
    :root {
      --school-primary: #1e40af;
      --school-primary-hover: #2563eb;
      --school-accent: #16a34a;
      --school-soft: #eff6ff;

      --school-canvas:
        color-mix(
          in srgb,
          var(--school-primary) 5%,
          white
        );

      --school-surface:
        color-mix(
          in srgb,
          var(--school-primary) 2%,
          white
        );

      --school-surface-soft:
        color-mix(
          in srgb,
          var(--school-primary) 7%,
          white
        );

      --school-surface-strong:
        color-mix(
          in srgb,
          var(--school-primary) 11%,
          white
        );

      --school-border:
        color-mix(
          in srgb,
          var(--school-primary) 17%,
          white
        );

      --school-border-strong:
        color-mix(
          in srgb,
          var(--school-primary) 28%,
          white
        );

      --school-gradient-start: #22d3ee;
      --school-gradient-end: #06b6d4;

      --primary: #0f172a;
      --primary-light: #334155;
      --secondary: var(--school-accent);
      --danger: #ef4444;
      --warning: #f59e0b;
      --success: #10b981;

      --light: var(--school-canvas);
      --gray: #94a3b8;
      --gray-light: var(--school-border);

      --radius-lg: 12px;
      --radius-md: 8px;
      --radius-sm: 6px;

      --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
      --shadow-md: 0 3px 6px rgba(0,0,0,0.15);
      --shadow-lg: 0 8px 20px rgba(0,0,0,0.15);

      --transition: all 0.2s ease-in-out;

      --primary-blue: var(--school-primary);
      --class-setup: #ffffff;

      --gradient-start: var(--school-gradient-start);
      --gradient-end: var(--school-gradient-end);

      --dark-text: #1f2937;
      --light-text: #f3f4f6;

      --bg-light: var(--school-surface-soft);
      --card-light: var(--school-surface);

      --sidebar-bg: var(--school-surface);
      --sidebar-active: var(--school-primary);
      --sidebar-text: #1e293b;

      --section-dashboard: var(--school-canvas);
      --section-students: var(--school-canvas);
      --section-houses: var(--school-canvas);

      --text: #1f2937;

      --primary: var(--school-primary);
      --primary-hover: var(--school-primary-hover);

      --border: var(--school-border);
      --teacher-silver: #a8b4bd;
      --teacher-hub-color: #14b8a6;
      --lb-gap: 12px;
      --lb-bar-h: 24px;
      --category-color-1: #e0f2fe;
      --category-color-2: #ecfdf5;
      --category-color-3: #fefce8;
      --category-color-4: #fff1f2;
      --category-color-5: #f3e8ff;
      --category-color-6: #ffedd5;
      --category-color-7: #e6f3ff;
      --category-color-8: #f0fdfa;
      --animation-duration: 60s;
    }
    
        @import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700;800&family=Fredoka+One&display=swap');
    
    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }
    
    body {
      font-family: 'Lexend', sans-serif; /* THE STUDENT FIX */
      background-color: var(--light);
      color: var(--dark-text);
      line-height: 1.6; /* Slightly more breathing room for easier reading */
      -webkit-font-smoothing: antialiased;
      font-size: 18px;
      letter-spacing: -0.01em; /* Tightens Lexend just enough for a pro look */
    }
    
    /* ⚡ SKELETON MASK: Hide app shell until data is ready */
    .app-container, .header, .announcement-bar, .mobile-nav {
      display: none !important;
    }
    
    /* Reveal App Shell on all devices */
    /* Reveal App Shell on all devices */
    body.ready .header, 
    body.ready .announcement-bar {
      display: flex !important;
    }
    
    body.ready .app-container {
      display: grid !important; /* ⚡ THE FIX: Restores the 180px sidebar layout */
    }
    
    /* 📱 MOBILE NAV: Only reveal if on a mobile-sized screen (max 1370px) */
    @media (max-width: 1370px) {
      body.ready .mobile-nav {
        display: flex !important;
      }
    }
    
    /* 🖥️ DESKTOP NAV: Ensure it stays hidden on large screens no matter what */
    @media (min-width: 1371px) {
      .mobile-nav {
        display: none !important;
      }
    }
    
    /* 📱 PROJECTOR VIEW VISIBILITY & STYLE */
    /* Hide completely on mobile phones (under 780px) */
    @media (max-width: 780px) {
      .btn-fullscreen-toggle,
      .inline-actions-group .btn-fullscreen-toggle,
      .dashboard-public-board-share {
        display: none !important;
      }
    }
    
    /* iPad/Tablet Specific: Show Icon + Text next to Projector Controls */
    @media (min-width: 781px) and (max-width: 1370px) {
      .inline-actions-group {
        display: flex !important;
        align-items: center;
        gap: 10px;
      }
    
      .inline-actions-group .btn-fullscreen-toggle {
        display: inline-flex !important;
        align-items: center;
        gap: 8px;
        height: 32px !important; /* Slightly taller for text */
        padding: 0 14px !important;
        font-size: 12px !important;
        font-weight: 700 !important;
        background: #f1f5f9 !important;
        border: 1px solid #cbd5e1 !important;
        color: var(--primary-blue) !important;
        border-radius: 8px !important;
        text-transform: uppercase;
      }
    }
    
    /* 🖼️ FORCE DESKTOP LAYOUT FOR PROJECTOR VIEW ON IPADS */
    @media (min-width: 781px) and (max-width: 1370px) {
      #fullscreenLeaderboard.show .hero-house-card {
        grid-template-columns: 50% 50% !important;
        padding: 32px !important;
        gap: 24px !important;
      }
    
    
      #fullscreenLeaderboard.show .hero-name {
        font-size: 60px !important; /* Restore desktop font size */
      }
    
      #fullscreenLeaderboard.show .hero-emoji {
        width: 200px !important;
        height: 200px !important;
        min-width: 200px !important;
        min-height: 200px !important;
      }
    
      #fullscreenLeaderboard.show .hero-points {
        font-size: 90px !important;
      }
    }
    
        
    
        .logo-inline {
          display: flex;
          align-items: center;
          gap: 8px;
        }
    
        .logo {
          font-size: 1.4rem;
          font-weight: 700;
          color: var(--light-text);
          white-space: nowrap;
        }
    
        .logo-pe {
      font-size: 1.2rem;
      color: #00ff00;
      border: 1.5px solid #00ff00;
      border-radius: 4px;
      background-color: rgba(0, 255, 0, 0.1);
      padding: 2px 4px;
      margin-right: .35em;
      display: inline-block;
    }
    
        .tagline {
          font-size: 0.85rem;
          font-weight: 400;
          color: var(--light-text);
          opacity: 0.9;
          white-space: nowrap;
        }
    
    
        .btn {
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 6px;
          padding: 8px 16px;
          border-radius: var(--radius-sm);
          font-weight: 600;
          font-size: 13px;
          cursor: pointer;
          transition: var(--transition);
          border: none;
          outline: none;
          white-space: nowrap;
        }
    
    .btn-primary {
      background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
      color: var(--light-text);
    }
    .btn-primary:hover {
      opacity: 0.95;
      transform: scale(1.03);
    }
    
        .btn-secondary {
          background-color: var(--bg-light);
          border: 1px solid var(--primary-blue);
          color: var(--primary-blue);
          transition:
            background-color 0.18s ease,
            color 0.18s ease,
            border-color 0.18s ease,
            transform 0.18s ease,
            box-shadow 0.18s ease;
        }
    
        .btn-secondary:hover {
          background-color: var(--primary-blue);
          border-color: var(--primary-blue);
          color: #ffffff;
          transform: translateY(-1px);
          box-shadow:
            0 4px 10px
            rgba(30, 64, 175, 0.18);
        }

        .btn-secondary:hover i {
          color: #ffffff;
        }
    
        .btn-warning {
          background-color: var(--warning);
          color: var(--light-text);
        }
    
        .btn-warning:hover {
          background-color: #d97706;
        }
    
        /* NEW: Green Success Button for +2 Points */
        .btn-success {
          background: linear-gradient(135deg, #10b981, #059669);
          color: var(--light-text);
          border: none;
        }
    
        .btn-success:hover {
          background: linear-gradient(135deg, #059669, #047857);
          transform: translateY(-1px);
          box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }
    
    /* Specific fix for the Award History Modal header which was likely blocking clicks */
    @media (max-width: 1370px) {
      #awardHistoryModal .modal-header {
        padding-top: 50px !important; /* Push header content down so it doesn't overlap the X */
      }
    }


    .header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions .btn {
  padding: 6px 12px;
  min-height: 32px;
  height: 32px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
}

.header-actions .btn i {
  font-size: 12px;
}

@media (max-width: 1370px) {
  .header-actions .btn {
    padding: 5px 10px;
    min-height: 28px;
    height: 28px;
    border-radius: 14px;
    font-size: 11px;
  }
  
  .header-actions .btn i {
    font-size: 11px;
  }

  /* Hide desktop Menu button and admin notification bell on phones and iPads */
  .desktop-admin-quick-actions,
  .header-actions .btn.desktop-smart-menu-button,
  .admin-notification-header-bell {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .header-actions .btn span.btn-text {
    display: none;
  }
  
  .header-actions .btn {
    width: 32px;
    padding: 5px 0;
    justify-content: center;
  }
  
  .header-actions .btn i {
    margin: 0;
  }
}
    
        .btn-close:hover {
          background: #b91c1c;
        }
    
        /* Fix: Let buttons keep their original position (fixed or relative) when loading */
        .btn.loading {
          opacity: 0.7;
          cursor: not-allowed;
          /* Removed position: inherit !important; */
          display: inline-flex;
          align-items: center;
          justify-content: center;
        }
    
        /* High-visibility Blue Spinner for Loading Buttons */
        .btn.loading::after {
          content: '';
          display: inline-block;
          width: 16px; /* Slightly larger */
          height: 16px;
          /* Using a vibrant blue for the wheel and a faint gray for the track */
          border: 3px solid rgba(30, 64, 175, 0.2); 
          border-top-color: #1e40af; /* Your primary-blue color */
          border-radius: 50%;
          animation: spin 0.8s linear infinite;
          margin-left: 10px;
          flex-shrink: 0;
        }
    
        @keyframes spin {
          100% { transform: rotate(360deg); }
        }
    
        .app-container {
          display: grid;
          grid-template-columns: 220px 1fr;
          min-height: 100vh;
          padding-top: 0;
          transition:
            grid-template-columns
            0.2s
            ease;
        }


        @media (min-width: 1371px) {

          body.dashboard-sidebar-collapsed
          .app-container {
            grid-template-columns: 1fr;
          }


          body.dashboard-sidebar-collapsed
          .sidebar {
            display: none !important;
          }


          body.dashboard-sidebar-collapsed
          #schoolValuesBar {
            display: none !important;
          }

        }
    
        .sidebar {
      background: #ffffff;
      border-right: 1px solid #e2e8f0;
      padding: 16px 12px;
      height: 100vh;
      position: sticky;
      top: 0;
      overflow-y: auto;
      box-shadow: none;
    }
    
    .sidebar .nav-item {
      margin-top: 3px;
    }

    .sidebar .nav-item:first-child {
      margin-top: 3px;
    }

    .sidebar-section {
      margin-bottom: 16px;
      padding: 0 8px;
    }


    .sidebar-nav-label {
      display:block;

      margin:
        14px
        8px
        6px;

      color:#94a3b8;

      font-size:9px;
      font-weight:850;

      letter-spacing:.9px;

      text-transform:uppercase;

      line-height:1;
    }


    .sidebar-section .sidebar-nav-label:first-child {
      margin-top:2px;
    }

    /* ==========================================
   COMPACT SIDEBAR GROUPS
   ========================================== */

.sidebar-nav-group {
  margin:
    3px
    0;

  border:0;
}


.sidebar-nav-group > summary {
  list-style:none;
}


.sidebar-nav-group > summary::-webkit-details-marker {
  display:none;
}


.sidebar-nav-group-toggle {
  min-height:38px;

  display:flex;
  align-items:center;
  justify-content:space-between;

  gap:8px;

  padding:
    8px
    10px;

  border:
    1px solid
    transparent;

  border-radius:10px;

  color:#475569;

  font-size:12px;
  font-weight:700;

  cursor:pointer;

  user-select:none;

  transition:
    background .18s ease,
    color .18s ease;
}


.sidebar-nav-group-toggle:hover {
  background:#f1f5f9;
  color:#0f172a;
}


.sidebar-nav-group-main {
  display:flex;
  align-items:center;
  gap:10px;

  min-width:0;
}


.sidebar-nav-group-main > i {
  width:20px;

  flex-shrink:0;

  text-align:center;

  color:#64748b;

  font-size:16px;
}


.sidebar-nav-chevron {
  flex-shrink:0;

  color:#94a3b8;

  font-size:10px;

  transition:
    transform .18s ease;
}


.sidebar-nav-group[open]
.sidebar-nav-chevron {
  transform:
    rotate(180deg);
}


.sidebar-nav-group-items {
  margin:
    2px
    0
    5px
    13px;

  padding-left:8px;

  border-left:
    1px solid
    #e2e8f0;
}


.sidebar-nav-group-items
.nav-item {
  min-height:34px;

  padding:
    6px
    8px;

  font-size:11px;
}


.sidebar-nav-group-items
.nav-item i {
  font-size:14px;
}


/* ==========================================
   SIDEBAR SECONDARY MENU GROUPS
   ========================================== */

#sidebarStudentsGroup,
#sidebarSchoolManagementGroup {
  margin: 0;
  border: none;
  background: transparent !important;
}

/* Separate the main tools from the secondary menus */
#sidebarStudentsGroup {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}

/* Simple text headings, not buttons */
#sidebarStudentsGroup > summary,
#sidebarSchoolManagementGroup > summary {
  min-height: 32px;
  padding: 6px 10px;
  border: none !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;

  color: #64748b !important;
  font-size: 12px;
  font-weight: 600;

  cursor: pointer;
}

/* No selected-looking background */
#sidebarStudentsGroup > summary:hover,
#sidebarSchoolManagementGroup > summary:hover,
#sidebarStudentsGroup[open] > summary,
#sidebarSchoolManagementGroup[open] > summary {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  color: #334155 !important;
}

/* Hide large heading icons */
#sidebarStudentsGroup .sidebar-nav-group-main > i,
#sidebarSchoolManagementGroup .sidebar-nav-group-main > i {
  display: none !important;
}

/* Keep headings on one line */
#sidebarStudentsGroup .sidebar-nav-group-main,
#sidebarSchoolManagementGroup .sidebar-nav-group-main {
  gap: 0;
  min-width: 0;
}

#sidebarStudentsGroup .sidebar-nav-group-main > span,
#sidebarSchoolManagementGroup .sidebar-nav-group-main > span {
  white-space: nowrap;
}

/* Small, quiet dropdown arrows */
#sidebarStudentsGroup .sidebar-nav-chevron,
#sidebarSchoolManagementGroup .sidebar-nav-chevron {
  font-size: 10px;
  color: #94a3b8 !important;
  margin-left: 8px;
}

/* Space between the two headings */
#sidebarSchoolManagementGroup {
  margin-top: 4px;
}

/* Keep the menu items neatly indented */
#sidebarStudentsGroup .sidebar-nav-group-items,
#sidebarSchoolManagementGroup .sidebar-nav-group-items {
  margin-left: 10px;
}

/* Dark mode */
body.house-display-dark #sidebarStudentsGroup {
  border-top-color: #334155;
}

body.house-display-dark #sidebarStudentsGroup > summary,
body.house-display-dark #sidebarSchoolManagementGroup > summary {
  background: transparent !important;
  color: #cbd5e1 !important;
}

body.house-display-dark #sidebarStudentsGroup > summary:hover,
body.house-display-dark #sidebarSchoolManagementGroup > summary:hover,
body.house-display-dark #sidebarStudentsGroup[open] > summary,
body.house-display-dark #sidebarSchoolManagementGroup[open] > summary {
  background: transparent !important;
  color: #ffffff !important;
}


/* ==========================================
   SLIGHTLY TIGHTER MAIN SIDEBAR
   ========================================== */

.sidebar-section {
  margin-bottom:10px;
}


.sidebar-nav-label {
  margin:
    11px
    8px
    5px;
}


.sidebar .nav-item {
  margin-top:2px;
}


.nav-item {
  min-height:36px;

  padding:
    7px
    10px;
}


    .sidebar-title {
      font-size:9px;
      text-transform:uppercase;
      letter-spacing:.8px;
      color:#94a3b8;
      margin-bottom:6px;
      font-weight:800;
      cursor:pointer;
      display:flex;
      align-items:center;
      gap:5px;
      padding:5px 8px;
      border-radius:8px;
      transition:
        background .18s ease,
        color .18s ease;
    }


    .sidebar-title:hover {
      background:#f8fafc;
      color:#475569;
    }


    .nav-item {
      position:relative;

      display:flex;
      align-items:center;
      gap:10px;

      min-height:38px;

      padding:
        8px
        10px;

      border:
        1px solid
        transparent;

      border-radius:10px;

      margin-bottom:2px;

      background:transparent;

      color:#475569;

      text-decoration:none;

      font-weight:700;
      font-size:12px;
      line-height:1.2;

      transition:
        background .16s ease,
        color .16s ease,
        border-color .16s ease;

      box-shadow:none;
    }


    .nav-item i {
      width:18px;

      flex:0 0 18px;

      color:#64748b;

      font-size:14px;

      text-align:center;

      transition:
        color .16s ease;
    }


    .nav-item:hover {
      background:#f1f5f9;
      color:#0f172a;

      border-color:transparent;

      transform:none;
      box-shadow:none;
    }


    .nav-item:hover i {
      color:#475569;
    }

    .sidebar .nav-item:focus-visible,
    .sidebar .sidebar-nav-group-toggle:focus-visible {
      outline:2px solid #2563eb;
      outline-offset:2px;
    }


    .nav-item.active {
      background:#eff6ff !important;

      color:#1d4ed8 !important;

      border-color:#dbeafe !important;

      box-shadow:none !important;

      font-weight:800;
    }


    .sidebar .nav-item.active::before {
      content:none;
    }


    .nav-item.active i {
      color:#2563eb !important;
    }

    /* Desktop sidebar: neutral icons except the selected item. */
    @media (min-width:1371px) {
      body:not(.house-display-dark)
      .sidebar .nav-item:not(.active):not(.static) > i,
      body:not(.house-display-dark)
      .sidebar .sidebar-nav-group-main > i {
        color:#64748b !important;
      }

      body:not(.house-display-dark)
      .sidebar .nav-item:not(.active):hover > i,
      body:not(.house-display-dark)
      .sidebar .sidebar-nav-group-toggle:hover
      .sidebar-nav-group-main > i {
        color:#334155 !important;
      }

      body:not(.house-display-dark)
      .sidebar .nav-item.active > i {
        color:#2563eb !important;
      }
    }
    
        .main-content {
          padding: 24px;
          width: 100%;
        }

        /* Give teacher settings room on iPads and phones. */
        @media (max-width: 1370px) {
          #systemSetupModal #teacherJoinCodeActions {
            width: 100%;
            min-width: 0 !important;
          }

          #systemSetupModal #pendingApprovalsCard,
          #systemSetupModal #approvedTeachersCard,
          #systemSetupModal #sameDomainTeachersCard {
            max-width: 100%;
            min-width: 0;
            padding: 14px !important;
          }

          #systemSetupModal #pendingApprovalsCard > div:first-child {
            flex-wrap: wrap;
          }

          #systemSetupModal #systemMaintenanceCard {
            min-width: 0;
          }
        }
    
    
    
    
        
    
        .page-header {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 24px;
        }
    
        .page-title {
          font-size: 22px;
          font-weight: 700;
          color: var(--primary-blue);
        }
    
        .page-actions {
          display: flex;
          gap: 10px;
          flex-wrap: wrap;
        }
    
        .card {
          background: #ffffff;
          border: 1px solid #e8edf3;
          border-radius: 14px;
          box-shadow: 0 2px 8px rgba(15, 23, 42, 0.045);
          padding: 18px;
          margin-bottom: 18px;
          transition:
            border-color 0.18s ease,
            box-shadow 0.18s ease;
        }

        .card:hover {
          border-color: #dbe3ec;
          box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
        }
    
    .card-header {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 6px;
      margin-bottom: 10px;
    }

        .card-title {
          font-size: 15px;
          font-weight: 700;
          color: #0f172a;
          display: flex;
          align-items: center;
          gap: 7px;
          letter-spacing: -0.01em;
        }
    
    
    
        .house-card {
          background: #ffffff;
          border-radius: 14px;
          padding: 16px;
          border: 1px solid #e8edf3;
          box-shadow: 0 2px 8px rgba(15,23,42,0.045);
          transition:
            border-color 0.18s ease,
            box-shadow 0.18s ease,
            transform 0.18s ease;
          position: relative;
          overflow: hidden;
          cursor: pointer;
          min-height: 120px;
          display: flex;
          flex-direction: column;
          justify-content: space-between;
        }

        .click-hint {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f8fafc;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  transition: background 0.18s ease;
  animation: none;

  white-space: nowrap;
  flex-wrap: nowrap;
  width: auto;
  min-width: max-content;
  flex-shrink: 0;
}

        .click-hint i {
          font-size: 9px;
          color: #64748b;
        }

        .house-card:hover {
          transform: translateY(-2px);
          border-color: #cbd5e1;
          box-shadow: 0 6px 18px rgba(15,23,42,0.08);
        }
    
    
    
    @media (max-width: 1370px) {
      /* 1. Header ONLY visible on Dashboard */
      body:not(.active-section-dashboard) .header {
        display: none !important;
      }
      
      /* 2. Announcement Bar VISIBLE EVERYWHERE */
      .announcement-bar {
        display: flex !important;
      }

      /* 3. When NOT on dashboard, slide announcement bar up to the top */
      body:not(.active-section-dashboard) .announcement-bar {
        top: 0 !important;
      }

      /* 4. Adjust App Container Padding */
      .app-container {
        padding-top: 92px !important; /* Dashboard: Header + AnnBar */
      }
      body:not(.active-section-dashboard) .app-container {
        padding-top: 44px !important; /* Other Pages: AnnBar only */
      }
      
      .main-content {
        margin-top: 0 !important;
      }

      /* 5. Adjust Student Section fixed height/top */
      #students-section {
        top: 92px !important;
        height: calc(100vh - 92px) !important;
      }
      body:not(.active-section-dashboard) #students-section {
        top: 44px !important;
        height: calc(100vh - 44px) !important;
      }
    }
    
    

/* Fix for lock icons being clipped on sidebar nav items */
.sidebar .nav-item {
  position: relative;
  overflow: visible !important;
  padding-right: 20px !important;
}

.sidebar {
  overflow-x: visible !important;
  overflow-y: auto !important;
}

/* Ensure the lock icon stays within the button's visual area */
.lock-icon-overlay {
  position: absolute;
  top: -6px;
  right: -4px;
  background: #1e293b;
  color: #fbbf24;
  font-size: 9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #fbbf24;
  z-index: 100;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  pointer-events: none;
}

/* Remove any overflow-hidden from parent containers */
.sidebar-section {
  overflow: visible !important;
}

.sidebar-logo {
  overflow: visible !important;
}

    
    
    /* Hide on mobile since touch is intuitive */
    @media (max-width: 1370px) {
      .click-hint {
        display: none !important;
      }
    }
    
        .house-card::before {
          content: '';
          position: absolute;
          top: 0;
          left: 14px;
          right: 14px;
          width: auto;
          height: 3px;
          border-radius: 0 0 999px 999px;
          background: var(--house-color, #2563eb);
        }

        .house-card-header {
          display: flex;
          align-items: center;
          gap: 10px;
          margin-bottom: 10px;
        }

        .house-emoji {
          font-size: 24px;
          width: 38px;
          height: 38px;
          background: #f8fafc;
          border: 1px solid #e2e8f0;
          border-radius: 10px;
          display: flex;
          align-items: center;
          justify-content: center;
          box-shadow: none;
          flex-shrink: 0;
        }

        .house-name {
          font-size: 15px;
          font-weight: 750;
          margin-bottom: 2px;
          color: #0f172a;
        }

        .house-motto {
          font-size: 10.5px;
          color: #64748b;
          font-style: normal;
          line-height: 1.35;
        }
    
        .house-progress {
          margin-top: 10px;
        }
    
        .progress-bar {
          height: 6px;
          background: var(--gray-light);
          border-radius: 3px;
          overflow: hidden;
          margin-bottom: 6px;
        }
    
        .progress-fill {
      height: 100%;
      border-radius: 3px;
      background: var(--house-color, linear-gradient(90deg, var(--primary-blue), var(--gradient-end)));
    }
    
        .house-stats {
          display: flex;
          justify-content: space-between;
          gap: 10px;
          margin-top: 10px;
          padding-top: 10px;
          border-top: 1px solid #f1f5f9;
        }

        .stat-item {
          text-align: left;
          flex: 1;
        }

        .stat-value {
          font-size: 15px;
          font-weight: 800;
          color: #0f172a;
          line-height: 1.2;
        }

        .stat-label {
          font-size: 8.5px;
          color: #94a3b8;
          text-transform: uppercase;
          letter-spacing: 0.5px;
          font-weight: 700;
        }
    
    .house-expanded {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,0.85);
      z-index: 1100; /* Higher than nav-bar (998) and other modals (1000) */
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.3s ease;
    }
    
        .house-expanded.show {
          opacity: 1;
          pointer-events: all;
        }
    
        .house-expanded-content {
          background: var(--card-light);
          border-radius: var(--radius-lg);
          width: 90%;
          max-width: 700px;
          max-height: 85vh;
          overflow-y: auto;
          padding: 20px;
          position: relative;
          transform: translateY(15px);
          transition: transform 0.3s ease;
        }
    
        .house-expanded.show .house-expanded-content {
          transform: translateY(0);
        }
    
    
    
      #awardHistoryModal .modal-header {
      position: relative;
      z-index: 2000; /* Ensure header is below close button */
      padding-right: 60px !important; /* Make room for the X button */
    }
    
    /* Ensure the close button is properly positioned for Award History */
    #awardHistoryModal .house-expanded-close {
      position: absolute !important;
      top: 15px !important;
      right: 15px !important;
      z-index: 10000 !important;
    }
    
    @media (max-width: 1370px) {
      #awardHistoryModal .modal-header {
        padding-right: 50px !important;
      }
    }
    #awardHistoryModal .form-control {
      z-index: 2500; /* Ensure dropdowns are below close button but above other content */
    }
    
       .house-expanded-header {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-bottom: 12px;
      position: relative;
      touch-action: pan-y; /* Prevents scroll interference with swipe */
    }
    .house-title-container {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    .house-expanded-motto {
      margin: 0;
      font-size: 13px;
      color: var(--gray);
      font-style: italic;
    }
    .house-swipe-controls {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      margin-bottom: 10px;
    }
    .swipe-btn {
      background: var(--primary-blue);
      color: var(--light-text);
      border: none;
      border-radius: 50%;
      width: 40px;
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      box-shadow: var(--shadow-sm);
      font-size: 16px;
      transition: var(--transition);
      opacity: 0.8;
    }
    .swipe-btn:hover {
      opacity: 1;
      transform: scale(1.1);
    }
    .swipe-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }
    
    @media (max-width: 480px) {
      .swipe-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
      }
    }
    .house-title-container {
      display: flex;
      align-items: baseline;
      gap: 8px;
    }
    .house-expanded-title {
      font-size: 18px;
      margin: 0;
    }
    .house-expanded-content .house-expanded-top-title {
      font-size: 15px;
      font-weight: 600;
      margin-bottom: 10px;
      display: flex;
      align-items: center;
      gap: 6px;
      color: var(--house-color, var(--primary-blue)) !important; /* Ensure house color applies */
    }
    
    .house-expanded-title {
      font-size: 22px;
      font-weight: 700;
      color: var(--house-color, var(--primary-blue)); /* Use house color, fallback to primary-blue */
    }
    
    .house-ranking {
      font-size: 14px;
      font-weight: 600;
      color: var(--house-color, var(--primary-blue)); /* Use house color, fallback to primary-blue */
    }
    @media (max-width: 1370px) {
      .house-expanded-content {
        -ms-touch-action: pan-y;
        touch-action: pan-y;
      }
    }
    .house-badge-row {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;
      margin: 12px 0;
      gap: 6px;
    }
    .house-badge-row::before {
      content: "🏅 Current House Badge: ";
      font-size: 13px;
      color: var(--gray);
    }
    .house-badge-item {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 12px;
      background: var(--milestone-color, #e6e6e6);
      border-radius: var(--radius-sm);
      font-size: 14px;
      font-weight: 700;
      color: var(--light-text);
      box-shadow: var(--shadow-sm);
    }
    .house-badge-item[style*="linear-gradient"] {
      background: var(--milestone-color);
    }
    .house-badge-item .house-badge-emoji {
      font-size: 14px;
      width: 18px;
      height: 18px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
        .house-expanded-emoji {
          font-size: 40px;
          width: 70px;
          height: 70px;
          background: rgba(0,0,0,0.1);
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
        }
    
        
    
        .house-expanded-motto {
          color: var(--gray);
          font-style: italic;
          margin-top: 3px;
          font-size: 13px;
        }
    
        .house-expanded-stats {
          display: grid;
          grid-template-columns: repeat(3, 1fr);
          gap: 12px;
          margin-bottom: 20px;
        }
    
        .house-expanded-stat {
          background: var(--light);
          border-radius: var(--radius-md);
          padding: 12px;
          text-align: center;
        }
    
        .house-expanded-stat-value {
          font-size: 22px;
          font-weight: 700;
          color: var(--primary-blue);
        }
    
        .house-expanded-stat-label {
          font-size: 11px;
          color: var(--gray);
          text-transform: uppercase;
        }
    
        .house-expanded-top-students {
          margin-top: 20px;
        }
    
        
    
        .house-expanded-top-list {
          display: grid;
          gap: 6px;
        }
    
        .house-expanded-top-item {
          display: flex;
          align-items: center;
          padding: 6px 10px;
          background: var(--light);
          border-radius: var(--radius-sm);
        }
    
        .house-expanded-top-rank {
          font-weight: 700;
          color: var(--primary-blue);
          width: 20px;
          text-align: center;
        }
    
        .house-expanded-top-name {
          flex: 1;
          margin: 0 10px;
        }
    
        .house-expanded-top-points {
          font-weight: 600;
          color: var(--primary-blue);
        }
    
        .leaderboard-item {
          display: flex;
          align-items: center;
          gap: 14px;
          margin-bottom: 8px;
          padding: 10px 12px;
          border-radius: 12px;
          background: #ffffff;
          border: 1px solid transparent;
          transition:
            background 0.18s ease,
            border-color 0.18s ease;
        }

        .leaderboard-item:hover {
          background: #f8fafc;
          border-color: #eef2f7;
        }


        /* ==========================================
           DASHBOARD LEADER REVEAL
           ========================================== */

        .leaderboard-item:first-child {
          animation:
            fadeIn 0.3s ease-out forwards,
            leaderboardWinnerPulse 0.75s ease-out 1.55s;
        }


        .leaderboard-item:first-child .leaderboard-rank {
          animation:
            leaderboardWinnerMedalPop
            0.55s
            cubic-bezier(0.34, 1.56, 0.64, 1)
            1.55s;
        }


        @keyframes leaderboardWinnerPulse {
          0% {
            box-shadow:
              0 0 0 rgba(245,158,11,0);
          }

          45% {
            box-shadow:
              0 0 0 3px rgba(245,158,11,0.18),
              0 8px 22px rgba(245,158,11,0.20);
          }

          100% {
            box-shadow:
              0 0 0 rgba(245,158,11,0);
          }
        }


        @keyframes leaderboardWinnerMedalPop {
          0% {
            transform: scale(1);
          }

          45% {
            transform: scale(1.18);
          }

          100% {
            transform: scale(1);
          }
        }


        @media (prefers-reduced-motion: reduce) {
          .leaderboard-item:first-child,
          .leaderboard-item:first-child .leaderboard-rank {
            animation: none;
          }
        }
    
        .leaderboard-rank {
          font-weight: 800;
          color: #64748b;
          width: 34px;
          min-width: 34px;
          text-align: center;
          font-size: 12px;
        }
    
    .nav-item.static {
      background: none;
      color: var(--sidebar-text);
      opacity: 0.8;
      cursor: default;
      pointer-events: none;
      user-select: none;
    }

    .nav-item.static:hover {
      background: none;
      transform: none;
      box-shadow: none;
    }
    
        .leaderboard-house {
          flex: 0 0 280px;
          margin: 0;
          min-width: 0;
        }
    
    /* =========================================================
       🎰 CASINO ANIMATIONS (DASHBOARD)
       ========================================================= */
    @keyframes casinoBarGrow {
      0% {
        width: 0%;
      }

      100% {
        width: var(--target-width);
      }
    }
    
    /* Leaderboard bars physically fill from 0 */
    .leaderboard-bar {
      width: 0%;
      animation:
        casinoBarGrow
        1.6s
        cubic-bezier(0.16, 1, 0.3, 1)
        forwards;
    }


    .leaderboard-item:nth-child(1) .leaderboard-bar {
      animation-delay: 0.05s;
    }

    .leaderboard-item:nth-child(2) .leaderboard-bar {
      animation-delay: 0.18s;
    }

    .leaderboard-item:nth-child(3) .leaderboard-bar {
      animation-delay: 0.31s;
    }

    .leaderboard-item:nth-child(4) .leaderboard-bar {
      animation-delay: 0.44s;
    }
    
    /* House Overview Bars */
    .overview-progress-fill {
      height: 100%;
      border-radius: 4px;
      width: 0%;
      animation:
        casinoBarGrow
        1.5s
        cubic-bezier(0.16, 1, 0.3, 1)
        forwards;
    }


    @media (prefers-reduced-motion: reduce) {
      .leaderboard-bar,
      .overview-progress-fill {
        animation: none;
        width: var(--target-width);
      }
    }
    
        .leaderboard-points {
          font-weight: 800;
          margin-left: 0;
          min-width: 90px;
          text-align: right;
          color: #0f172a;
          font-size: 14px;
        }
    
    
    .leaderboard-fullscreen-item {
      margin-bottom: 12px;
      padding: 10px;
      background: #ffffff;
      border-radius: var(--radius-sm);
      box-shadow: 0 6px 16px rgba(2, 6, 23, 0.12);
    }
    
    .leaderboard-fullscreen-rank {
      font-size: 16px;
      font-weight: 800;
      color: #fff;
      width: auto;
      min-width: 36px;
      text-align: center;
      padding: 4px 10px;
      border-radius: 10px;
      background: #1e40af;
    }
    
    .leaderboard-fullscreen-house{
      font-size: 18px;
      flex: 0 0 26%;        /* fixed width for name column */
      margin: 0 6px;
    }
    
    .leaderboard-fullscreen-bar-container{
      flex: 0 0 52%;                       /* narrower than before */
      max-width: 52%;
      height: var(--lb-bar-h);             /* uses variable below */
      background: var(--gray-light);
      border-radius: calc(var(--lb-bar-h) / 2);
      overflow: hidden;
      margin-right: 10px;                  /* space before points chip */
    }
    
    .leaderboard-fullscreen-bar {
      height: 100%;
      border-radius: 10px;
      background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
      transition: width 0.45s ease; /* snappier */
    }
    
    .leaderboard-fullscreen-points {
      font-size: 24px;
      font-weight: 800;
      margin-left: 12px;
      min-width: 120px;
      text-align: right;
      color: #fff;
      background: #0ea5e9;
      padding: 8px 16px;
      border-radius: 999px;
    }
    
    
    /* Brand chip for fullscreen header */
    .leaderboard-brand{
      display:flex; align-items:center; gap:10px;
      background:#fff; border-radius:9999px; padding:6px 12px;
      box-shadow:0 6px 20px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
      flex-shrink:0;
    }
    .leaderboard-brand img{
      height:64px; width:64px; border-radius:9999px; display:block;
    }
    
    .leaderboard-brand-text{line-height:1.05}
    .leaderboard-brand-title{font-weight:800; letter-spacing:.2px; color:#1e3a8a}
    .leaderboard-brand-sub{font-size:12px; color:#64748b}
    @media (min-width:1200px){
      .leaderboard-brand img{height:56px; width:56px}
      .leaderboard-brand-sub{font-size:13px}
    }
    
    
    .leaderboard-fullscreen.show .leaderboard-fullscreen-title {
      font-size: 16px; /* Reduced from 30px */
      font-weight: 700;
      color: var(--primary-blue);
      flex: 1;
      min-width: 200px;
    }
    .leaderboard-fullscreen-stats {
      display: flex;
      gap: 12px;
      flex: 2;
      min-width: 320px;
      justify-content: center;
    }
    .leaderboard-fullscreen-stat {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 12px;
      background: var(--light);
      border-radius: 999px;
    }
    
    .leaderboard-fullscreen-stat-value {
      font-size: 14px;
      font-weight: 600;
      color: var(--primary-blue);
    }
    .leaderboard-fullscreen-stat-label {
      font-size: 10px;
      color: var(--gray);
      text-transform: uppercase;
    }
    .leaderboard-fullscreen-close {
      background: var(--danger);
      color: var(--light-text);
      border: none;
      border-radius: 50%;
      width: 28px;
      height: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: transform 0.2s ease;
      flex-shrink: 0;
    }
    .leaderboard-fullscreen-close:hover {
      transform: scale(1.1);
    }
    
    .leaderboard-fullscreen-tv-mode {
      background: #1a8bb5;
      color: var(--light-text);
      border: none;
      padding: 6px 12px;
      border-radius: 5px;
      cursor: pointer;
      font-size: 12px;
      transition: background 0.2s, transform 0.2s;
      flex-shrink: 0;
    }
    .leaderboard-fullscreen-tv-mode:hover {
      background: #156f94;
      transform: scale(1.05);
    }
    .leaderboard-fullscreen-tv-mode .spinner {
      display: none;
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      border: 2px solid var(--light-text);
      border-top: 2px solid transparent;
      border-radius: 50%;
      width: 12px;
      height: 12px;
      animation: spin 1s linear infinite;
    }
    .leaderboard-fullscreen-tv-mode.loading .spinner {
      display: inline-block;
    }
    
    
    .leaderboard-fullscreen {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: linear-gradient(135deg, #f1f5f9, #e0f2fe);
      z-index: 10001;
      display: flex;
      flex-direction: column;
      overflow-y: auto; /* Enable vertical scrolling */
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.3s ease;
    }
    .leaderboard-fullscreen.show {
      opacity: 1;
      pointer-events: all;
    }
    
    .leaderboard-announcement-bar {
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 20px 16px; /* Standardized to 20px vertical padding */
      background: linear-gradient(135deg, #FFD700, #FFFACD);
      border-bottom: 1px solid var(--gray-light);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      z-index: 9;
      overflow: hidden;
    }
    
    .leaderboard-fullscreen.show .hero-house-card {
      margin-top: 16px; /* Reduced to move content up and minimize gap */
    }
    .leaderboard-announcement-bar .announcement-content {
      display: flex;
      align-items: center;
      gap: 20px;
      font-size: 32px;
      font-weight: 900;
      color: var(--dark-text);
      width: 90%;
      max-width: 1600px;
      overflow: hidden;
    }
    .leaderboard-announcement-bar .announcement-icon {
      font-size: 36px;
      color: var(--dark-text);
    }
    #leaderboardAnnouncementText {
      white-space: nowrap;
      display: inline-block;
      padding-left: 12px;
    }
    #leaderboardAnnouncementText .text-content {
      display: inline-block;
      padding-right: 40px; /* Space between duplicated text */
    }
    @keyframes marquee {
      0% { transform: translateX(0%); }
      100% { transform: translateX(-50%); } /* Seamless loop with duplicated text */
    }
    .leaderboard-announcement-bar .announcement-content.scrolling #leaderboardAnnouncementText,
    .announcement-bar .announcement-content.scrolling #announcementText {
      animation: marquee var(--animation-duration, 60s) linear infinite;
      animation-play-state: running;
      animation-delay: 0s;
      will-change: transform;
    }
    @media (max-width: 1370px) {
      .leaderboard-announcement-bar {
       padding: 20px 16px; /* Maintain 20px vertical padding */
      }
      .leaderboard-announcement-bar .announcement-content {
        font-size: 24px;
        gap: 16px;
      }
      .leaderboard-announcement-bar .announcement-icon {
        font-size: 28px;
      }
    .leaderboard-announcement-bar .announcement-content.scrolling #leaderboardAnnouncementText,
      .announcement-bar .announcement-content.scrolling #announcementText {
        animation: marquee var(--animation-duration, 48s) linear infinite;
        animation-delay: 0s;
      }
    
      .leaderboard-announcement-bar .announcement-title {
        font-size: 20px;
      }
    }
    @media (max-width: 480px) {
      .leaderboard-announcement-bar {
    padding: 20px 12px; /* Maintain 20px vertical padding, adjust horizontal */
      }
      .leaderboard-announcement-bar .announcement-content {
        font-size: 18px;
      }
      .leaderboard-announcement-bar .announcement-icon {
        font-size: 22px;
      }
    .leaderboard-announcement-bar .announcement-content.scrolling #leaderboardAnnouncementText,
      .announcement-bar .announcement-content.scrolling #announcementText {
        animation: marquee var(--animation-duration, 36s) linear infinite;
        animation-delay: 0s;
      }
      .leaderboard-announcement-bar .announcement-title {
        font-size: 16px;
      }
    }
    .leaderboard-brand {
      display: flex;
      align-items: center;
      gap: 12px;
      flex-shrink: 0;
    }
    .leaderboard-brand img {
      height: 100px !important; /* Larger than inline 84px, smaller than sidebar 120px */
      width: 100px !important; /* Override inline styles */
      border-radius: 9999px;
      animation: float 3s ease-in-out infinite;
      object-fit: contain; /* Ensure proportional scaling */
      padding: 0; /* Remove padding for no white gap */
      margin: 0; /* Remove margin for no white gap */
    }
    .leaderboard-brand-text {
      display: flex;
      flex-direction: column;
    }
    .leaderboard-brand-title {
      font-size: 24px;
      font-weight: 800;
      color: #1e293b;
    }
    .leaderboard-brand-sub {
      font-size: 14px;
      color: #64748b;
    }
    .leaderboard-fullscreen-header {
      display: flex;
      align-items: center;
      justify-content: space-around; /* Changed from space-between to reduce spread */
      gap: 12px;
      padding: 12px 24px;
      background: rgba(255,255,255,0.95);
      backdrop-filter: blur(10px);
      border-radius: var(--radius-md);
      box-shadow: 0 4px 12px rgba(0,0,0,0.1);
      position: sticky;
      top: 0;
      z-index: 10;
    }
    .leaderboard-fullscreen-stats {
      display: flex;
      gap: 8px; /* Reduced from 12px for tighter grouping */
      flex-wrap: nowrap; /* Prevent wrapping */
      justify-content: flex-start; /* Align left for cohesive strip */
      background: linear-gradient(135deg, #0ea5e9, #22d3ee); /* Unified background */
      border-radius: 999px; /* Pill shape for the group */
      padding: 4px 8px; /* Padding around the group */
      max-width: 600px; /* Constrain width to avoid spreading */
    }
    .leaderboard-fullscreen-stat {
      display: flex;
      align-items: center;
      gap: 6px; /* Reduced from 8px for compactness */
      padding: 4px 8px; /* Reduced padding for tighter fit */
      color: #fff;
      font-weight: 700;
      font-size: 14px; /* Slightly smaller for balance */
      background: transparent; /* Remove individual pill backgrounds */
    }
    .leaderboard-fullscreen-stat-label {
      font-size: 12px; /* Reduced from 14px */
      text-transform: uppercase;
      color: #fff;
    }
    .leaderboard-fullscreen-stat-value {
      font-size: 16px; /* Reduced from 18px */
      font-weight: 900;
      color: #fff;
    }
    
    .leaderboard-fullscreen-controls {
      display: flex;
      gap: 8px;
      flex-shrink: 0;
    }
    .leaderboard-fullscreen-controls button {
      background: #1e40af;
      color: #fff;
      border: none;
      border-radius: 8px;
      padding: 10px;
      cursor: pointer;
      font-size: 18px;
      transition: transform 0.2s ease, background 0.2s ease;
    }
    .leaderboard-fullscreen-controls button:hover {
      background: #3b82f6;
      transform: scale(1.1);
    }
    /* Remove the pseudo-elements that cause double icons */
.leaderboard-fullscreen-controls .pause-play.playing::before,
.leaderboard-fullscreen-controls .pause-play.paused::before {
  content: none !important;
}
    .leaderboard-fullscreen-content {
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;
    
      /* Consistent small gap around */
      padding: clamp(8px, 2vw, 24px);
    }
    
    /* Fullscreen hero card */
    .hero-house-card {
      width: 100%;
      max-width: none; /* allow full width */
      margin: 0 auto; /* centered within gutters */
      background: var(--card-light);
      border-radius: var(--radius-lg);
      box-shadow: 0 12px 32px rgba(2, 6, 23, 0.2);
      padding: clamp(16px, 2.5vw, 32px);
      display: grid;
      grid-template-columns: 50% 50%;
      gap: clamp(12px, 2vw, 24px);
      opacity: 0;
      transform: translateY(20px);
      transition: opacity 0.5s ease, transform 0.5s ease;
      min-height: fit-content; /* Flexible height */
    }
    
    
    .hero-house-card.show {
      opacity: 1;
      transform: translateY(0);
    }
    
    
    
    @keyframes gentle-pulse {
      0% { transform: scale(1); }
      50% { transform: scale(1.05); }
      100% { transform: scale(1); }
    }
    @keyframes fadeInScale {
      0% { opacity: 0; transform: scale(0.8); }
      100% { opacity: 1; transform: scale(1); }
    }
    
    
    
    
    
    .hero-title {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    /* NEW PREMIUM CSS - FIXED (No Gap) */
    .leaderboard-fullscreen.show .hero-house-card .hero-emoji {
      position: relative; 
      width: 200px !important;
      height: 200px !important;
      min-width: 200px !important;
      min-height: 200px !important;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      
      /* 1. Border definition */
      border: 6px solid var(--house-color, #1e40af); 
      box-sizing: border-box; /* Critical: Ensures border sits outside the content area */
      
      /* 2. REMOVED PADDING so image touches the border */
      padding: 0 !important; 
      
      /* 3. Background for the "Letter" view */
      background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%); 
      
      box-shadow: 0 10px 30px rgba(0,0,0,0.15);
      overflow: hidden;
      flex-shrink: 0;
    }
    
    /* The "WOW" Fallback Letter */
    .leaderboard-fullscreen.show .hero-house-card .hero-emoji::before {
      content: attr(data-initial);
      position: absolute;
      font-size: 120px;
      font-weight: 900;
      color: var(--house-color);
      opacity: 0.9;
      text-shadow: 2px 2px 0px rgba(255,255,255,0.8);
      z-index: 1;
    }
    
    /* 1. Define the Reveal Animation */
    @keyframes logoReveal {
      0% { opacity: 0; }
      100% { opacity: 1; }
    }
    /* 2. Update the image style - FIXED to prevent cropping */
    .hero-emoji img.logo-house-card {
  width: 82% !important;
  height: 82% !important;
  object-fit: contain !important;
  object-position: center !important;
  position: relative;
  z-index: 2;
  display: block;
  background: transparent;
  border-radius: 0 !important;
  opacity: 0;
  animation: logoReveal 1s ease forwards;
  animation-delay: 2s;
}
    
    /* This closing brace was missing - add it here */
    
    
    .leaderboard-fullscreen.show .hero-house-card .hero-name {
  font-size: clamp(44px, 4.8vw, 80px);
  font-weight: 900;
  color: var(--house-display-color, var(--house-color, #1e293b));
  -webkit-text-stroke: 0.5px rgba(15, 23, 42, 0.24);
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.14);
}
    .leaderboard-fullscreen.show .hero-house-card .hero-motto {
      font-size: 23px;
      font-style: italic;
      color: #64748b;
    }
    .hero-points {
  font-size: clamp(64px, 7vw, 110px);
  font-weight: 800;
  color: var(--house-display-color, var(--house-color, #1e40af));
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 12px 20px;
  width: fit-content;
  max-width: 100%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  margin-top: 12px;

  -webkit-text-stroke: 0;
text-shadow:
  0 1px 1px rgba(15, 23, 42, 0.22),
  0 3px 7px rgba(15, 23, 42, 0.12);
}
    
    .hero-progress-fill {
      height: 100%;
      background: var(--house-color, #1e40af);
      transition: width 0.6s ease;
    }
    .hero-body {
      display: flex;
      flex-direction: column;
      gap: 24px;
    }
    .hero-section {
      background: var(--card-light);
      border-radius: var(--radius-md);
      padding: 16px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }
    .hero-section h4 {
  font-size: 32px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 12px;
}
    .hero-row {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 4px 10px; /* Reduced vertical padding from 10px to 4px */
      border-radius: 6px;
      background: rgba(255,255,255,0.85);
      margin-bottom: 4px; /* Reduced bottom margin from 8px to 4px */
    }
    
    /* Specifically target the students section to tighten the list */
    .hero-section .hero-row {
      min-height: 40px; /* Ensures a consistent but slim height */
    }
    
    /* Tighten the student rank number spacing */
    .hero-student-rank {
      font-weight: 800;
      width: 24px;
      font-size: 14px;
    }
    .hero-row.leader {
      background: linear-gradient(135deg, rgba(255,255,255,0.9), var(--house-color, #1e40af));
      font-weight: 700;
      padding: 12px; /* Slightly increased for larger text */
    }
    .hero-row.leader .hero-who {
      font-size: 20px; /* Increased to 30px for names, class, role */
      color: #1e293b;
      flex: 1;
    }
    .hero-pts {
      font-weight: 800;
      font-size: 18px;
      color: var(--dark-text);
    }
    .hero-row.leader .hero-pts {
      font-size: 25px;
      font-weight: 800;
      color: var(--dark-text);
    }
    
    .hero-who {
      flex: 1;
      font-size: 18px;
      color: #1e293b;
    }
    
    
    
    @media (max-height: 800px) {
      .leaderboard-fullscreen {
        padding: clamp(8px, 1.5vw, 16px); /* Reduced padding */
      }
      .hero-house-card {
        grid-template-columns: 1fr; /* Single column for smaller screens */
        padding: clamp(12px, 2vw, 16px); /* Reduced padding */
        font-size: 0.9rem; /* Slightly smaller font */
      }
      .hero-name {
        font-size: clamp(32px, 5vw, 48px); /* Scaled-down font */
      }
      .hero-points {
        font-size: clamp(48px, 8vw, 80px); /* Scaled-down points */
      }
      .hero-milestone-badge {
        font-size: clamp(16px, 2.5vw, 20px); /* Smaller badge */
        padding: clamp(6px, 1vw, 10px); /* Adjusted padding */
      }
      .hero-progress {
        height: clamp(20px, 3vw, 24px); /* Thinner progress bar */
        border-radius: clamp(10px, 1.5vw, 12px);
      }
      .hero-captain-banner {
        font-size: clamp(14px, 2vw, 16px); /* Smaller captain message */
        padding: clamp(8px, 1.5vw, 12px);
      }
    }
    
    
    @media (max-width: 1370px) {
      .leaderboard-fullscreen-header {
        padding: 12px 16px;
      }
      .leaderboard-announcement-bar .announcement-content {
        font-size: 14px;
      }
      .leaderboard-announcement-bar .announcement-icon {
        font-size: 16px;
      }
      .leaderboard-announcement-bar .announcement-content.scrolling #leaderboardAnnouncementText {
        animation: marquee 32s linear infinite;
      }
      .leaderboard-announcement-bar .announcement-title {
        font-size: 13px;
      }
      .hero-house-card {
        grid-template-columns: 1fr;
        padding: 16px;
      }
      .hero-name {
        font-size: 36px;
      }
    @media (max-width: 1370px) {
      .leaderboard-fullscreen-header {
        padding: 12px 16px;
      }
      .leaderboard-announcement-bar .announcement-content {
        font-size: 14px;
      }
      .leaderboard-announcement-bar .announcement-icon {
        font-size: 16px;
      }
      .leaderboard-announcement-bar .announcement-content.scrolling #leaderboardAnnouncementText {
        animation: marquee 32s linear infinite;
      }
      .leaderboard-announcement-bar .announcement-title {
        font-size: 13px;
      }
      .hero-house-card {
        grid-template-columns: 1fr;
        padding: 16px;
      }
      .hero-name {
        font-size: 36px;
      }
      .hero-points {
        font-size: 64px; /* Scaled down for mobile */
        color: var(--house-color, #1e40af); /* Maintain house color */
        background: rgba(255, 255, 255, 0.9); /* Consistent contrast */
      }
      .hero-emoji {
        width: 80px;
        height: 80px;
        font-size: 48px;
      }
    }
      /* Mobile: Smaller but still perfect circle */
      .leaderboard-fullscreen.show .hero-house-card .hero-emoji {
        width: 120px !important;
        height: 120px !important;
        min-width: 120px !important;
        min-height: 120px !important;
        border-width: 3px;
      }
    }
    @media (max-width: 480px) {
      .leaderboard-announcement-bar .announcement-content {
        font-size: 12px;
      }
      .leaderboard-announcement-bar .announcement-icon {
        font-size: 14px;
      }
      .leaderboard-announcement-bar .announcement-content.scrolling #leaderboardAnnouncementText {
        animation: marquee 24s linear infinite;
      }
      .leaderboard-announcement-bar .announcement-title {
        font-size: 11px;
      }
    }
    @media (max-width: 900px) {
      .leaderboard-fullscreen-split {
        grid-template-columns: 1fr; 
        height: auto;
      }
      .hero-house-card { min-height: 480px; }
    }
    
    .leaderboard-fullscreen-house-card {
      background: linear-gradient(145deg, #ffffff, #e6f0fa);
      border-radius: var(--radius-lg);
      padding: 16px;
      box-shadow: 0 12px 28px rgba(2, 6, 23, 0.12);
      width: 100%;
      margin-bottom: 16px;
      display: flex;
      flex-direction: row;
      align-items: center;
      gap: 24px;
      transition: transform 0.3s ease, opacity 0.3s ease;
      /* NEW: house color rail; falls back to primary if no inline color */
      border-left: 8px solid var(--houseColor, var(--primary-blue));
    }
    
    .leaderboard-fullscreen-house-card.hidden {
      opacity: 0;
      transform: translateY(20px);
    }
    .leaderboard-fullscreen-house-header {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 8px;
    }
    .leaderboard-fullscreen-house-emoji {
      font-size: 48px;
      width: 80px;
      height: 80px;
      background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(0, 0, 0, 0.1));
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: var(--shadow-sm);
      margin-right: 16px;
    }
    .leaderboard-fullscreen-house-name {
      font-size: 28px;
      font-weight: 800;
      color: var(--primary-blue);
      letter-spacing: 0.2px;
    }
    
    .leaderboard-fullscreen-house-motto {
      font-size: 16px;
      color: #64748b;
      font-style: italic;
    }
    
    .leaderboard-fullscreen-top-students {
      flex: 1;
      font-size: 14px;
      color: var(--dark-text);
    }
    .leaderboard-fullscreen-leaders {
      flex: 1;
      font-size: 14px;
      color: var(--dark-text);
    }
    .leaderboard-fullscreen-top-item {
      display: grid;
      grid-template-columns: 28px 1fr auto;
      align-items: center;
      gap: 10px;
      margin-bottom: 6px;
      padding: 8px;
      border-radius: var(--radius-sm);
      background: rgba(255, 255, 255, 0.85);
    }
    .leaderboard-fullscreen-top-item:nth-child(odd) {
      background: rgba(255, 255, 255, 0.6);
    }
    
    .leaderboard-fullscreen-top-rank {
      font-weight: 700;
      color: var(--primary-blue);
      width: 28px;
      text-align: center;
    }
    .leaderboard-fullscreen-top-name {
      flex: 1;
    }
    .leaderboard-fullscreen-top-points {
      font-weight: 600;
      color: var(--primary-blue);
    }
    @media (max-width: 1370px) {
      .leaderboard-fullscreen {
        padding: 10px 4px;
      }
      .leaderboard-fullscreen-stats {
        grid-template-columns: 1fr;
        gap: 6px;
      }
      .leaderboard-fullscreen-house-card {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px;
      }
      .leaderboard-fullscreen-house-emoji {
        font-size: 36px;
        width: 60px;
        height: 60px;
        margin-right: 12px;
      }
      .leaderboard-fullscreen-house-name {
        font-size: 22px;
      }
      .leaderboard-fullscreen-house-motto {
        font-size: 14px;
      }
      .leaderboard-fullscreen-top-students,
      .leaderboard-fullscreen-leaders {
        font-size: 13px;
      }
      .leaderboard-fullscreen-top-item {
        font-size: 12px;
      }
    }
    @media (min-width: 769px) and (max-width: 1024px) {
      .leaderboard-fullscreen-house-card {
        padding: 14px;
      }
      .leaderboard-fullscreen-house-name {
        font-size: 24px;
      }
    }
    @media (min-width: 1025px) {
      .leaderboard-fullscreen-house-card {
        padding: 16px;
      }
      .leaderboard-fullscreen-title {
        font-size: 15px;
      }
      .leaderboard-fullscreen-stats {
        gap: 12px;
      }
    }
    
    .leaderboard-tv-mode {
      display: none;
    }
    .leaderboard-tv-mode.show {
      display: block;
    }
    @media screen and (display-mode: tv-mode) {
      .leaderboard-fullscreen-header,
      .leaderboard-fullscreen-close,
      .leaderboard-fullscreen-tv-mode,
      .leaderboard-fullscreen-items {
        display: none !important;
      }
      .leaderboard-fullscreen {
        padding: 0;
        background: linear-gradient(135deg, #f1f5f9, #e0f2fe);
        height: 100vh;
        width: 100vw;
        overflow: hidden;
        display: flex;
        flex-direction: column;
      }
    .leaderboard-fullscreen-houses {
      margin: 0;
      padding: 10px;
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
      gap: 10px;
      flex: 1;
    }
      .leaderboard-fullscreen-house-card {
        border: 1px solid #ddd;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        padding: 8px;
        width: 100%;
        font-size: 12px;
        display: flex;
        flex-direction: row;
        gap: 12px;
      }
      .leaderboard-fullscreen-house-header {
        flex: 1;
        gap: 6px;
      }
      .leaderboard-fullscreen-house-emoji {
        font-size: 24px;
        width: 40px;
        height: 40px;
        background: #f0f0f0;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 8px;
      }
      .leaderboard-fullscreen-house-name {
        font-size: 16px;
        font-weight: 700;
        color: #1e40af;
      }
      .leaderboard-fullscreen-house-motto {
        font-size: 12px;
        color: #94a3b8;
        font-style: italic;
      }
      .leaderboard-fullscreen-top-students,
      .leaderboard-fullscreen-leaders {
        flex: 1;
        font-size: 12px;
      }
      .leaderboard-fullscreen-top-item {
        padding: 4px;
        margin-bottom: 4px;
        background: #f9fafb;
        border-radius: 4px;
      }
      .leaderboard-fullscreen-top-rank {
        width: 20px;
        font-size: 12px;
        text-align: center;
      }
      .leaderboard-fullscreen-top-name {
        flex: 1;
      }
      .leaderboard-fullscreen-top-points {
        font-size: 12px;
      }
      .print-header {
        text-align: center;
        font-size: 16px;
        font-weight: bold;
        margin-bottom: 10px;
        color: #1e40af;
      }
    }
    
    
    
    
    
    @media (max-width: 1024px) {
      .leaderboard-fullscreen-houses {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
      }
    }
    @media (max-width: 1370px) {
      .leaderboard-fullscreen-houses {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      }
    }
    @media (max-width: 480px) {
      .leaderboard-fullscreen-houses {
        grid-template-columns: 1fr;
      }
    }
    
    
    
    
    @media print {
      .leaderboard-fullscreen-header,
      .leaderboard-fullscreen-close,
      .leaderboard-fullscreen-tv-mode,
      .leaderboard-fullscreen-items {
        display: none !important;
      }
      .leaderboard-fullscreen {
        padding: 0;
        background: none;
        height: auto;
        overflow: visible;
      }
      .leaderboard-fullscreen-houses {
        margin: 0;
        padding: 5mm;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 5mm;
      }
      .leaderboard-fullscreen-house-card {
        page-break-inside: avoid;
        margin-bottom: 5mm;
        border: 1px solid #ddd;
        box-shadow: none;
        padding: 6px;
        width: 100%;
        font-size: 7pt;
        display: flex;
        flex-direction: row;
        gap: 8px;
      }
      .leaderboard-fullscreen-house-header {
        flex: 1;
        gap: 4px;
      }
      .leaderboard-fullscreen-house-emoji {
        font-size: 18pt;
        width: 30px;
        height: 30px;
        background: #f0f0f0;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 6px;
      }
      .leaderboard-fullscreen-house-name {
        font-size: 9pt;
        font-weight: 700;
        color: #1e40af;
      }
      .leaderboard-fullscreen-house-motto {
        font-size: 7pt;
        color: #94a3b8;
        font-style: italic;
      }
      .leaderboard-fullscreen-top-students,
      .leaderboard-fullscreen-leaders {
        flex: 1;
        font-size: 7pt;
      }
      .leaderboard-fullscreen-top-item {
        padding: 3px;
        margin-bottom: 3px;
        background: #f9fafb;
        border-radius: 3px;
      }
      .leaderboard-fullscreen-top-rank {
        width: 15px;
        font-size: 7pt;
        text-align: center;
      }
      .leaderboard-fullscreen-top-name {
        flex: 1;
      }
      .leaderboard-fullscreen-top-points {
        font-size: 7pt;
      }
      .print-header {
        text-align: center;
        font-size: 10pt;
        font-weight: bold;
        margin-bottom: 5mm;
      }
      @page {
        size: A4 landscape;
        margin: 5mm;
      }
    }
    .table-container {
      background: var(--card-light);
      border-radius: var(--radius-lg);
      box-shadow: var(--shadow-sm);
      position: relative; /* Ensure tooltips can escape container */
    }
    .table-responsive {
      overflow-x: auto;
      position: relative; /* Ensure tooltips can escape */
    }
    
        table {
          width: 100%;
          border-collapse: collapse;
        }
    
        th {
          background: var(--light);
          padding: 10px 14px;
          text-align: left;
          font-weight: 600;
          color: var(--primary-blue);
          border-bottom: 1px solid var(--gray-light);
          white-space: nowrap;
        }
    
        td {
          padding: 10px 14px;
          border-bottom: 1px solid var(--gray-light);
          vertical-align: middle;
          white-space: nowrap; /* Keeps roles on one line */
        }
    
        tr:last-child td {
          border-bottom: none;
        }
    
        tr:hover td {
          background: rgba(30, 58, 138, 0.05);
        }
    
        .form-group {
          position: relative;
          margin-bottom: 14px;
        }
    
        .form-group-row {
          display: flex;
          gap: 12px;
          flex-wrap: wrap;
        }
    
        .form-group-row .form-group {
          flex: 1;
          min-width: 180px;
        }
    
        .form-label {
          display: block;
          margin-bottom: 6px;
          font-weight: 600;
          font-size: 13px;
          color: var(--dark-text);
        }
    
        .form-control {
          width: 100%;
          padding: 8px 10px;
          border: 1px solid var(--gray-light);
          border-radius: var(--radius-sm);
          font-family: inherit;
          font-size: 13px;
          background-color: var(--bg-light);
          transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }
    
        .form-control:focus {
          outline: none;
          border-color: var(--primary-blue);
          box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.25);
        }
    
        select.form-control {
          appearance: none;
          background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
          background-repeat: no-repeat;
          background-position: right 8px center;
          background-size: 14px;
          padding-right: 28px;
        }
    
       
    .toggle-panel {
      display: none;
      transition: opacity 0.3s ease 0.1s, max-height 0.3s ease 0.1s;
      opacity: 0;
      max-height: 0;
      overflow: hidden;
    }
    
    
    /* THE FIX: Increased max-height to 1200px to fit the tall Custom Poster form */
  .toggle-panel.active,
  .toggle-panel[style*="display: block"] {
    display: block;
    opacity: 1;
    max-height: 1200px; 
    overflow: visible; /* Ensures buttons and tooltips aren't clipped */
  }
    
    .announcements-config-panel {
      display: none;
      transition: opacity 0.3s ease 0.1s, max-height 0.3s ease 0.1s;
      opacity: 0;
      max-height: 0;
      overflow: hidden;
      width: 100%;
      box-sizing: border-box;
    }
    
    .announcements-config-panel.active,
    .announcements-config-panel[style*="display: block"] {
      display: block;
      opacity: 1;
      max-height: 2000px; /* Large enough for many announcements */
      width: 100%;
      box-sizing: border-box;
    }
        
    
        .house-config-item {
          display: flex;
          align-items: center;
          gap: 10px;
          margin-bottom: 10px;
          padding: 10px;
          background: var(--card-light);
          border-radius: var(--radius-sm);
          box-shadow: var(--shadow-sm);
        }
    
        .house-config-emoji {
          font-size: 22px;
          width: 45px;
          text-align: center;
        }
    
        .house-config-name {
          flex: 1;
        }
    
        @keyframes fadeIn {
          from { opacity: 0; transform: translateY(8px); }
          to { opacity: 1; transform: translateY(0); }
        }
    
        .animate-fade {
          animation: fadeIn 0.3s ease-out forwards;
        }
    
    
    
    
        .btn-class-setup {
      background: var(--class-setup);
      color: var(--light-text);
      border: 1px solid var(--class-setup);
    }
    
    .btn-class-setup:hover {
      background: #6D28D9; /* Slightly darker purple for hover */
      transform: translateY(-1px);
      box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
    }
    
    
    .mobile-menu-item {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 8px 12px;
      background: var(--class-setup);
      color: var(--light-text);
      border: 1px solid var(--class-setup);
      border-radius: 5px;
      font-size: 0.9rem;
      font-weight: 500;
      text-decoration: none;
      transition: all 0.2s ease;
    }
    
    .mobile-menu-item:hover {
      background: #6D28D9; /* Slightly darker purple */
      transform: translateY(-1px);
      box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
    }
    
    .mobile-menu-item i {
      font-size: 1rem;
    }
    
    
    
    .toast-central {
  background: var(--card-light);
  color: var(--dark-text);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideIn 0.2s ease;
  pointer-events: auto;
  border-left: 4px solid var(--primary-blue);
}
    
    /* Modern Border-only Status indicators */
    .toast-central.success { border-left-color: var(--success); }
    .toast-central.error   { border-left-color: var(--danger); }
    .toast-central.warning { border-left-color: var(--warning); }
    .toast-central.info    { border-left-color: var(--primary-blue); }
    
    /* Fixed Emoji Picker for Mobile (Smartphones Only) */
    @media (max-width: 780px) {
      #emojiPickerContainer {
        position: fixed !important;
        top: auto !important; /* Overrides the JS inline 'top' coordinate */
        bottom: 20px !important; /* Docks neatly near the bottom */
        left: 50% !important; /* Overrides the JS inline 'left' coordinate */
        transform: translateX(-50%) !important; /* Perfect horizontal center */
        width: 95vw !important;
        max-width: 400px !important;
        z-index: 60000 !important; /* Ensures it stays above all modals */
        border-radius: 12px !important;
        box-shadow: 0 10px 40px rgba(0,0,0,0.3) !important;
      }
      
      #emojiPickerContainer emoji-picker {
        width: 100% !important;
        height: 350px !important;
        margin: 0 !important;
      }
    }
    
    
    .toast-central .close-toast {
      cursor: pointer;
      font-size: 14px;
      margin-left: 10px;
      color: inherit;
      opacity: 0.7;
    }
    
    .toast-central .close-toast:hover {
      opacity: 1;
    }
    
    @keyframes slideIn {
      from { opacity: 0; transform: translateY(-10px); }
      to { opacity: 1; transform: translateY(0); }
    }
    
    
    
    
        .toast {
          position: fixed;
          bottom: 20px;
          left: 50%;
          transform: translateX(-50%);
          padding: 10px 20px;
          border-radius: var(--radius-md);
          background-color: var(--primary-blue);
          color: var(--light-text);
          font-weight: 500;
          box-shadow: var(--shadow-lg);
          z-index: 1000;
          display: flex;
          align-items: center;
          gap: 6px;
          opacity: 0;
          transition: opacity 0.3s ease;
        }
    
        .toast.show {
          opacity: 1;
        }
    
        .toast.success {
          background-color: var(--success);
        }
    
        .toast.error {
          background-color: var(--danger);
        }
    
        .toast.warning {
          background-color: var(--warning);
        }
    
    .tooltip {
      position: relative;
      display: inline-block;
    }
    .tooltip .tooltiptext {
      visibility: hidden;
      width: 180px;
      background-color: var(--dark-text);
      color: var(--light-text);
      text-align: center;
      border-radius: 6px;
      padding: 6px;
      position: absolute;
      z-index: 2000; /* Higher than table-container and other elements */
      top: -40px; /* Position above the header */
      left: 50%;
      margin-left: -90px;
      opacity: 0;
      transition: opacity 0.3s;
      font-size: 11px;
      pointer-events: none; /* Prevent tooltip from blocking interactions */
    }
    .tooltip:hover .tooltiptext {
      visibility: visible;
      opacity: 1;
    }
    
        .category-group {
          margin-bottom: 10px;
        }
    
        .category-title {
          font-size: 12px;
          font-weight: 600;
          color: var(--primary-blue);
          padding: 8px 12px;
          cursor: pointer;
          display: flex;
          align-items: center;
          gap: 6px;
          border-radius: var(--radius-sm);
          background: var(--gray-light);
          transition: var(--transition);
        }
    
        .category-title:hover {
          background: rgba(30, 58, 138, 0.15);
        }
    
        .category-content {
          display: none;
          padding: 8px 0;
        }
    
        .category-content.show {
          display: block;
        }
    
    /* The new whole-school onboarding replaces the House-only admin guide. */
    #pilotSetupDashboardCard {
      display: none !important;
    }

    /* No House activities until real Houses exist. */
    body.trackedu-no-houses #dashboardStartChallengeBtn,
    body.trackedu-no-houses #dashboardAnnouncementAssemblyBtn {
      display: none !important;
    }

    /* Hide Assembly Mode on mobile phones only. */
    @media (max-width: 780px) {
      #dashboardAnnouncementAssemblyBtn {
        display: none !important;
      }
    }

    /* Staff Directory teacher access: administrators only */
    body:not(.trackedu-license-admin) #staffDirectoryTeacherAccessBtn {
      display: none !important;
    }

    /* Compact Staff Directory header button on iPad and mobile */
    @media (max-width: 1370px) {
      #staffDirectoryTeacherAccessBtn {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        font-size: 13px !important;
      }

      #staffDirectoryTeacherAccessBtn .staff-directory-teacher-access-label {
        display: none !important;
      }
    }

    /* Simple teacher settings sections */
    #systemSetupModal #joinCodeCard {
      padding: 16px !important;
      background: #ffffff !important;
    }

    #systemSetupModal .ted-teacher-group {
      min-width: 0;
      margin-bottom: 12px;
      background: #ffffff;
      border: 1px solid #e2e8f0;
      border-radius: 14px;
      overflow: hidden;
    }

    #systemSetupModal .ted-teacher-group:last-child {
      margin-bottom: 0;
    }

    #systemSetupModal .ted-teacher-group > summary {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      min-height: 70px;
      padding: 15px 18px;
      list-style: none;
      cursor: pointer;
      color: #0f172a;
      background: #ffffff;
    }

    #systemSetupModal .ted-teacher-group > summary::-webkit-details-marker {
      display: none;
    }

    #systemSetupModal .ted-teacher-group > summary:focus-visible {
      outline: 2px solid #2563eb;
      outline-offset: -3px;
    }

    #systemSetupModal .ted-teacher-group-heading {
      display: flex;
      align-items: center;
      gap: 12px;
      min-width: 0;
    }

    #systemSetupModal .ted-teacher-group-heading > i {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 38px;
      height: 38px;
      flex: 0 0 38px;
      border-radius: 10px;
      background: #eff6ff;
      color: #2563eb;
      font-size: 15px;
    }

    #systemSetupModal .ted-teacher-group-heading strong {
      display: block;
      font-size: 15px;
      line-height: 1.35;
      font-weight: 800;
      color: #0f172a;
    }

    #systemSetupModal .ted-teacher-group-heading small {
      display: block;
      margin-top: 3px;
      font-size: 11px;
      line-height: 1.45;
      font-weight: 400;
      color: #64748b;
    }

    #systemSetupModal .ted-teacher-group-end {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-shrink: 0;
      color: #64748b;
      font-size: 12px;
    }

    #systemSetupModal .ted-teacher-group-end > i {
      transition: transform .18s ease;
    }

    #systemSetupModal .ted-teacher-group[open]
    .ted-teacher-group-end > i {
      transform: rotate(180deg);
    }

    #systemSetupModal .ted-teacher-summary-count:not(:empty) {
      padding: 4px 9px;
      border-radius: 999px;
      background: #f1f5f9;
      color: #475569;
      font-size: 11px;
      font-weight: 750;
    }

    #systemSetupModal .ted-teacher-group-content {
      min-width: 0;
      padding: 16px 18px 20px;
      border-top: 1px solid #e2e8f0;
    }

    #systemSetupModal #tedTeacherListGroup
    #approvedTeachersCard,
    #systemSetupModal #tedTeacherListGroup
    #sameDomainTeachersCard,
    #systemSetupModal #tedTeacherWaitingGroup
    #pendingApprovalsCard {
      margin: 0 0 12px !important;
      background: #f8fafc !important;
      border: 1px solid #e2e8f0 !important;
      border-radius: 12px !important;
      padding: 16px !important;
    }

    #systemSetupModal #tedTeacherListGroup
    #sameDomainTeachersCard {
      margin-bottom: 0 !important;
    }

    #systemSetupModal #tedTeacherSettingsGroup
    #teacherStudentManagementPermissionPanel {
      margin: 12px 0 0 !important;
    }

    #systemSetupModal #tedTeacherInviteGroup
    #teacherAccessOnboardingPanel[style*="display: block"] {
      display: block !important;
      padding: 16px !important;
    }

    #systemSetupModal #joinCodeCard
    #teacherAccessOnboardingPanel > div:first-child {
      display: block !important;
      height: auto !important;
      grid-column: auto !important;
      grid-row: auto !important;
      border-right: none !important;
      padding-right: 0 !important;
    }

    #systemSetupModal #joinCodeCard
    #teacherAccessOnboardingPanel
    .ted-teacher-csv-content > div {
      max-width: 100%;
      min-width: 0;
    }

    #systemSetupModal #tedTeacherSettingsGroup
    #teacherStudentManagementPermissionPanel > div,
    #systemSetupModal #tedTeacherSettingsGroup
    #teacherAutoApprovalToggle {
      min-width: 0;
    }

    @media (max-width: 1370px) {
      #systemSetupModal .ted-teacher-group-content {
        padding: 14px;
      }

      #systemSetupModal .ted-teacher-group > summary {
        padding: 13px 14px;
        min-height: 64px;
      }

      #systemSetupModal #teacherJoinCodeActions {
        width: 100%;
        flex-wrap: wrap;
      }

      #systemSetupModal #teacherJoinCodeActions button {
        white-space: normal !important;
        min-height: 42px;
      }
    }

    @media (max-width: 600px) {
      #systemSetupModal #joinCodeCard {
        padding: 10px !important;
      }

      #systemSetupModal .ted-teacher-group-heading strong {
        font-size: 13px;
      }

      #systemSetupModal .ted-teacher-group-heading small {
        font-size: 10px;
      }

      #systemSetupModal .ted-teacher-group-content {
        padding: 12px;
      }

      #systemSetupModal #tedTeacherListGroup
      #approvedTeachersCard,
      #systemSetupModal #tedTeacherListGroup
      #sameDomainTeachersCard,
      #systemSetupModal #tedTeacherWaitingGroup
      #pendingApprovalsCard {
        padding: 12px !important;
      }

      #systemSetupModal #teacherJoinCodeActions button {
        width: 100% !important;
      }
    }

    /* Teacher Join Code: compact horizontal actions on desktop */
    @media (min-width: 1371px) {
      #teacherJoinCodeActions {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 10px !important;
        min-width: 0 !important;
        flex: 0 1 auto;
      }

      #teacherJoinCodeActions button {
        width: auto !important;
        min-height: 42px !important;
        padding: 10px 15px !important;
        border-radius: 10px !important;
        font-size: 12px !important;
        font-weight: 800 !important;
        white-space: nowrap !important;
        box-shadow: none !important;
      }

      #copyTeacherInvitationBtn {
        background: #2563eb !important;
        color: #ffffff !important;
        border: 1px solid #1d4ed8 !important;
        order: 1;
      }

      #reviewPendingTeacherRequestsBtn {
        background: #ffffff !important;
        color: #334155 !important;
        border: 1px solid #cbd5e1 !important;
        order: 2;
      }

      #regenerateJoinCodeBtn {
        background: #fff7ed !important;
        color: #9a3412 !important;
        border: 1px solid #fed7aa !important;
        order: 3;
      }

      #teacherJoinCodeActions button:hover {
        filter: brightness(0.97);
      }
    }

    /* Licence and upgrade controls have the same permissions as House Settings. */
    body:not(.trackedu-license-admin) #headerLicenseWidget,
    body:not(.trackedu-license-admin) #mobileLicenseWidget,
    body:not(.trackedu-license-admin) #sidebarLicenseWidget,
    body:not(.trackedu-license-admin) #smartMenuLicenseContainer,
    body:not(.trackedu-license-admin) #smartMenuUpgradeBtn {
      display: none !important;
    }

    /* Sample-school removal is a school administration action. */
    body:not(.trackedu-license-admin) #tedSampleStatusChip,
    body:not(.trackedu-license-admin) #dashboardSchoolStartingPoints {
      display: none !important;
    }

      /* Shared, read-only value discovery for admin and teacher onboarding. */
      .ted-discover { margin:0; padding:20px; border:1px solid #c7d2fe;
        border-radius:15px; background:linear-gradient(120deg,#eff6ff,#f5f3ff); color:#0f172a; }
      .ted-discover-head { display:flex; align-items:flex-start; justify-content:space-between;
        flex-wrap:wrap; gap:10px; margin-bottom:18px; }
      .ted-discover-kicker { font-size:12px; font-weight:850; color:#4338ca; letter-spacing:.08em; }
      .ted-discover-title { font-size:24px; font-weight:850; line-height:1.3; margin:5px 0 8px; color:#0f172a; }
      .ted-discover-sub { font-size:15px; color:#475569; line-height:1.6; }
      .ted-discover-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
      .ted-discover-card { display:flex; align-items:flex-start; gap:14px; padding:18px;
        background:#fff; border:1px solid #dbe3f0; border-radius:12px;
        font:inherit; color:#0f172a; text-align:left; cursor:pointer; min-width:0; }
      .ted-discover-card:hover { border-color:#6366f1; box-shadow:0 3px 10px #312e8120; }
      .ted-discover-card:focus-visible { outline:3px solid #6366f1; outline-offset:2px; }
      .ted-discover-card i { color:#4f46e5; font-size:23px; margin-top:2px; flex:none; }
      .ted-discover-card strong { display:block; font-size:16px; line-height:1.4; }
      .ted-discover-card small { display:block; margin-top:5px; font-size:14px;
        line-height:1.5; color:#64748b; }
      .ted-discover-note { margin-top:14px; color:#64748b; font-size:12px; line-height:1.5; }
      .te-help-explore-button { width:100%; margin:12px 0 15px; }
      body.house-display-dark .ted-discover { background:#172337; border-color:#475569; }
      body.house-display-dark .ted-discover-title { color:#f8fafc; }
      body.house-display-dark .ted-discover-sub, body.house-display-dark .ted-discover-note { color:#cbd5e1; }
      body.house-display-dark .ted-discover-card { background:#1e293b; color:#f8fafc; border-color:#475569; }
      body.house-display-dark .ted-discover-card small { color:#cbd5e1; }
      @media(max-width:900px) { .ted-discover-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
      @media(max-width:520px) { .ted-discover { padding:12px; }
        .ted-discover-grid { grid-template-columns:1fr; }
        .ted-discover-card { padding:9px 10px; } }

      /* Native, accessible showcase dialog. Isolated from existing app modals. */
      dialog.ted-demo-dialog { position:fixed; inset:0; margin:auto; padding:0; border:0;
        border-radius:18px; width:min(900px,94vw); max-width:94vw; max-height:92dvh;
        background:#f8fafc; color:#0f172a; box-shadow:0 25px 80px #0f172a55; }
      dialog.ted-demo-dialog::backdrop { background:#0f172ac2; }
      .ted-demo-head { display:flex; align-items:center; justify-content:space-between; gap:12px;
        padding:17px 20px; background:#172554; color:white; }
      .ted-demo-head strong { font-size:17px; } .ted-demo-head span { display:block; font-size:11px; color:#c7d2fe; }
      .ted-demo-close { flex:none; border:1px solid #ffffff55; border-radius:8px;
        background:#ffffff20; color:#fff; font-size:18px; width:34px; height:34px; cursor:pointer; }
      .ted-demo-content { padding:18px; max-height:calc(92dvh - 145px); overflow-y:auto; }
      .ted-demo-sheet { max-width:750px; margin:0 auto; background:#fff; border:1px solid #cbd5e1;
        border-radius:12px; padding:27px; color:#0f172a; font-family:Arial,sans-serif; }
      .ted-demo-sheet h2 { font-size:25px; line-height:1.2; margin:0 0 5px; color:#172554; }
      .ted-demo-sheet p { font-size:12px; color:#475569; margin:6px 0 14px; }
      .ted-demo-tag { display:inline-block; font-size:10px; font-weight:800; letter-spacing:.07em;
        padding:5px 9px; border-radius:999px; background:#fef3c7; color:#92400e; margin-bottom:14px; }
      .ted-demo-metrics { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; margin:15px 0; }
      .ted-demo-metric { border:1px solid #e2e8f0; border-radius:10px; padding:13px; background:#f8fafc; }
      .ted-demo-metric strong { display:block; font-size:23px; color:#1e40af; }
      .ted-demo-metric span { font-size:11px; color:#475569; }
      .ted-demo-sheet h3 { color:#172554; font-size:15px; margin:19px 0 8px; }
      .ted-demo-line { padding:9px 0; border-bottom:1px solid #e2e8f0; font-size:12px; }
      .ted-demo-line strong { color:#0f172a; }
      .ted-demo-bar { height:9px; border-radius:99px; background:#e2e8f0; overflow:hidden; margin-top:5px; }
      .ted-demo-bar b { display:block; height:100%; background:#4f46e5; border-radius:99px; }
      .ted-demo-footer { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap;
        gap:9px; padding:12px 20px; background:#fff; border-top:1px solid #e2e8f0; }
      .ted-demo-footer small { color:#64748b; font-size:10px; }
      .ted-demo-footer div { display:flex; flex-wrap:wrap; gap:7px; }
      .ted-demo-footer button { font:700 12px Arial,sans-serif; padding:9px 12px; border-radius:9px;
        border:1px solid #cbd5e1; color:#1e40af; background:#eff6ff; cursor:pointer; }
      .ted-demo-footer button.ted-demo-primary { background:#1e40af; color:#fff; border-color:#1e40af; }
      .ted-demo-footer button:disabled { opacity:.5; cursor:wait; }
      dialog.ted-demo-dialog .ted-discover { margin:0; }
      @media(max-width:520px) { .ted-demo-sheet { padding:15px; }
        .ted-demo-metrics { grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
        .ted-demo-metric { padding:8px; } .ted-demo-metric strong { font-size:17px; }
        .ted-demo-content { padding:10px; } .ted-demo-footer { padding:10px; } }

      /* Remember which onboarding tools each user has explored. */
      #dashboardSchoolStartingPoints .ted-explore-muted,
      #teacherGettingStartedCard .ted-explore-muted {
        opacity: 0.75;
      }

      #dashboardSchoolStartingPoints .ted-explore-visited,
      #teacherGettingStartedCard .ted-explore-visited {
        position: relative;
        opacity: 1;
      }

      #dashboardSchoolStartingPoints .ted-explore-visited::after,
      #teacherGettingStartedCard .ted-explore-visited::after {
        content: "✓";
        position: absolute;
        top: 7px;
        right: 9px;
        display: grid;
        place-items: center;
        width: 19px;
        height: 19px;
        border-radius: 50%;
        background: #16a34a;
        color: #ffffff;
        font-size: 12px;
        font-weight: 800;
      }

      /* Teacher First Value: isolated from administrator onboarding. */
    #teacherGettingStartedCard.teacher-first-value,
    body.house-display-dark #teacherGettingStartedCard.teacher-first-value {
      margin:0 0 12px;
      padding:16px 18px;
      border:1px solid #334c94;
      border-radius:14px;
      background:#172554;
      color:#ffffff;
      box-shadow:0 2px 10px rgba(15,23,42,.08);
    }

    /* White welcome heading. */
    #teacherGettingStartedCard.teacher-first-value h3 {
      color:#ffffff!important;
    }

    /* White feature cards in both display modes. */
    #teacherGettingStartedCard .teacher-first-value-options button,
    body.house-display-dark #teacherGettingStartedCard .teacher-first-value-options button {
      background:#ffffff;
      border-color:#cbd5e1;
      color:#0f172a;
    }

    #teacherGettingStartedCard .teacher-first-value-options button strong,
    body.house-display-dark #teacherGettingStartedCard .teacher-first-value-options button strong {
      color:#0f172a;
    }

    #teacherGettingStartedCard .teacher-first-value-options button span,
    body.house-display-dark #teacherGettingStartedCard .teacher-first-value-options button span {
      color:#64748b;
    }

    #teacherGettingStartedCard .teacher-first-value-options button i {
      color:#2563eb;
    }

    /* Keep the header actions readable. */
    #teacherGettingStartedCard .teacher-first-value-title-actions button:not(#teacherFirstValueFinishButton),
    body.house-display-dark #teacherGettingStartedCard .teacher-first-value-title-actions button:not(#teacherFirstValueFinishButton) {
      background:#312e81;
      border-color:#818cf8;
      color:#ffffff;
    }

    #teacherGettingStartedCard #teacherFirstValueFinishButton {
      background:#dbeafe;
      border-color:#93c5fd;
      color:#1d4ed8;
    }
    .teacher-first-value h3 {font-size:17px; margin:8px 0 4px; color:inherit}
    .teacher-first-value p {font-size:12px; color:#64748b; margin:0 0 12px}
    .teacher-first-value-head,.teacher-first-value-footer {display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap}
    .teacher-first-value-head,.teacher-first-value-footer {color:#64748b;font-size:11px}
    .teacher-first-value-options {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
    .teacher-first-value-options button {
      display:flex;
      flex-direction:column;
      align-items:flex-start;
      justify-content:center;
      gap:2px;
      min-height:58px;
      padding:8px 12px;
      text-align:left;
      background:#f8fafc;
      border:1px solid #dbe4f0;
      border-radius:10px;
      color:inherit;
      font-family:inherit;
      cursor:pointer;
    }

    #teacherGettingStartedCard .teacher-first-value-options button i {
      font-size:13px;
    }

    #teacherGettingStartedCard .teacher-first-value-options button strong {
      font-size:14px;
      line-height:1.3;
    }

    #teacherGettingStartedCard .teacher-first-value-options button span {
      font-size:12px;
      line-height:1.35;
    }
    .teacher-first-value-options button strong {font-size:12px}
    .teacher-first-value-options button span {font-size:11px;color:#64748b}
    .teacher-first-value-options button i {color:#2563eb}
    .teacher-first-value-options button:disabled {opacity:.45;cursor:not-allowed}
    .teacher-first-value-more {display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
    .teacher-first-value-more[hidden],.teacher-first-value-result[hidden],.teacher-first-value-more button[hidden] {display:none!important}
    .teacher-first-value-more button,.teacher-first-value-footer button,.teacher-first-value-result button {padding:8px 11px;border:1px solid #cbd5e1;border-radius:8px;background:#fff;color:#334155;font-family:inherit;font-size:11px;font-weight:650;cursor:pointer}
    .teacher-first-value-result {margin-bottom:12px;padding:10px;background:#ecfdf5;border:1px solid #bbf7d0;border-radius:10px;color:#166534;font-size:11px}
    .teacher-first-value-result button {margin-left:8px;background:transparent;color:inherit;border:0}
    .teacher-first-value-footer {margin-top:12px}

    .teacher-first-value-title-row {
      display:flex;
      align-items:center;
      justify-content:space-between;
      flex-wrap:wrap;
      gap:10px;
      margin-bottom:6px;
    }

    .teacher-first-value-title-row h3 {
      margin:0;
    }

    .teacher-first-value-title-actions {
      display:flex;
      align-items:center;
      justify-content:flex-end;
      flex-wrap:wrap;
      gap:8px;
      margin-left:auto;
    }

    .teacher-first-value-title-actions button {
      padding:8px 12px;
      min-height:36px;
      border:1px solid #cbd5e1;
      border-radius:8px;
      background:#ffffff;
      color:#334155;
      font-family:inherit;
      font-size:11px;
      font-weight:700;
      cursor:pointer;
    }

    #teacherFirstValueFinishButton {
      background:#2563eb;
      color:#ffffff;
      border-color:#2563eb;
    }

    body.house-display-dark .teacher-first-value-title-actions button:not(#teacherFirstValueFinishButton) {
      background:#1e293b;
      color:#f8fafc;
      border-color:#475569;
    }

    @media (max-width:720px) {
      .teacher-first-value-title-actions {
        width:100%;
        justify-content:flex-start;
        margin-left:0;
      }
    }
    #teacherFirstValueFinishButton {background:#2563eb;color:#fff;border-color:#2563eb}
    .teacher-first-value button:focus-visible {outline:2px solid #2563eb;outline-offset:2px}
    @media(max-width:720px) {.teacher-first-value-options {grid-template-columns:1fr}.teacher-first-value-options button {min-height:65px}}
    body.house-display-dark #teacherGettingStartedCard {background:#14243b;color:#f8fafc;border-color:#3b82f6}
    body.house-display-dark .teacher-first-value p,body.house-display-dark .teacher-first-value-head,body.house-display-dark .teacher-first-value-footer {color:#cbd5e1}
    body.house-display-dark .teacher-first-value-options button,body.house-display-dark .teacher-first-value-more button,body.house-display-dark .teacher-first-value-footer button:not(#teacherFirstValueFinishButton) {background:#1e293b;color:#f8fafc;border-color:#475569}
    body.house-display-dark .teacher-first-value-options button span {color:#cbd5e1}
    body.house-display-dark .teacher-first-value-result {background:#123e30;color:#bbf7d0;border-color:#166534}

    /* Whole-school onboarding: compact, responsive and dark-mode safe. */
    #dashboardSchoolStartingPoints {
      width:100%;
      min-width:0;
      margin:0 0 12px!important;
      padding:15px 18px!important;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-top {
      display:flex;
      align-items:center;
      justify-content:space-between;
      flex-wrap:wrap;
      gap:8px 16px;
      font-size:11px;
      font-weight:800;
      letter-spacing:.05em;
      color:#64748b;
      margin-bottom:4px;
    }

    #dashboardSchoolStartingPoints .ted-onboarding-top > strong {
      flex-shrink:0;
    }

    #dashboardSchoolStartingPoints .ted-demo-inline-welcome {
      flex:1 1 320px;
      min-width:0;
      margin:0!important;
      font-size:12px!important;
      font-weight:400;
      line-height:1.4!important;
      letter-spacing:normal;
    }

    #dashboardSchoolStartingPoints .ted-demo-more-button {
      flex-shrink:0;
      margin-left:auto;
    }
    #dashboardSchoolStartingPoints h3 {
      margin:0 0 5px;
      font-size:17px;
      line-height:1.35;
      color:#0f172a;
    }
    #dashboardSchoolStartingPoints h2.ted-onboarding-big {
      margin:6px 0;
      font-size:clamp(18px,2vw,27px);
      line-height:1.2;
      font-weight:900;
      color:#0f172a;
    }
    #dashboardSchoolStartingPoints h3.ted-onboarding-hook {
      font-size:15px;
      font-weight:750;
    }
    #dashboardSchoolStartingPoints p {
      margin:6px 0;
      font-size:14px;
      line-height:1.55;
      color:#475569;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-cards {
      display:grid;
      grid-template-columns:repeat(4,minmax(0,1fr));
      gap:10px;
      margin:14px 0 10px;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-action {
      display:flex;
      flex-direction:column;
      align-items:flex-start;
      gap:5px;
      min-height:110px;
      padding:14px;
      text-align:left;
      background:#fff;
      color:#0f172a;
      border:1px solid #cbd5e1;
      border-radius:12px;
      cursor:pointer;
      font:inherit;
      transition:border-color .15s,box-shadow .15s,transform .15s;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-action:hover,
    #dashboardSchoolStartingPoints .ted-onboarding-action:focus-visible {
      border-color:#2563eb;
      box-shadow:0 3px 12px rgba(37,99,235,.12);
      transform:translateY(-1px);
      outline:2px solid transparent;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-action i {
      color:#2563eb;
      font-size:19px;
      margin-bottom:3px;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-action strong {
      font-size:14px;
      line-height:1.3;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-action span {
      color:#64748b;
      font-size:12px;
      line-height:1.4;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-actions {
      display:flex;
      justify-content:space-between;
      align-items:center;
      gap:10px;
      flex-wrap:wrap;
      margin-top:12px;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-actions button {
      min-height:40px;
      white-space:normal;
      padding:9px 14px;
      font-size:13px;
    }

    #dashboardSchoolStartingPoints .ted-onboarding-actions button i {
      color:inherit;
    }

    /* New school setup: keep both actions together. */
    #dashboardSchoolStartingPoints .ted-school-setup-actions {
      justify-content:flex-start;
      gap:10px;
    }

    #dashboardSchoolStartingPoints .ted-school-setup-actions button {
      min-height:42px;
      padding:10px 15px;
      border-radius:9px;
      font-size:13px;
      font-weight:750;
    }

    /* Hide empty dashboard panels after demo removal. */
    body.ted-empty-school-setup #tedWeeklyRecognitionSummary,
    body.ted-empty-school-setup #dashboard-section .card:has(#leaderboardBars),
    body.ted-empty-school-setup #dashboard-section .card:has(#houseOverview) {
      display:none!important;
    }
    body.house-display-dark #dashboardSchoolStartingPoints .ted-onboarding-action {
      background:#1e293b;
      color:#f8fafc;
      border-color:#475569;
    }
    body.house-display-dark #dashboardSchoolStartingPoints .ted-onboarding-action span {
      color:#cbd5e1;
    }
    /* Recommended first onboarding action */
    #dashboardSchoolStartingPoints .ted-onboarding-action--primary {
      position:relative;
      background:#eff6ff;
      border-color:#2563eb;
      padding-top:35px;
    }

    #dashboardSchoolStartingPoints .ted-onboarding-start {
      position:absolute;
      top:10px;
      right:11px;
      display:inline-block;
      padding:3px 7px;
      border-radius:5px;
      background:#dbeafe;
      color:#1d4ed8;
      font-size:10px;
      font-weight:800;
      letter-spacing:.04em;
      line-height:1.25;
    }

    body.house-display-dark #dashboardSchoolStartingPoints .ted-onboarding-action--primary {
      background:#172f4e!important;
      border-color:#60a5fa!important;
    }

    body.house-display-dark #dashboardSchoolStartingPoints .ted-onboarding-start {
      background:#1e40af;
      color:#eff6ff;
    }

    #dashboardSchoolStartingPoints .ted-sample-report-link {
      display:inline-flex;
      align-items:center;
      gap:6px;
      margin-left:12px;
      padding:6px 10px;
      min-height:32px;
      border:1px solid #93c5fd;
      border-radius:8px;
      background:#eff6ff;
      color:#1d4ed8;
      font-family:inherit;
      font-size:12px;
      font-weight:700;
      cursor:pointer;
      letter-spacing:normal;
    }

    #dashboardSchoolStartingPoints .ted-sample-report-link:hover,
    #dashboardSchoolStartingPoints .ted-sample-report-link:focus-visible {
      background:#dbeafe;
      border-color:#2563eb;
    }

    body.house-display-dark #dashboardSchoolStartingPoints .ted-sample-report-link {
      color:#bfdbfe;
      background:#1e3a5f;
      border-color:#60a5fa;
    }

    /* Real-school activation begins when genuine students are present. */
    #dashboardSchoolStartingPoints.ted-onboarding-real {
      background:#eff6ff!important;
      border-color:#bfdbfe!important;
    }
    #dashboardSchoolStartingPoints .ted-real-onboarding-grid {
      grid-template-columns:repeat(3,minmax(0,1fr));
      margin-top:10px;
    }
    #dashboardSchoolStartingPoints.ted-onboarding-real .ted-onboarding-actions {
      padding-top:8px;
      border-top:1px solid #bfdbfe;
    }
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-real {
      background:#14243b!important;
      border-color:#3b82f6!important;
    }
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-real .ted-onboarding-actions {
      border-color:#334155;
    }
    @media (max-width:900px) {
      #dashboardSchoolStartingPoints .ted-onboarding-cards.ted-real-onboarding-grid {
        grid-template-columns:repeat(2,minmax(0,1fr));
      }
    }
    @media (max-width:520px) {
      #dashboardSchoolStartingPoints .ted-onboarding-cards.ted-real-onboarding-grid {
        grid-template-columns:1fr;
      }
    }

    /* Compact first-login onboarding: keep the real Dashboard visible. */
    #dashboardSchoolStartingPoints { padding:12px 16px!important; }

    /* Demo School onboarding: dark navy welcome panel. */
    #dashboardSchoolStartingPoints.ted-onboarding-compact,
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-compact {
      background:#172554!important;
      border-color:#334c94!important;
    }

    /* Light blue demo label. */
    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-top > strong {
      color:#93c5fd!important;
    }

    /* White welcome text in both display modes. */
    #dashboardSchoolStartingPoints.ted-onboarding-compact p,
    #dashboardSchoolStartingPoints.ted-onboarding-compact p strong,
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-compact p,
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-compact p strong {
      color:#ffffff!important;
    }

    /* Four white feature cards, including dark mode. */
    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-action:not(.ted-demo-setup-card),
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-action:not(.ted-demo-setup-card) {
      background:#ffffff!important;
      border-color:#cbd5e1!important;
      color:#0f172a!important;
    }

    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-action:not(.ted-demo-setup-card) strong,
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-action:not(.ted-demo-setup-card) strong {
      color:#0f172a!important;
    }

    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-action:not(.ted-demo-setup-card) span,
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-action:not(.ted-demo-setup-card) span {
      color:#64748b!important;
    }

    /* Blue setup card stays distinct. */
    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-setup-card,
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-setup-card {
      background:#dbeafe!important;
      border-color:#93c5fd!important;
      color:#1e40af!important;
    }

    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-setup-card i,
    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-setup-card strong,
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-setup-card i,
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-setup-card strong {
      color:#1d4ed8!important;
    }

    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-setup-card span,
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-setup-card span {
      color:#1e40af!important;
    }

    /* Indigo Explore More Features button. */
    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-more-button,
    body.house-display-dark #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-more-button {
      background:#312e81!important;
      border-color:#818cf8!important;
      color:#ffffff!important;
    }

    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-more-button i {
      color:inherit!important;
    }

    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-demo-more-button:hover {
      background:#4338ca!important;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-top { margin-bottom:4px; }
    #dashboardSchoolStartingPoints h3.ted-onboarding-hook { font-size:13px; line-height:1.3; }
    #dashboardSchoolStartingPoints h2.ted-onboarding-big {
      font-size:clamp(19px,1.65vw,23px); line-height:1.2; margin:4px 0;
    }
    #dashboardSchoolStartingPoints p { font-size:13px; margin:4px 0; line-height:1.4; }
    #dashboardSchoolStartingPoints .ted-onboarding-cards {
      gap:8px;
      max-width:none;
      margin:8px 0 6px;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-action {
      min-height:68px;
      padding:9px 11px;
      gap:2px;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-action--primary { padding-top:9px; }
    #dashboardSchoolStartingPoints .ted-onboarding-start {
      top:7px;
      right:8px;
      font-size:9px;
      padding:2px 6px;
    }
    #dashboardSchoolStartingPoints .ted-onboarding-action i { font-size:14px; margin-bottom:0; }
    #dashboardSchoolStartingPoints .ted-onboarding-action strong { font-size:12px; }
    #dashboardSchoolStartingPoints .ted-onboarding-action span:not(.ted-onboarding-start) { font-size:11px; }
    #dashboardSchoolStartingPoints .ted-onboarding-actions { margin-top:9px; }

    /* Keep both Demo School header buttons together. */
    #dashboardSchoolStartingPoints .ted-demo-header-actions {
      display:flex;
      align-items:center;
      justify-content:flex-end;
      gap:8px;
      flex-wrap:wrap;
      margin-left:auto;
      letter-spacing:normal;
    }

    #dashboardSchoolStartingPoints .ted-demo-header-actions button {
      display:inline-flex;
      align-items:center;
      justify-content:center;
      gap:7px;
      min-height:34px;
      padding:7px 12px;
      border-radius:8px;
      font-family:inherit;
      font-size:12px;
      font-weight:750;
      white-space:nowrap;
      cursor:pointer;
    }

    /* Main setup action. */
    #dashboardSchoolStartingPoints .ted-demo-header-setup {
      background:#dbeafe;
      border:1px solid #93c5fd;
      color:#1d4ed8;
    }

    #dashboardSchoolStartingPoints .ted-demo-header-setup i {
      color:inherit;
    }

    #dashboardSchoolStartingPoints .ted-demo-header-setup:hover {
      background:#bfdbfe;
      border-color:#60a5fa;
    }

    #dashboardSchoolStartingPoints .ted-demo-header-setup:focus-visible {
      outline:2px solid #93c5fd;
      outline-offset:2px;
    }

    /* Demo header buttons remain readable in dark mode. */
    body.house-display-dark #dashboardSchoolStartingPoints .ted-demo-header-setup {
      background:#dbeafe;
      border-color:#93c5fd;
      color:#1d4ed8;
    }

    @media (max-width:780px) {
      #dashboardSchoolStartingPoints .ted-demo-header-actions {
        width:100%;
        max-width:100%;
        justify-content:flex-start;
        flex-wrap:nowrap;
        margin-left:0;
        overflow-x:auto;
        overflow-y:hidden;
        overscroll-behavior-x:contain;
        -webkit-overflow-scrolling:touch;
        scrollbar-width:thin;
        padding-bottom:5px;
      }

      #dashboardSchoolStartingPoints .ted-demo-header-actions button {
        flex:0 0 auto;
        min-width:200px;
      }
    }

    /* Compact horizontal cards for Demo School only. */
    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-action {
      flex-direction:row;
      align-items:center;
      justify-content:center;
      gap:9px;
      min-height:52px;
      padding:10px 12px;
      text-align:left;
    }

    /* Highlight the first demo action until the user explores it. */
    #dashboardSchoolStartingPoints.ted-onboarding-compact
    .ted-onboarding-action:first-child:not(.ted-explore-visited) {
      position:relative;
      border-color:#86efac;
    }

    #dashboardSchoolStartingPoints.ted-onboarding-compact
    .ted-onboarding-action:first-child:not(.ted-explore-visited)::after {
      content:"START HERE";
      position:static;
      display:inline-flex;
      align-items:center;
      flex-shrink:0;
      margin-left:4px;
      padding:4px 7px;
      border-radius:6px;
      background:#dcfce7;
      color:#166534;
      font-size:9px;
      font-weight:800;
      letter-spacing:.02em;
      white-space:nowrap;
    }

    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-action i {
      flex-shrink:0;
      font-size:17px;
      margin:0;
    }

    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-action strong {
      font-size:12px;
      line-height:1.35;
      font-weight:750;
    }

    @media (max-width:780px) {
      #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-action {
        justify-content:flex-start;
        min-height:48px;
      }
    }

    /* Demo School: five equal cards on desktop. */
    #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-cards {
      grid-template-columns:repeat(4,minmax(0,1fr));
    }

    /* Demo School: distinct setup card. */
    #dashboardSchoolStartingPoints .ted-demo-setup-card {
      background:#dbeafe;
      border-color:#93c5fd;
      color:#1e40af;
    }

    #dashboardSchoolStartingPoints .ted-demo-setup-card i,
    #dashboardSchoolStartingPoints .ted-demo-setup-card strong {
      color:#1d4ed8;
    }

    #dashboardSchoolStartingPoints .ted-demo-setup-card span {
      color:#1e40af;
    }

    #dashboardSchoolStartingPoints .ted-demo-setup-card:hover,
    #dashboardSchoolStartingPoints .ted-demo-setup-card:focus-visible {
      background:#bfdbfe;
      border-color:#2563eb;
    }

    /* Demo School: additional features link in header. */
    #dashboardSchoolStartingPoints .ted-demo-more-button {
      display:inline-flex;
      align-items:center;
      justify-content:center;
      gap:7px;
      min-height:34px;
      padding:7px 12px;
      background:#f3e8ff;
      border:1px solid #c4b5fd;
      border-radius:8px;
      color:#6d28d9;
      font-family:inherit;
      font-size:12px;
      font-weight:750;
      letter-spacing:normal;
      cursor:pointer;
    }

    #dashboardSchoolStartingPoints .ted-demo-more-button:hover {
      background:#ede9fe;
      border-color:#8b5cf6;
    }

    #dashboardSchoolStartingPoints .ted-demo-more-button:focus-visible {
      outline:2px solid #7c3aed;
      outline-offset:2px;
    }

    /* Keep dark-mode contrast readable. */
    body.house-display-dark #dashboardSchoolStartingPoints .ted-demo-setup-card {
      background:#1e3a5f;
      border-color:#60a5fa;
      color:#dbeafe;
    }

    body.house-display-dark #dashboardSchoolStartingPoints .ted-demo-setup-card i,
    body.house-display-dark #dashboardSchoolStartingPoints .ted-demo-setup-card strong,
    body.house-display-dark #dashboardSchoolStartingPoints .ted-demo-setup-card span {
      color:#dbeafe;
    }

    body.house-display-dark #dashboardSchoolStartingPoints .ted-demo-more-button {
      background:#312450;
      border-color:#8b5cf6;
      color:#e9d5ff;
    }

    /* Prevent five cramped cards on tablets. */
    @media (min-width:781px) and (max-width:1200px) {
      #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-cards {
        grid-template-columns:repeat(2,minmax(0,1fr));
      }
    }

    /* Demo School: horizontally scrollable exploration buttons on mobile. */
    @media (max-width:780px) {
      #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-cards {
        display:flex;
        flex-wrap:nowrap;
        gap:10px;
        width:100%;
        max-width:100%;
        overflow-x:auto;
        overflow-y:hidden;
        overscroll-behavior-x:contain;
        -webkit-overflow-scrolling:touch;
        scrollbar-width:thin;
        padding:5px 2px 10px;
      }

      #dashboardSchoolStartingPoints.ted-onboarding-compact .ted-onboarding-cards .ted-onboarding-action {
        flex:0 0 220px;
        min-width:220px;
        min-height:56px;
        justify-content:center;
      }
    }

    #tedSampleStatusChip {
      position:fixed;
      right:96px;
      bottom:22px;
      z-index:1010;
      background:#172554;
      color:#fff;
      border:1px solid #60a5fa;
      padding:8px 12px;
      border-radius:999px;
      font:700 11px Lexend,sans-serif;
      box-shadow:0 4px 16px #0002;
      cursor:pointer;
    }
    #tedSampleStatusChip[hidden],
    body.active-section-dashboard #tedSampleStatusChip {
      display:none!important;
    }
    body.house-display-dark #dashboardSchoolStartingPoints {
      background:#172337!important;
      border-color:#334155!important;
    }
    body.house-display-dark #dashboardSchoolStartingPoints h2,
    body.house-display-dark #dashboardSchoolStartingPoints h3,
    body.house-display-dark #dashboardSchoolStartingPoints p strong {
      color:#f8fafc!important;
    }
    body.house-display-dark #dashboardSchoolStartingPoints p,
    body.house-display-dark #dashboardSchoolStartingPoints .ted-onboarding-top {
      color:#cbd5e1!important;
    }
    @media (max-width:780px) {
      #dashboardSchoolStartingPoints {
        padding:12px!important;
      }
      #dashboardSchoolStartingPoints .ted-onboarding-cards {
        grid-template-columns:1fr;
        gap:8px;
      }
      #dashboardSchoolStartingPoints .ted-onboarding-action {
        min-height:75px;
        padding:11px;
      }
      #dashboardSchoolStartingPoints .ted-onboarding-actions button {
        width:100%;
      }
      #tedSampleStatusChip {
        right:90px;
        bottom:88px;
        font-size:10px;
      }
    }

    /* Onboarding guides: readable without horizontal clipping on phones. */
    @media (max-width: 780px) {
      #pilotSetupDashboardCard > div:first-child,
      #teacherGettingStartedCard > div:first-child {
        flex-wrap: wrap !important;
      }

      #pilotSetupDashboardBadge,
      #teacherGettingStartedBadge {
        font-size: 11px !important;
      }

      #pilotSetupDashboardMessage,
      #teacherGettingStartedMessage {
        flex-basis: 100% !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        font-size: 12px !important;
      }

      #pilotSetupDashboardAction,
      #teacherGettingStartedAction {
        min-height: 40px !important;
        font-size: 12px !important;
      }
    }

        #dashboard-section {
  background: #f8fafc;
  border-radius: 0;
  padding: 8px 0 16px;
  width: 100%;
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
}

/* Full-width dashboard panels */
body.active-section-dashboard .main-content {
  padding-left: 12px !important;
  padding-right: 12px !important;
  width: 100%;
  max-width: none !important;
  min-width: 0;
}

#dashboard-section #tedWeeklyRecognitionSummary,
#dashboard-section .card:has(#leaderboardBars),
#dashboard-section .card:has(#houseOverview) {
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
  margin-left: 0 !important;
  margin-right: 0 !important;
  box-sizing: border-box;
}

body.house-display-dark #tedSchoolActivityClassBreakdown {
  background: #172337 !important;
  border-color: #334155 !important;
}
#tedSchoolActivityClassBreakdown.ted-class-recognition-inline {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0 0 12px;
  padding: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

#tedSchoolActivityClassBreakdown[hidden] {
  display: none !important;
}

#tedSchoolActivityClassBreakdown > div:last-child {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px !important;
  max-height: 400px !important;
  overflow-y: auto;
}

@media (max-width: 600px) {
  #tedSchoolActivityClassBreakdown > div:last-child {
    grid-template-columns: 1fr;
  }
}

body.house-display-dark #tedSchoolActivityClassBreakdown {
  background: #172337 !important;
  border-color: #334155 !important;
}


/* ==========================================
   DESKTOP DASHBOARD - REDUCE TOP EMPTY SPACE
   ========================================== */
@media (min-width: 1371px) {

  body.active-section-dashboard .main-content {
    padding-top: 0 !important;
  }

  body.active-section-dashboard #dashboard-section {
    padding-top: 0 !important;
  }

  body.active-section-dashboard #tedWeeklyRecognitionSummary {
    margin-top: 0 !important;
  }

}
    
        #students-section {
          background: var(--section-students);
          border-radius: var(--radius-lg);
          padding: 16px;
        }
    
        #houses-section {
          background: var(--section-houses);
          border-radius: var(--radius-lg);
          padding: 16px;
        }
    
        /* UPDATED: Increased to 1180px to hide sidebar on iPad */
    /* FIX: Force hide sidebar on all devices up to iPad Pro size */
    @media (max-width: 1370px) {
        .app-container {
            grid-template-columns: 1fr;
        }
        .sidebar {
            display: none !important; /* Added !important to force hide */
        }
        .main-content {
            padding: 16px;
        }
    }
    
    
    .house-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 12px;
      margin-top: 12px;
      width: 100%;
    }


    /* ==========================================
       DESKTOP STANDINGS
       Expand cards to use the available width
       when there are fewer than 4 houses
       ========================================== */
    @media (min-width: 1371px) {

      /* 1 House */
      .house-grid:has(> .house-card:only-child) {
        grid-template-columns: 1fr;
      }


      /* 2 Houses */
      .house-grid:has(> .house-card:nth-child(2):last-child) {
        grid-template-columns:
          repeat(2, minmax(0, 1fr));
      }


      /* 3 Houses */
      .house-grid:has(> .house-card:nth-child(3):last-child) {
        grid-template-columns:
          repeat(3, minmax(0, 1fr));
      }


      /* 4 or more Houses */
      .house-grid:has(> .house-card:nth-child(4)) {
        grid-template-columns:
          repeat(4, minmax(0, 1fr));
      }

    }


    @media (max-width: 1370px) {
      .house-grid {
        grid-template-columns:
          repeat(2, minmax(0, 1fr));
      }
    }


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


    @media (max-width: 480px) {
      .house-grid {
        grid-template-columns: 1fr;
      }
    }
    
    
    
    
    
    
    @media (max-width: 1370px) {
      /* Ensure the toast container is visible on top of everything */
      /* New specific styles for toolbar feedback only */
    #toolbar-toast-container {
      position: fixed;
      top: 30px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 100000; /* Over everything */
      width: 90%;
      max-width: 400px;
      pointer-events: none;
    }
    
    .toolbar-toast-item {
      display: flex !important; /* Forces visibility bypassing global hide */
      align-items: center;
      gap: 12px;
      background: #0f172a; /* Deep charcoal */
      color: white;
      padding: 14px 20px;
      border-radius: 16px;
      border-left: 5px solid #10b981; /* Success Green */
      box-shadow: 0 10px 30px rgba(0,0,0,0.5);
      margin-bottom: 10px;
      animation: slideDownIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
      pointer-events: auto;
    }
    
    @keyframes slideDownIn {
      from { opacity: 0; transform: translateY(-20px); }
      to { opacity: 1; transform: translateY(0); }
    }
    
    /* Confetti Animation Logic */
    .confetti-piece {
      position: fixed;
      width: 10px;
      height: 10px;
      background-color: #ffd700;
      top: -20px;
      z-index: 100001;
      border-radius: 2px;
      animation: confettiFall 2.5s ease-out forwards;
    }
    
    @keyframes confettiFall {
      0% { transform: translateY(0) rotate(0deg); opacity: 1; }
      100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
    }
    }
    
    
    @media (max-width: 1370px) {
      #studentsList .student-card {
        padding: 12px;
        margin-bottom: 8px;
        cursor: pointer;
        transition: all 0.4s ease-in-out; /* Smoother expansion */
        max-height: 120px; /* Base height for collapsed */
        overflow: hidden;
      }
    
      /* Add this specific rule to override the height when open */
      #studentsList .student-card.expanded {
        max-height: 1000px !important; /* Allow it to grow to its full content size */
      }
      #studentsList .student-card.collapsed .student-card-details,
      #studentsList .student-card.collapsed .student-card-actions {
        display: none;
      }
      #studentsList .student-card.expanded {
        background: var(--card-light);
        box-shadow: var(--shadow-md);
        max-height: 600px; /* Allow for expanded content */
      }
      .student-card-header {
        justify-content: center;
        text-align: center;
        position: relative;
        padding: 8px 24px;
        flex-direction: column;
        gap: 4px;
      }
      .student-card-header::after {
        content: '⌄';
        position: absolute;
        right: 12px;
        font-size: 16px;
        color: var(--primary-blue);
        transition: transform 0.3s ease;
      }
      .student-card.expanded .student-card-header::after {
        content: '⌃';
        transform: rotate(180deg);
      }
      .student-card-name {
        font-size: 14px;
        font-weight: 600;
        color: var(--dark-text);
      }
      .student-card-house {
        font-size: 11px;
        color: var(--gray);
        margin-top: 2px;
      }
      .student-card-class {
        font-size: 10px;
        color: var(--gray);
        margin-top: 2px;
        display: block; /* Ensure class is visible in collapsed state */
      }
      .student-card-details,
      .student-card-actions {
        margin-top: 12px;
        transition: opacity 0.3s ease, max-height 0.3s ease;
        opacity: 1;
        max-height: 500px; /* Adjust based on content */
        overflow: hidden;
      }
      .student-card.collapsed .student-card-details,
      .student-card.collapsed .student-card-actions {
        opacity: 0;
        max-height: 0;
      }
      /* Hide avatar in collapsed state for cleaner look */
      .student-card.collapsed .student-card-avatar {
        display: none;
      }
      /* Ensure only one card is expanded (optional, controlled by JS) */
      #studentsList .student-card:not(.expanded) {
        background: var(--card-light);
      }
    }
    
    
    
    
    
    
    
    
    /* ==========================================
       DARK MODE: SCHOOL ACTIVITY POP-UPS
       ========================================== */

    body.house-display-dark #tedSchoolActivityDetailsDialog,
    body.house-display-dark #tedSchoolActivityClassBreakdown {
      background: #172337 !important;
      color: #f8fafc !important;
      border-color: #334155 !important;
      color-scheme: dark;
    }

    /* Pop-up headings and sticky headers */
    body.house-display-dark #tedSchoolActivityDetailsDialog > div > div:first-child,
    body.house-display-dark #tedSchoolActivityClassBreakdown > div:first-child {
      background: #172337 !important;
      border-color: #334155 !important;
    }

    body.house-display-dark #tedSchoolActivityDetailsDialog h2,
    body.house-display-dark #tedSchoolActivityClassBreakdown h2 {
      color: #f8fafc !important;
    }

    body.house-display-dark #tedSchoolActivityDetailsDialog p,
    body.house-display-dark #tedSchoolActivityClassBreakdown p {
      color: #94a3b8 !important;
    }

    /* History summary and transaction cards */
    body.house-display-dark #tedSchoolActivityDetailsDialog
    > div > div:nth-child(2),
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction {
      background: #1e293b !important;
      border-color: #334155 !important;
    }

    body.house-display-dark #tedSchoolActivityDetailsDialog
    > div > div:nth-child(2) strong,
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle > div:first-of-type,
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-students strong {
      color: #f8fafc !important;
    }

    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle > strong:first-child {
      color: #cbd5e1 !important;
    }

    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle > div:last-child,
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-students span {
      color: #94a3b8 !important;
    }

    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-students {
      background: #182437 !important;
      border-color: #334155 !important;
    }

    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-students > div {
      color: #cbd5e1 !important;
      border-color: #334155 !important;
    }

    /* Recognition by Class cards */
    body.house-display-dark #tedSchoolActivityClassBreakdown
    > div:last-child > button {
      background: #1e293b !important;
      color: #f8fafc !important;
      border-color: #334155 !important;
    }

    body.house-display-dark #tedSchoolActivityClassBreakdown
    > div:last-child > button:hover {
      background: #263c60 !important;
      border-color: #60a5fa !important;
    }

    body.house-display-dark #tedSchoolActivityClassBreakdown
    > div:last-child > button span {
      color: #cbd5e1 !important;
    }

    /* Close buttons */
    body.house-display-dark #tedSchoolActivityDetailsDialog
    > div > div:first-child > button,
    body.house-display-dark #tedSchoolActivityClassBreakdown
    > div:first-child > button {
      background: #263449 !important;
      color: #f8fafc !important;
      border: 1px solid #475569 !important;
    }

    /* Preserve positive and negative point colours */
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle > strong:last-of-type {
      filter: brightness(1.35);
    }

    /* ==========================================
       COMPACT SCHOOL ACTIVITY HISTORY
       ========================================== */

    #tedSchoolActivityDetailsDialog {
      width: min(760px, calc(100vw - 24px)) !important;
      max-height: 85dvh !important;
    }

    #tedSchoolActivityDetailsDialog .ted-history-transaction {
      transition: border-color 0.15s ease,
                  background 0.15s ease;
    }

    #tedSchoolActivityDetailsDialog .ted-history-transaction:hover {
      border-color: #bfdbfe !important;
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle {
      padding: 12px 16px !important;
      row-gap: 4px !important;
      column-gap: 10px !important;
      outline-offset: -3px;
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle::-webkit-details-marker {
      display: none;
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle::marker {
      content: '';
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle > div {
      flex: 0 0 100%;
      min-width: 0;
      margin-top: 0 !important;
      line-height: 1.45;
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle > div:last-child {
      color: #64748b;
      font-weight: 400;
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-transaction[open] {
      border-color: #93c5fd !important;
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle::after {
      content: "Show details";
      display: flex;
      align-items: center;
      gap: 7px;
      margin-left: auto;
      color: #2563eb;
      font-size: 11px;
      font-weight: 700;
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle::before {
      content: "\f078";
      font-family: "Font Awesome 6 Free";
      font-weight: 900;
      color: #2563eb;
      font-size: 11px;
      order: 10;
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-transaction[open]
    .ted-history-transaction-toggle::after {
      content: "Hide details";
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-transaction[open]
    .ted-history-transaction-toggle::before {
      content: "\f077";
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-transaction[open]
    .ted-history-transaction-toggle {
      background: #eff6ff;
    }

    /* DARK MODE: Keep expanded history cards dark */
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction[open]
    .ted-history-transaction-toggle {
      background: #1e293b !important;
      border-color: #334155 !important;
    }

    /* Readable date and recognition/Needs Work reason */
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle > strong:first-child,
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle > div:first-of-type {
      color: #f8fafc !important;
    }

    /* Secondary transaction information */
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle > div:last-of-type {
      color: #a8b8cc !important;
    }

    /* Expanded student details */
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction[open] .ted-history-students {
      background: #182437 !important;
      border-color: #334155 !important;
      color: #f8fafc !important;
    }

    /* Keep expand/collapse controls clearly visible */
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle::before,
    body.house-display-dark #tedSchoolActivityDetailsDialog
    .ted-history-transaction-toggle::after {
      color: #60a5fa !important;
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-students {
      max-height: 360px;
      overflow-y: auto;
    }

    #tedSchoolActivityDetailsDialog
    .ted-history-students > strong {
      margin-bottom: 8px;
    }

    @media (max-width: 600px) {
      #tedSchoolActivityDetailsDialog
      .ted-history-transaction-toggle {
        padding: 11px 12px !important;
      }

      #tedSchoolActivityDetailsDialog
      .ted-history-students {
        padding: 10px 12px !important;
      }
    }

    @media (max-width: 1370px) {
      #tedSchoolActivityDetailsDialog,
      #tedSchoolActivityClassBreakdown {
        position: fixed !important;
        inset: 0 !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        overflow-y: hidden !important;
      }

      #tedSchoolActivityDetailsDialog > div {
        width: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        padding:
          calc(18px + env(safe-area-inset-top))
          16px
          calc(24px + env(safe-area-inset-bottom))
          16px !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
      }

      #tedSchoolActivityClassBreakdown {
        padding:
          calc(18px + env(safe-area-inset-top))
          16px
          calc(24px + env(safe-area-inset-bottom))
          16px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
      }

      #tedSchoolActivityClassBreakdown > div:last-child {
        max-height: none !important;
        overflow-y: visible !important;
      }

      #tedSchoolActivityDetailsDialog::backdrop,
      #tedSchoolActivityClassBreakdown::backdrop {
        background: rgba(15, 23, 42, 0.45);
      }
    }

    /* --- CLASS BREAKDOWN INTERACTION --- */
    .class-rank-card {
      transition: all 0.3s ease !important;
      cursor: pointer !important;
    }
    
    .class-rank-card:hover {
      transform: translateY(-5px) scale(1.02) !important;
      box-shadow: 0 10px 20px rgba(0,0,0,0.1) !important;
      background-color: #f8fafc !important;
    }
    
    .class-breakdown-container {
      display: flex;
      flex-direction: column;
      gap: 10px;
      margin-top: 15px;
      text-align: left;
    }
    
    .class-breakdown-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 12px 16px;
      background: #f1f5f9;
      border-radius: 12px;
      border-left: 5px solid var(--house-color, #1e40af);
      transition: transform 0.2s ease;
    }
    
    .class-breakdown-row:hover {
      transform: translateX(5px);
      background: #e2e8f0;
    }
    
    .breakdown-house-info {
      display: flex;
      align-items: center;
      gap: 12px;
      font-weight: 700;
      color: #1e293b;
    }
    
    .breakdown-pts {
      font-weight: 800;
      color: #1e40af;
    }
    
    
        @media (max-width: 1370px) {  /* <--- CHANGE TO 1180px */
    
    body.mobile {
            padding-bottom: calc(90px + env(safe-area-inset-bottom));
        }
        .mobile-nav {
            display: none;
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 76px;
            background: var(--card-light);
            box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
            display: flex; /* This makes it visible */
            justify-content: space-around;
            padding: 8px 0 calc(8px + env(safe-area-inset-bottom)) 0;
            z-index: 1000;
        }
      body.mobile .mobile-nav {
        display: flex;
      }
    
      body.mobile .mobile-nav {
        scroll-snap-type: x mandatory; /* Snap to items for smooth scrolling */
        -webkit-overflow-scrolling: touch; /* Ensure smooth iOS scrolling */
      }
    
      /* Fade gradients on edges */
      body.mobile .mobile-nav::before,
      body.mobile .mobile-nav::after {
        content: '';
        position: absolute;
        top: 0;
        width: 24px;
        height: 100%;
        z-index: 10;
        pointer-events: none;
      }
      body.mobile .mobile-nav::before {
        left: 0;
        background: linear-gradient(to right, var(--card-light), transparent);
      }
      body.mobile .mobile-nav::after {
        right: 0;
        background: linear-gradient(to left, var(--card-light), transparent);
      }
    
      /* Scroll hint animation */
      body.mobile .mobile-nav-item {
        scroll-snap-align: center; /* Snap items to center */
        animation: nudge 3s ease-in-out 1s 2; /* Nudge twice after 1s delay */
      }
    
      /* Scroll indicator arrows */
      body.mobile .mobile-nav:not(:hover)::before,
      body.mobile .mobile-nav:not(:hover)::after {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        color: var(--gray);
        opacity: 0.7;
      }
      body.mobile .mobile-nav:not(:hover)::before {
        content: '◄';
      }
      body.mobile .mobile-nav:not(:hover)::after {
        content: '►';
      }
    
      @keyframes nudge {
        0%, 100% { transform: translateX(0); }
        50% { transform: translateX(10px); }
      }
      
      .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px; /* More space between icon and text */
        color: var(--primary-blue);
        font-size: 11px; /* Slightly larger text */
        font-weight: 600;
        padding: 8px 12px; /* Much larger touch target area */
        border-radius: 12px; /* Softer corners */
        transition: all 0.2s ease;
        min-width: 75px; /* Wider buttons */
        height: 100%; /* Fill the container height */
        touch-action: manipulation;
      }
      
      .mobile-nav-item.active {
        background: var(--primary-blue);
        color: white;
        transform: translateY(-4px); /* Little pop effect when active */
        box-shadow: 0 4px 8px rgba(30, 64, 175, 0.3);
      }
      
      .mobile-nav-item i {
        font-size: 24px; /* Increased from 16px to 24px for better visibility */
      }
      
         
    
          .main-content {
            padding: 12px;
          }
    
          .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1px;      /* Reduced gap */
        margin-bottom: 1px; /* Reduced margin */
      }
    
          .page-title {
            font-size: 18px;
          }
    
          .page-actions {
            width: 100%;
            flex-wrap: wrap;
            gap: 8px;
          }
    
                .page-actions.mobile-only {
            display: flex !important;
            flex-direction: column;
            gap: 8px;
            width: 100%;
          }
    
          body.mobile #houses-section .page-actions.mobile-only {
            display: flex !important;
            margin-top: 12px;
          }
    
    
          /* Mobile-friendly modal styles */
          body.mobile .house-expanded.mobile-only .house-expanded-content {
            padding: 16px;
            display: flex;
            flex-direction: column;
            gap: 12px;
            background: var(--card-light);
            border-radius: 0;
            overflow-y: auto;
          }
    
          body.mobile .house-expanded.mobile-only .house-expanded-title {
            font-size: 20px;
            font-weight: 700;
            color: var(--primary-blue);
            margin-bottom: 8px;
          }
    
          body.mobile .house-expanded.mobile-only .house-expanded-close {
            width: 40px;
            height: 40px;
            font-size: 20px;
            top: 8px;
            right: 8px;
          }
    
          body.mobile .house-expanded.mobile-only .btn {
            font-size: 16px;
            padding: 12px;
            min-height: 48px;
            border-radius: 10px;
            width: 100%;
            justify-content: center;
            gap: 8px;
          }
    
          body.mobile .house-expanded.mobile-only .form-control {
            font-size: 16px;
            padding: 12px;
            height: 48px;
            border-radius: 10px;
          }
    
          body.mobile .house-expanded.mobile-only .house-config-item {
            flex-direction: column;
            align-items: stretch;
            padding: 12px;
            border-radius: 10px;
            gap: 8px;
          }
    
          body.mobile .house-expanded.mobile-only .house-config-emoji {
            width: 100%;
            max-width: 80px;
            font-size: 20px;
            text-align: left;
          }
    
          body.mobile .house-expanded.mobile-only .house-config-name,
          body.mobile .house-expanded.mobile-only .form-control[placeholder="House motto"],
          body.mobile .house-expanded.mobile-only .form-control[placeholder="Captain’s Message"],
          body.mobile .house-expanded.mobile-only .form-control[placeholder="Password"],
          body.mobile .house-expanded.mobile-only .form-control[placeholder="Admin Email"] {
            width: 100%;
          }
    
          body.mobile .house-expanded.mobile-only .announcement-item {
            flex-direction: column;
            align-items: stretch;
            padding: 12px;
            border-radius: 10px;
            gap: 8px;
          }
    
          body.mobile .house-expanded.mobile-only .announcement-title-input,
          body.mobile .house-expanded.mobile-only .announcement-text,
          body.mobile .house-expanded.mobile-only .announcement-points-input {
            width: 100%;
            font-size: 16px;
            padding: 12px;
            height: 48px;
            border-radius: 10px;
          }
    
          body.mobile .house-expanded.mobile-only #houseSettingsListMobile,
          body.mobile .house-expanded.mobile-only #announcementsListMobile {
            display: flex;
            flex-direction: column;
            gap: 12px;
          }
    
                body.mobile .house-expanded.mobile-only#houseConfigModal .form-group-row {
            display: none !important;
          }
                  .desktop-only, .page-actions.desktop-only {
            display: none !important;
          }
    
               #dashboard-section .page-title {
            display: none;
          }
    
          .announcement-bar {
            position: relative;
            z-index: 100;
          }
    
          
    
          body.mobile #dashboard-section .page-actions {
            margin-top: 16px;
          }
    
                .card.desktop-only {
            display: none !important;
          }
    
          body.mobile #houses-section .card.desktop-only {
            display: none !important;
          }
    
          .card {
            padding: 12px;
            border-radius: 10px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
          }
    
          .house-expanded, .housepoints-user-guide-overlay {
            width: 100vw !important;
            height: 100vh !important;
            top: 0 !important;
            left: 0 !important;
            margin: 0 !important;
            padding: 0 !important;
            border-radius: 0 !important;
            align-items: flex-start !important; /* Forces modals to anchor to the top */
          }
    
          .house-expanded-content {
      width: 100vw !important;
      max-width: 100% !important;
      height: 100vh !important;
      max-height: 100% !important;
      padding: 16px !important;
      padding-top: 60px !important;
      padding-bottom: 16px !important; /* Reduced from default to prevent massive bottom padding */
      border-radius: 0 !important;
      box-shadow: none !important;
      margin: 0 !important;
      display: flex !important;
      flex-direction: column;
    }


    /* ==========================================
       HOUSE DETAIL V2
       True edge-to-edge mobile modal
       ========================================== */
    #expandedHouseView .house-expanded-content.house-detail-v2 {
      width: 100vw !important;
      max-width: 100vw !important;

      height: 100dvh !important;
      max-height: 100dvh !important;

      padding: 0 !important;
      padding-top: 0 !important;
      padding-right: 0 !important;
      padding-bottom: 0 !important;
      padding-left: 0 !important;

      margin: 0 !important;

      border-radius: 0 !important;

      box-shadow: none !important;

      overflow-x: hidden !important;
      overflow-y: auto !important;
    }
    
    /* Specific fix for modals that had extra bottom padding */
    #reasonManagerModal .house-expanded-content,
    #milestoneEditorModal .house-expanded-content,
    #reasonSettingsModal .house-expanded-content {
      padding-bottom: 16px !important;
    }

    /* FIRST LOGIN / EDIT STAFF PROFILE MODAL */
    #staffSetupModal {
      padding: 0 !important;
      align-items: stretch !important;
      justify-content: flex-start !important;
      overflow: hidden !important;
    }

    #staffSetupModal .house-expanded-content {
      width: 100vw !important;
      max-width: 100vw !important;

      height: 100dvh !important;
      min-height: 100dvh !important;
      max-height: 100dvh !important;

      margin: 0 !important;

      padding:
        calc(18px + env(safe-area-inset-top))
        16px
        calc(18px + env(safe-area-inset-bottom))
        16px !important;

      border-radius: 0 !important;

      overflow-x: hidden !important;
      overflow-y: auto !important;

      display: block !important;

      box-shadow: none !important;

      box-sizing: border-box !important;

      -webkit-overflow-scrolling: touch;
    }

    #staffSetupModal .house-expanded-content > div:first-child {
      margin-bottom: 14px !important;
    }

    #staffSetupModal .house-expanded-content
    > div:first-child
    > div:first-child {
      width: 48px !important;
      height: 48px !important;

      margin:
        0
        auto
        10px !important;
    }

    #staffSetupModal .house-expanded-content
    > div:first-child
    > div:first-child
    > i {
      font-size: 21px !important;
    }

    #staffSetupWelcomeName {
      font-size: 24px !important;
      line-height: 1.1 !important;
      margin-bottom: 5px !important;
    }

    #staffSetupModal .house-expanded-content
    > div:first-child
    > p {
      font-size: 12px !important;
      line-height: 1.4 !important;
    }

    #staffSetupModal .form-group {
      width: 100% !important;
      min-width: 0 !important;
      flex: none !important;
      margin-bottom: 0 !important;
    }

    #staffSetupModal #staffRoleSelect,
    #staffSetupModal #staffHouseSelect,
    #staffSetupModal #staffSetupCategory,
    #staffSetupModal #staffSetupClass {
      display: block !important;

      width: 100% !important;
      min-width: 0 !important;

      height: 44px !important;
      min-height: 44px !important;

      padding:
        0
        36px
        0
        12px !important;

      font-size: 14px !important;
      line-height: 44px !important;

      box-sizing: border-box !important;
    }

    @media (max-width: 680px) {

      #staffSetupModal .house-expanded-content {
        padding:
          calc(16px + env(safe-area-inset-top))
          14px
          calc(16px + env(safe-area-inset-bottom))
          14px !important;
      }

      #staffSetupModal .house-expanded-content
      > div:nth-child(2) {
        padding: 11px 12px !important;
        margin-bottom: 13px !important;
        border-radius: 12px !important;
      }

      #staffSetupModal .house-expanded-content
      > div:nth-child(2)
      > div {
        margin-bottom: 5px !important;
      }

      #staffSetupModal .house-expanded-content
      > div:nth-child(2)
      > p {
        margin-left: 26px !important;
      }

      #staffSetupModal .house-expanded-content
      > div:nth-child(3) {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        margin-bottom: 9px !important;
      }

      #staffSetupModal .house-expanded-content
      > div:nth-child(4) {
        margin-bottom: 11px !important;
      }

      #staffSetupModal .house-expanded-content
      > div:nth-child(5) {
        padding: 12px !important;
        margin-bottom: 14px !important;
        border-radius: 12px !important;
      }

      #staffSetupModal .house-expanded-content
      > div:nth-child(5)
      > div:nth-child(2) {
        grid-template-columns: 1fr !important;
        gap: 9px !important;
      }

      #staffSetupModal .form-label {
        margin-bottom: 5px !important;
        font-size: 12px !important;
      }

      #staffSetupCancelBtn,
      #staffSetupSubmitBtn {
        min-height: 46px !important;
        border-radius: 12px !important;
      }

      #staffSetupCancelBtn {
        flex: 1 !important;
      }

      #staffSetupSubmitBtn {
        flex: 2 !important;
      }

    }
    
          .housepoints-user-guide-container {
            width: 100vw;
            max-width: 100%;
            height: 100vh;
            max-height: 100%;
            padding: 0;
            margin: 0;
            border: none;
            border-radius: 0;
            box-shadow: none;
            display: flex;
            flex-direction: column;
            background: var(--card-light);
          }
    
                /* User Guide modal video and intro container layout */
          body.mobile #housepoints-user-guide-modal > .housepoints-user-guide-container > .housepoints-user-guide-body > div[style*="display: flex; gap: 24px;"] {
            flex-direction: column !important;
            gap: 16px !important;
            align-items: stretch !important;
            margin-bottom: 24px !important;
          }
    
          body.mobile #housepoints-user-guide-modal div[style*="width: 100%; height: 100%; min-height: 280px;"] {
            width: 100% !important;
            min-height: 200px !important;
            height: auto !important;
          }
    
          body.mobile #housepoints-user-guide-modal iframe[style*="width: 100%; height: 100%; min-height: 280px;"] {
            width: 100% !important;
            min-height: 200px !important;
            height: 200px !important;
            border-radius: 8px;
          }
    
          body.mobile #housepoints-user-guide-modal p[style*="font-size: 14px; font-weight: 600;"] {
            font-size: 16px !important;
            padding: 8px !important;
            text-align: left !important;
            margin: 0 0 16px 0 !important;
          }
    
          body.mobile #housepoints-user-guide-modal .housepoints-intro-container {
            width: 100% !important;
            padding: 16px !important;
            min-height: auto !important;
            flex: 1 !important;
          }
    
         
    
          .house-expanded.mobile-only.show {
            display: flex;
          }
    
          .form-group-row {
            flex-direction: column;
            gap: 8px;
          }
    
          .form-group-row .form-group {
            min-width: 100%;
          }
    
          .form-control {
            font-size: 14px;
            padding: 10px;
            height: 40px;
            border-radius: 8px;
          }
    
    .btn {
      font-size: 16px;
      padding: 12px;
      border-radius: 8px;
      min-height: 48px;
      width: 100%;
      text-align: center;
      box-sizing: border-box;
    }
    @media (min-width: 769px) {
      .btn {
        width: auto;
        padding: 8px 16px;
        font-size: 13px;
        min-height: 40px;
      }
    }
    
          
    
          #students-section {
      width: 100%;
      max-width: 100%;
      min-height: calc(100vh - 56px - 60px); /* Header + nav */
      display: flex;
      flex-direction: column;
      padding-bottom: env(safe-area-inset-bottom, 60px); /* Respect safe area */
      overflow-x: hidden;
      background: var(--section-students);
    }
    #students-section .card {
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      border-radius: 12px;
      padding: 16px;
    }
    #students-section .table-responsive {
      width: 100%;
      overflow-x: hidden;
    }
    
    
    
    /* Force 5 columns on iPads and Tablets */
              @media (min-width: 781px) {
                .house-group-grid {
                  grid-template-columns: repeat(5, 1fr) !important;
                }
              }









              @media (max-width: 1370px) {
  #students-section {
    position: fixed;
    top: 44px; /* Adjusted for hidden header */
    left: 0;
    width: 100vw !important; /* Force full viewport width */
    max-width: 100vw !important;
    box-sizing: border-box;
    height: calc(100vh - 44px);
    z-index: 999;
    padding: 0 !important; /* REMOVE ALL PADDING - EDGE TO EDGE */
    margin: 0 !important;
    border-radius: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-padding-top: 15px;
  }
  
  /* Remove padding from the main card inside students section */
  #students-section .card {
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 12px !important;
    width: 100% !important;
    box-sizing: border-box;
  }
  
  /* Remove padding from the card header */
  #students-section .card .card-header {
    padding: 0 0 12px 0 !important;
  }
  
  /* Ensure the students list container is edge to edge */
  #students-section .table-container {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  
  /* Make student cards edge to edge with no outer margins */
  #studentsList {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
  
  /* Student cards should touch the edges */
  #studentsList .student-card {
    margin: 0 0 8px 0 !important;
    border-radius: 0 !important;
    width: 100% !important;
  }
  
  /* House group sections should be edge to edge */
  .house-group-section {
    margin: 0 0 12px 0 !important;
    border-radius: 0 !important;
  }
  
  .house-group-header {
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 12px 16px !important;
  }
  
  .house-group-grid {
    padding: 12px !important;
  }
}

/* Phone: full-width Student Management without altering tablet layout */
@media (max-width: 780px) {
  #students-section > .card {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  #students-section #studentsList {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  #students-section #studentsList .house-group-section {
    width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  #students-section #studentsList .house-group-grid {
    padding: 8px 0 !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
}


    
    
    @media (max-width: 1370px) {
      
    
    
    
    /* SEARCH GLOW ANIMATION */
    
    @keyframes groupSearchGlow {
    
      0% { transform: scale(1); box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
    
      50% { transform: scale(1.02); box-shadow: 0 0 20px var(--group-color); }
    
      100% { transform: scale(1); box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
    
    }
    
    
    
    .group-glow-active {
    
      animation: groupSearchGlow 1.5s ease-out;
    
      z-index: 10;
    
    }
    
      /* REMOVE REDUNDANT ACCORDION ARROW ON MOBILE CARDS */
      #students-section .student-card-header::after {
        display: none !important;
        content: none !important;
      }
    
      /* FIX: Ensure the grid itself respects the container bounds */
      .house-group-grid {
        width: 100%;
        box-sizing: border-box;
        padding-right: 2px; /* Safety buffer for the right edge */
      }
    
      #studentsList {
        width: 100%;
        box-sizing: border-box;
      }
    
      .form-group-row.award-class-house {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 0;
        margin: 0;
        align-items: stretch;
      }
    
      .form-group-row.award-class-house > div:nth-child(1) {
        display: flex;
        flex-direction: row;
        gap: 8px;
        width: 100%;
      }
    
      .form-group-row.award-class-house > div:nth-child(1) > .form-group:nth-child(1),
      .form-group-row.award-class-house > div:nth-child(1) > .form-group:nth-child(2) {
        flex: 1;
        min-width: 0;
      }
    
      .form-group-row.award-class-house .form-group {
        min-width: 0;
        max-width: 100%;
        margin-bottom: 0;
      }
    
      .form-group-row.award-class-house .form-label {
        font-size: 12px;
        margin-bottom: 2px;
        font-weight: 500;
        color: var(--dark-text);
      }
    
      .form-group-row.award-class-house .form-control {
        width: 100%;
        height: 40px;
        font-size: 14px;
        padding: 8px;
        border-radius: 6px;
        border: 1px solid var(--gray-light);
        background: var(--bg-light);
        touch-action: manipulation;
      }
    
      .form-group-row.award-class-house select.form-control {
        padding-right: 24px;
        background-size: 12px;
      }
    
      .form-group-row.award-class-house .btn {
        width: 100%;
        height: 48px;
        font-size: 16px;
        padding: 12px;
        border-radius: 8px;
        background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
        color: var(--light-text);
        font-weight: 600;
        margin-top: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
      }
    
      .form-group-row.award-class-house #pointsPreview {
        font-size: 12px;
        color: var(--primary-blue);
        text-align: center;
        margin-top: 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    
      .form-group-row.award-class-house #housePointsOverview {
        display: none;
      }
    
      #studentsList .student-card {
        display: flex;
        flex-direction: column;
        background: var(--card-light);
        border-radius: 12px;
        padding: 16px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        margin-bottom: 12px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box; /* Prevents padding from stretching the card */
      }
    
      /* 1. COMPACT TRADING CARD STYLE */
      /* 1. COMPACT TRADING CARD STYLE */
      #students-section .student-card {
        position: relative;
        margin: 0;
        border-radius: 16px; 
        background: linear-gradient(to bottom, #ffffff 75%, var(--house-color) 180%) !important;
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
        border: 1px solid rgba(0, 0, 0, 0.05);
        overflow: visible !important; 
        transition: all 0.2s ease;
        display: flex;
        flex-direction: column;
        /* Taller by 3px for better breathing room */
        min-height: 138px !important; 
        padding: 8px 6px !important;
        
        /* MOBILE SPEED OPTIMIZATION: Skip rendering off-screen cards */
        content-visibility: auto;
        contain-intrinsic-size: 138px; /* Tells browser the expected height so scrolling doesn't jump */
        will-change: transform, opacity; /* Hardware acceleration */
      }
    
      /* Hover effect to make the card feel "tappable" */
      #students-section .student-card:active {
        transform: scale(0.95);
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
      }
    
      /* --- NEW: PREMIUM EXPANDED STATE (INTENSE DYNAMIC GRADIENT) --- */
      #students-section .student-card.expanded {
        grid-column: 1 / -1 !important; 
        transform: scale(1.02) !important; 
        /* When expanded, the gradient comes up higher (45%) to look more cinematic */
        background: linear-gradient(to bottom, #ffffff 45%, var(--house-color) 150%);
        box-shadow: 0 20px 40px rgba(0,0,0,0.2) !important; 
        
        border: 3px solid var(--house-color) !important; 
        z-index: 10 !important; 
        margin: 12px 0 !important; 
      }
    
      /* 2. ENSURE COLLAPSED STATE GROWS IF NEEDED */
      #studentsList .student-card.collapsed {
        max-height: none !important; 
      }
    
      /* 3. COMPACT HEADER LAYOUT */
      /* 3. TIGHT HEADER LAYOUT */
      #students-section .student-card.collapsed .student-card-header {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center; /* Center vertically in the shorter card */
        padding: 0 !important;       
        gap: 1px !important; /* Minimal gap between icon and name */          
        height: 100%;
        text-align: center;
        width: 100%;
        box-sizing: border-box;
      }
    
      /* Clean Horizontal Layout for Collapsed Cards */
          .student-card.collapsed .student-card-header {
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 12px;
            padding: 10px 15px;
            text-align: left;
          }
    
          /* The Action Column: Stacks Points on top of the Settings Icon */
          .action-column {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            min-width: 50px;
            flex-shrink: 0;
          }
    
    .action-column {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
      min-width: 50px;
      flex-shrink: 0;
    }
    
    /* EXPANSION INDICATOR STYLES */
          .expansion-indicator {
            width: 22px;
            height: 22px;
            background: #f1f5f9;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #64748b;
            font-size: 9px;
            transition: all 0.2s ease;
            border: 1px solid #e2e8f0;
            margin-top: 2px; /* Added for better vertical centering in the Action Column */
          }
    
    /* HIDE INDICATOR COMPLETELY WHEN EXPANDED */
    .student-card.expanded .expansion-indicator {
      display: none !important;
    }
    
    /* HERO SHIELD - COMPACT FOR PHONES */
    .student-card.collapsed .hero-shield { 
      width: 46px !important; 
      height: 46px !important; 
      font-size: 26px !important;
      margin: 0 !important; 
      flex-shrink: 0; 
    }
          
          .student-card.expanded .expansion-indicator {
      display: none !important;
    }
    
          .collapsed-points-pill {
            margin: 0 !important;
            font-weight: 800;
            font-size: 14px;
          }
    
      /* CARD NAME STYLE */
      #students-section .student-card.collapsed .student-card-name {
        color: #0f172a !important; 
        width: 100%;
        font-size: 13px !important; /* Increased for readability */
        font-weight: 800;
        line-height: 1.1;
        text-align: center;
        margin-bottom: 8px !important;
        min-height: 32px; 
      }
    
      /* INTEGRATED POINTS BOX - REFINED FOR GRADIENT BACKGROUND */
      .collapsed-points-pill {
        background: white !important; 
        color: #0f172a !important; 
        font-weight: 900 !important;
        font-size: 16px !important; 
        padding: 6px 12px !important;
        border-radius: 12px !important;
        /* Adding a crisp border so the white pill stands out against the white part of the card */
        border: 1px solid #e2e8f0 !important;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1) !important;
        margin: 0 auto !important;
        width: fit-content;
      }
    
      /* NEW: BULLETPROOF BLACK ID PILL FOR COLLAPSED STATE */
      .collapsed-id-pill {
        font-family: 'Courier New', monospace !important;
        font-weight: 800 !important;
        color: #000000 !important; /* FORCED PURE BLACK */
        background-color: #f1f5f9 !important;
        padding: 1px 6px !important;
        border-radius: 4px !important;
        border: 1px solid #cbd5e1 !important;
        font-size: 11px !important;
        letter-spacing: 0.5px !important;
      }
    
      #studentsList .student-card:hover {
        transform: translateY(-2px);
      }
    
      .student-card-header {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 12px;
      }
    
      .student-card-avatar {
        display: none; 
      }
    
      /* ADJUST TEXT SIZES FOR COMPACT VIEW & FIX LONG NAMES */
      /* ADJUST TEXT SIZES FOR COMPACT VIEW & FIX LONG NAMES */
      #students-section .student-card.collapsed .student-card-name {
        font-size: 12px !important; /* Base size for phones */
        font-weight: 700;
        color: var(--dark-text);
        margin-bottom: 2px !important;
        line-height: 1.2 !important;
        width: 100%;
        white-space: normal;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        word-break: break-word;
      }
      .student-card-class {
        font-size: 14px;
        color: var(--gray);
      }
    
      .student-card-details {
        display: flex;
        flex-direction: column;
         gap: 8px !important; /* Tighten gap between dropdowns and inputs */
        margin-bottom: 8px !important; 
      }
    
      .student-card-details select,
      .student-card-details input {
        font-size: 16px;
        padding: 10px;
        height: 48px;
        border-radius: 8px;
        width: 100%;
        box-sizing: border-box;
      }
    
      .student-card-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
      }
    
      .student-card-actions .btn {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        min-height: 48px;
        border-radius: 8px;
        box-sizing: border-box;
      }
    
      .student-card-actions-toggle {
        display: none;
      }
    
      .student-card-actions-toggle + label {
        display: block;
        font-size: 14px;
        font-weight: 600;
        color: var(--primary-blue);
        cursor: pointer;
        padding: 8px;
        background: var(--gray-light);
        border-radius: 8px;
        text-align: center;
      }
    
      .student-card-actions-toggle:checked + label {
        background: var(--primary-blue);
        color: white;
      }
    
      .student-card-actions-toggle:checked ~ .student-card-actions {
        display: flex;
      }
    }


    /* ==========================================
       STUDENT BEHAVIOUR TIER BADGE
       DESKTOP + IPAD + MOBILE
       ========================================== */

    .student-behaviour-tier-badge {
      position: relative;

      min-width: 74px;
      min-height: 25px;

      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 4px;

      padding: 4px 8px 6px;

      border:
        1px solid
        var(--tier-border) !important;

      border-radius: 999px;

      background:
        var(--tier-bg) !important;

      color:
        var(--tier-color) !important;

      font-family: inherit;

      font-size: 9px;
      font-weight: 850;
      line-height: 1;

      white-space: nowrap;

      cursor: pointer;

      box-shadow:
        0 1px 3px
        rgba(15,23,42,.08);

      appearance: none;
      -webkit-appearance: none;

      overflow: hidden;
    }


    .student-behaviour-tier-badge::after {
      content: "";

      position: absolute;

      left: 0;
      bottom: 0;

      width:
        var(--tier-progress);

      height: 3px;

      background:
        var(--tier-color);

      opacity: .8;
    }


    .student-behaviour-tier-badge .tier-full {
      display: inline;
    }


    .student-behaviour-tier-badge .tier-short {
      display: none;
    }


    @media (max-width: 1370px) {

      .student-behaviour-tier-badge {
        min-width: 58px;
        min-height: 24px;

        padding:
          4px
          6px
          6px;

        font-size: 8px;
      }


      .student-behaviour-tier-badge .tier-full {
        display: none !important;
      }


      .student-behaviour-tier-badge .tier-short {
        display: inline !important;
      }

    }


    @media (max-width: 600px) {

      .student-behaviour-tier-badge {
        min-width: 52px;
        min-height: 22px;

        padding:
          3px
          5px
          5px;

        font-size: 7.5px;
      }

    }


    /* ==========================================
       TEACHER STUDENT MANAGEMENT PERMISSION
       ========================================== */

    body.student-management-locked
    #desktopAddStudentsMenu {
      display: none !important;
    }


    body.student-management-locked
    #overflowMenuDropdown
    .overflow-menu-item[onclick*="showAddStudentModal"] {
      display: none !important;
    }


    body.student-management-locked
    #overflowMenuDropdown
    .overflow-menu-item[onclick*="openBulkImportModal"] {
      display: none !important;
    }


    body.student-management-locked
    button[onclick*="showEditStudentModal"] {
      display: none !important;
    }


    body.student-management-locked
    button[onclick*="confirmDeleteStudent"] {
      display: none !important;
    }


    body.student-management-locked
    button[onclick*="showAddEditTeacherModal"],
    body.student-management-locked
    .overflow-menu-item[onclick*="showAddEditTeacherModal"] {
      display: none !important;
    }


    body.student-management-locked
    #googleClassroomImportCard {
      display: none !important;
    }


    body.student-management-locked
    select[onchange*="assignHouse"],
    body.student-management-locked
    select[onchange*="updateRole"] {
      pointer-events: none !important;
      opacity: 0.5 !important;
      cursor: not-allowed !important;
    }
    
    
    
    /* ==========================================
       MANAGE CLASS MODAL RESPONSIVE LAYOUT
       ========================================== */

    @media (max-width: 900px) {

      #addEditTeacherModal {
        padding: 12px !important;
        align-items: flex-start !important;
        overflow-y: auto !important;
      }


      #addEditTeacherModal
      .manage-class-content {
        width: 100% !important;
        max-width: 720px !important;

        height: auto !important;
        min-height: 0 !important;
        max-height: calc(100dvh - 24px) !important;

        margin: auto !important;

        padding: 0 !important;
        padding-top: 0 !important;

        border-radius: 18px !important;

        overflow-x: hidden !important;
        overflow-y: auto !important;

        display: block !important;

        -webkit-overflow-scrolling: touch;
      }

    }


    @media (max-width: 520px) {

      #addEditTeacherModal {
        padding: 0 !important;
      }


      #addEditTeacherModal
      .manage-class-content {
        width: 100vw !important;
        max-width: 100vw !important;

        min-height: 100dvh !important;
        max-height: 100dvh !important;

        margin: 0 !important;

        border-radius: 0 !important;
      }


      #addEditTeacherModal
      .manage-class-content
      form {
        padding:
          20px
          16px
          28px !important;
      }

    }


    /* --- STUDENT CARD FUNCTIONAL LAYOUT --- */
    @media (min-width: 769px) {
      .student-card-details {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
      }
      
      .student-card-actions {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
      }
      
      .student-card-actions .btn {
        flex: 1;
      }
      
      /* Hide mobile-specific accordion toggles on larger screens */
      .student-card-actions-toggle,
      .student-card-actions-toggle + label {
        display: none;
      }
    }
          
    
          /* House Configuration Mobile Styles */
          #houses-section .page-actions {
            flex-direction: column;
            align-items: stretch;
          }
    
          #houses-section .btn {
            width: 100%;
            text-align: left;
            justify-content: flex-start;
            font-size: 16px;
            padding: 12px;
          }
        }
    
        ::-webkit-scrollbar {
          width: 6px;
          height: 6px;
        }
    
        ::-webkit-scrollbar-track {
          background: #f1f1f1;
        }
    
        ::-webkit-scrollbar-thumb {
          background: #c1c1c1;
          border-radius: 3px;
        }
    
        ::-webkit-scrollbar-thumb:hover {
          background: #a1a1a1;
        }
    
        .overlay {
          position: fixed;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          background: rgba(0, 0, 0, 0.65);
          z-index: 1000;
          display: flex;
          justify-content: center;
          align-items: center;
        }
    
        
    
    
    /* House Points User Guide Overlay Styles */
    .housepoints-user-guide-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.6);
      z-index: 1100; /* Higher than modals (1000) and nav-bar (998) */
      display: none;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity 0.3s ease;
    }
    
    .housepoints-user-guide-overlay.show {
      display: flex;
      opacity: 1;
      pointer-events: all;
    }
    
    .housepoints-user-guide-container {
      width: 100vw;
      max-width: 1400px;
      height: 100vh;
      display: flex;
      flex-direction: column;
      background: var(--card-light);
      border-radius: 8px;
      overflow: hidden;
      border: none;
      box-shadow: none;
      position: relative;
    }
    
    .housepoints-user-guide-header {
      padding: 12px 16px;
      background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
      border-bottom: none;
      position: sticky;
      top: 0;
      z-index: 10;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    
    .housepoints-user-guide-header h2 {
      font-size: 18px;
      font-weight: 700;
      color: #fff;
      margin: 0;
      display: flex;
      align-items: center;
      gap: 8px;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    }
    
    .housepoints-user-guide-body {
      padding: 24px;
      flex: 1;
      overflow-y: auto;
      text-align: left;
    }
    
    @media (max-width: 1370px) {
      body.mobile .housepoints-user-guide-body {
        padding: 16px;
      }
      body.mobile .housepoints-user-guide-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        padding: 12px 16px !important;
      }
      body.mobile .housepoints-user-guide-header h2 {
        font-size: 13px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        margin: 0 !important;
        line-height: 1.2 !important;
      }
      body.mobile .housepoints-header-right {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        width: 100% !important;
      }
      body.mobile .housepoints-header-right .byline {
        font-size: 12px !important;
        white-space: nowrap !important;
        margin: 0 !important;
        line-height: 1.2 !important;
        color: #fff !important;
      }
      body.mobile .housepoints-header-right .byline a {
        color: #fff !important;
        text-decoration: underline !important;
      }
        body.mobile .housepoints-header-right .btn {
        align-self: flex-end !important;
        position: absolute !important;
        top: 12px !important;
        right: 16px !important;
        display: inline-flex !important;
        width: auto !important;
        padding: 4px 8px !important;
        font-size: 14px !important;
        background: none !important;
        color: var(--light-text) !important;
        border: none !important;
        box-shadow: none !important;
        font-weight: 600 !important;
      }
      body.mobile .housepoints-collapsible-content ul li {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 8px !important;
        margin-bottom: 24px !important;
      }
      body.mobile .housepoints-collapsible-content ul li i {
        font-size: 24px !important;
        margin-bottom: 8px !important;
      }
      body.mobile .housepoints-collapsible-content ul li strong {
        font-size: 15px !important; /* Slightly smaller for mobile */
        font-weight: 700 !important;
        white-space: normal !important; /* Allow wrapping */
        max-width: 90% !important; /* Match HTML inline style */
        line-height: 1.3 !important; /* Improve readability */
        overflow: visible !important; /* Prevent clipping */
        text-overflow: clip !important; /* Remove ellipsis */
        display: block !important;
      }
    body.mobile .housepoints-collapsible-content ul li span:not(.fa) {
        font-size: 13px !important;
        line-height: 1.4 !important;
        white-space: normal !important;
        max-width: 90% !important;
        overflow: visible !important;
        text-overflow: clip !important;
        display: block !important;
      }
      /* Ensure text wrapping only on mobile for specified items */
      body.mobile .housepoints-collapsible-content ul li div {
        max-width: 90% !important;
        white-space: normal !important;
        word-wrap: break-word !important;
      }
    }
    
    .housepoints-user-guide-body h3 {
      font-size: 26px;
      font-weight: 700;
      color: var(--primary-blue);
      margin-bottom: 20px;
      display: flex;
      align-items: center;
      gap: 10px;
    }
    
    .housepoints-user-guide-body h4 {
      font-size: 20px;
      color: var(--gradient-start);
      font-weight: 600;
      margin: 24px 0 16px;
    }
    
    .housepoints-user-guide-body p {
      font-size: 16px;
      line-height: 1.8;
      color: var(--dark-text);
      margin-bottom: 24px;
    }
    
    .housepoints-user-guide-body ul {
      padding-left: 0;
      font-size: 16px;
      color: var(--dark-text);
      list-style: none;
    }
    
    .housepoints-user-guide-body li {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 16px;
    }
    
    .housepoints-collapsible-btn {
      background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
      color: var(--light-text);
      padding: 14px 24px;
      font-size: 18px;
      font-weight: 700;
      border-radius: 8px;
      border: none;
      display: flex;
      justify-content: space-between;
      align-items: center;
      cursor: pointer;
      transition: all 0.2s ease;
      width: 100%;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
      text-align: left;
    }
    
    
    .housepoints-collapsible-btn:hover {
      background: linear-gradient(135deg, #0891b2, #075985);
      transform: translateY(-1px);
    }
    
    .housepoints-collapsible-btn .fa-chevron-down {
      margin-left: auto;
      transition: transform 0.3s ease;
    }
    .housepoints-collapsible-btn.active .fa-chevron-down {
      transform: rotate(180deg);
    }
    .housepoints-collapsible-content {
      transition: all 0.3s ease;
      padding: 24px;
      background: #f1f5f9;
      border-radius: 8px;
      margin-top: 6px;
      text-align: left;
      font-size: 16px;
      max-height: 0;
      overflow: hidden;
    }
    .housepoints-collapsible-content[style*="block"] {
      max-height: 1000px; /* Adjust based on content size */
    }
    
    .housepoints-collapsible-content {
      transition: all 0.3s ease;
      padding: 24px;
      background: #f1f5f9;
      border-radius: 8px;
      margin-top: 6px;
      text-align: left;
      font-size: 16px;
    }
    
    .housepoints-intro-container {
      transition: transform 0.2s ease;
    }
    
    .housepoints-intro-container:hover {
      transform: translateY(-2px);
    }
    
    
    
    
    
        .modal-header {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 20px;
          border-bottom: 1px solid var(--gray-light);
          padding-bottom: 10px;
        }
    
        
    
    
    
    
        .nav-spacer { flex-grow: 1; }
        .nav-group { position: relative; }

        .nav-item {
          background: transparent;
          color: #475569;
          padding: 9px 10px;
          border-radius: 9px;
          font-size: 12px;
          font-weight: 650;
          cursor: pointer;
          transition:
            background 0.18s ease,
            color 0.18s ease;
          display: flex;
          align-items: center;
          gap: 9px;
          box-shadow: none;
          border: 1px solid transparent;
        }

        .nav-item:hover {
          background: #f1f5f9;
          color: #0f172a;
          transform: none;
          box-shadow: none;
        }

        .nav-item.active {
          background: #eef6ff !important;
          color: #1d4ed8 !important;
          border-color: #dbeafe !important;
          box-shadow: none !important;
          font-weight: 750;
        }

        .nav-item.active i {
          color: #2563eb !important;
        }
    
        .nav-item.hod-dashboard {
          background: linear-gradient(145deg, var(--warning), #d97706);
          color: var(--light-text);
          border: 1px solid var(--warning);
        }
    
        .nav-item.hod-dashboard:hover {
          background: linear-gradient(145deg, #d97706, #b37400);
          transform: translateY(-1px);
          box-shadow: var(--shadow-md);
        }
    
    .nav-dropdown {
      display: none;
      position: absolute;
      top: 100%;
      left: 0;
      background: linear-gradient(145deg, #f1f5f9, #e5e7eb);
      border-radius: 6px;
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
      z-index: 10;
      min-width: 220px;
      border: 1px solid var(--teacher-hub-color);
      padding: 6px 0;
    }
    
    .nav-group:hover .nav-dropdown {
      display: block;
    }
    
    .nav-dropdown .nav-item {
      background: transparent;
      border: none;
      border-radius: 0;
      padding: 8px 12px;
      color: var(--dark-text);
      font-size: 11px;
      gap: 4px;
    }
    
    .nav-dropdown .nav-item:hover {
      background: var(--teacher-hub-color);
      color: #ffffff;
      transform: none;
      box-shadow: none;
    }
    
    .nav-dropdown .nav-item.get-started-guide i {
      color: var(--teacher-hub-color);
    }
    
        .form-group label {
          font-weight: 600;
          margin-bottom: 8px;
        }
    
        .form-group select,
        .form-group input {
          transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }
    
        .form-group select:focus,
        .form-group input:focus {
          border-color: var(--primary-blue);
          box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.25);
        }
    
        .error-message {
          color: var(--danger);
          font-size: 12px;
          margin-top: 4px;
          display: none;
        }
    
        @media (max-width: 1440px) {
          .main-content { padding: 0 0.5rem; }
          .card-title { font-size: 1rem; }
          .btn { padding: 0.4rem 0.6rem; font-size: 0.75rem; }
        }
    
        @media (max-width: 1366px) {
          .main-content { max-width: 100%; }
          table { font-size: 0.75rem; }
        }
    
        @media (max-width: 1024px) {
          .main-content { padding: 0 0.4rem; }
          .filters { flex-direction: column; }
        }
    
        @media (max-width: 1370px) {
          .header { padding: 0.4rem 0.8rem; }
          .logo { font-size: 1.1rem; }
          .tagline { font-size: 0.7rem; }
          table { font-size: 0.7rem; }
        }
    
        /* Prevent wrapping on desktop */
    @media (min-width: 769px) {
      .housepoints-collapsible-content ul li div {
        white-space: nowrap !important;
        max-width: none !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
      }
    }


    /* ==========================================
       DESKTOP SYSTEM SETUP HUB
       Desktop ONLY
       iPad / mobile remain unchanged
       ========================================== */
    @media (min-width: 1371px) {

      #systemSetupModal .system-setup-page-inner {
        max-width: 1600px !important;
        margin: 0 auto !important;
      }


      #systemSetupModal .system-setup-main-header {
        margin-bottom: 18px !important;
      }


      /* Main desktop shell */
      #systemSetupModal .desktop-setup-layout {
        display: grid;

        grid-template-columns:
          230px
          minmax(0, 1fr);

        gap: 22px;

        align-items: start;
      }


      /* ==========================================
         LEFT SETTINGS NAV
         ========================================== */

      #systemSetupModal .desktop-setup-nav {
        display: flex;
        flex-direction: column;

        gap: 4px;

        position: sticky;
        top: 8px;

        padding: 14px;

        background: #ffffff;

        border:
          1px solid
          #e2e8f0;

        border-radius: 18px;

        box-shadow:
          0 4px 16px
          rgba(15, 23, 42, 0.055);
      }


      #systemSetupModal .desktop-setup-nav-heading {
        padding:
          4px
          8px
          10px;

        font-size: 9px;
        font-weight: 850;

        letter-spacing: 0.9px;

        color: #94a3b8;
      }


      #systemSetupModal .desktop-setup-nav-group {
        margin:
          13px
          8px
          5px;

        font-size: 8px;
        font-weight: 850;

        letter-spacing: 0.8px;

        color: #94a3b8;
      }


      #systemSetupModal .desktop-setup-nav-item {
        width: 100%;

        display: grid;

        grid-template-columns:
          34px
          minmax(0, 1fr);

        align-items: center;

        gap: 9px;

        padding: 9px 10px;

        background: transparent;

        border:
          1px solid
          transparent;

        border-radius: 11px;

        color: #475569;

        text-align: left;

        cursor: pointer;

        transition:
          background 0.18s ease,
          border-color 0.18s ease,
          color 0.18s ease;
      }


      #systemSetupModal .desktop-setup-nav-item:hover {
        background: #f8fafc;
        border-color: #e2e8f0;
      }


      #systemSetupModal .desktop-setup-nav-item.active {
        background: #eff6ff;

        border-color: #bfdbfe;

        color: #1d4ed8;
      }


      #systemSetupModal .desktop-setup-nav-icon {
        width: 32px;
        height: 32px;

        display: flex;

        align-items: center;
        justify-content: center;

        border-radius: 9px;

        background: #f1f5f9;

        color: #64748b;

        font-size: 12px;
      }


      #systemSetupModal .desktop-setup-nav-item.active
      .desktop-setup-nav-icon {
        background: #dbeafe;
        color: #2563eb;
      }


      #systemSetupModal .desktop-setup-nav-item strong {
        display: block;

        font-size: 11px;
        line-height: 1.2;

        font-weight: 800;
      }


      #systemSetupModal .desktop-setup-nav-item small {
        display: block;

        margin-top: 2px;

        font-size: 8px;
        line-height: 1.2;

        color: #94a3b8;
      }


      /* Highlight key System Setup actions on desktop only */
      @media (min-width: 1371px) {

        /* Teacher Access - Orange */
        #systemSetupModal .desktop-setup-nav-item[data-setup-section="teacher-access"]
        .desktop-setup-nav-icon {
          background: #fef3c7;
          color: #d97706;
        }

        #systemSetupModal .desktop-setup-nav-item[data-setup-section="teacher-access"]
        strong {
          color: #b45309;
        }


        /* Import Students - Green */
        #systemSetupModal .desktop-setup-nav-item[data-setup-section="import-students"]
        .desktop-setup-nav-icon {
          background: #d1fae5;
          color: #059669;
        }

        #systemSetupModal .desktop-setup-nav-item[data-setup-section="import-students"]
        strong {
          color: #047857;
        }


        /* Houses & Awards - Purple */
        #systemSetupModal .desktop-setup-nav-item[data-setup-section="awards-houses"]
        .desktop-setup-nav-icon {
          background: #ede9fe;
          color: #7c3aed;
        }

        #systemSetupModal .desktop-setup-nav-item[data-setup-section="awards-houses"]
        strong {
          color: #6d28d9;
        }


        /* Keep the selected section clearly highlighted */
        #systemSetupModal .desktop-setup-nav-item.active {
          background: #eff6ff;
          border-color: #93c5fd;
        }

      }


      /* ==========================================
         RIGHT SETTINGS CONTENT
         ========================================== */

      #systemSetupModal .desktop-setup-content {
        min-width: 0;
      }


      #systemSetupModal .desktop-setup-panel-header {
        display: block;

        min-height: 0;

        padding:
          2px
          2px
          15px;

        margin-bottom: 14px;

        border-bottom:
          1px solid
          #e2e8f0;
      }


      #systemSetupModal .desktop-setup-panel-eyebrow {
        margin-bottom: 5px;

        font-size: 8px;
        line-height: 1;

        font-weight: 850;

        letter-spacing: 0.9px;

        color: #3b82f6;
      }


      #systemSetupModal #desktopSetupPanelTitle {
        margin: 0;

        font-size: 21px;
        line-height: 1.15;

        font-weight: 850;

        color: #0f172a;
      }


      #systemSetupModal #desktopSetupPanelDescription {
        margin:
          5px
          0
          0;

        max-width: 680px;

        font-size: 10px;
        line-height: 1.5;

        color: #64748b;
      }


      /* ==========================================
         DEFAULT: HIDE ALL DESKTOP PANELS
         ========================================== */

      #systemSetupModal .setup-wizard-card,
      #systemSetupModal .setup-cards-container,
      #systemSetupModal .import-section-container,
      #systemSetupModal #bulkBalanceSection {
        display: none !important;
      }


      /* ==========================================
         OVERVIEW
         ========================================== */

      #systemSetupModal[data-desktop-setup-section="overview"]
      .setup-wizard-card {
        display: block !important;
      }


      #systemSetupModal .setup-wizard-card {
        padding: 16px !important;

        margin-bottom: 0 !important;

        border-radius: 16px !important;

        box-shadow:
          0 3px 12px
          rgba(15, 23, 42, 0.045);
      }


      #systemSetupModal .setup-wizard-card > div:first-child {
        margin-bottom: 10px !important;
      }


      #systemSetupModal .setup-wizard-card > div:nth-child(2) {
        margin-bottom: 12px !important;
      }


      #systemSetupModal .setup-steps-container {
        display: grid !important;

        grid-template-columns:
          repeat(
            2,
            minmax(0, 1fr)
          ) !important;

        gap: 8px !important;
      }


      #systemSetupModal .setup-step-card {
        min-height: 58px;

        padding:
          8px
          10px !important;

        border-radius:
          11px !important;

        gap:
          8px !important;
      }


      #systemSetupModal .setup-step-card .step-number {
        width: 24px !important;
        height: 24px !important;

        min-width: 24px !important;

        font-size: 9px !important;
      }


      #systemSetupModal .setup-step-card .step-status {
        width: 16px !important;
        height: 16px !important;

        min-width: 16px !important;

        font-size: 7px !important;
      }


      #systemSetupModal
      .setup-step-card
      > div:nth-child(2)
      > div:first-child {
        font-size: 10px !important;

        line-height: 1.2 !important;

        font-weight: 800 !important;
      }


      #systemSetupModal
      .setup-step-card
      > div:nth-child(2)
      > div:last-child {
        margin-top: 2px !important;

        font-size: 8px !important;

        line-height: 1.25 !important;

        color: #94a3b8 !important;
      }


      #systemSetupModal #setupCompletionMessage {
        margin-top: 10px !important;
      }


      /* ==========================================
         NORMAL SETTINGS CARDS
         ========================================== */

      #systemSetupModal .setup-cards-container {
        grid-template-columns:
          repeat(
            2,
            minmax(0, 1fr)
          ) !important;

        gap: 14px !important;

        align-items: stretch !important;
      }


      #systemSetupModal
      .setup-cards-container
      > .setup-card {
        display: none !important;

        width: 100% !important;

        margin: 0 !important;

        min-height: 0 !important;
      }


      /* School Profile */
      #systemSetupModal[data-desktop-setup-section="school-profile"]
      .setup-cards-container {
        display: grid !important;
        grid-template-columns: minmax(0, 760px) !important;
      }


      #systemSetupModal[data-desktop-setup-section="school-profile"]
      #schoolBrandingCard {
        display: block !important;
      }


      /* Privacy & Data */
      #systemSetupModal[data-desktop-setup-section="privacy"]
      .setup-cards-container {
        display: grid !important;
        grid-template-columns:
          repeat(
            2,
            minmax(0, 1fr)
          ) !important;
        gap: 14px !important;
      }


      #systemSetupModal[data-desktop-setup-section="privacy"]
      #studentNamePrivacyCard,

      #systemSetupModal[data-desktop-setup-section="privacy"]
      #exportSchoolDataCard,

      #systemSetupModal[data-desktop-setup-section="privacy"]
      #systemMaintenanceCard {
        display: block !important;
      }


      #systemSetupModal[data-desktop-setup-section="privacy"]
      #systemMaintenanceCard {
        grid-column: 1 / -1 !important;
      }


      #systemSetupModal[data-desktop-setup-section="privacy"]
      #deleteSchoolAccountCard.owner-visible {
        display: block !important;
      }


      /* Awards & Houses */
      #systemSetupModal[data-desktop-setup-section="awards-houses"]
      .setup-cards-container {
        display: grid !important;

        grid-template-columns:
          minmax(0, 1fr)
          minmax(0, 1fr) !important;
      }


      #systemSetupModal[data-desktop-setup-section="awards-houses"]
      #awardReasonsCard,

      #systemSetupModal[data-desktop-setup-section="awards-houses"]
      #houseManagementCard,

      #systemSetupModal[data-desktop-setup-section="awards-houses"]
      #publicHouseBoardCard {
        display: block !important;
      }

      #systemSetupModal[data-desktop-setup-section="awards-houses"]
      #rewardsStoreActivationPanel[style*="display: block"] {
        display: block !important;
      }

      #systemSetupModal[data-desktop-setup-section="awards-houses"]
      #awardReasonsCard {
        grid-column: 1 !important;
        grid-row: 1 !important;
      }

      #systemSetupModal[data-desktop-setup-section="awards-houses"]
      #rewardsStoreActivationPanel[style*="display: block"] {
        grid-column: 1 !important;
        grid-row: 2 !important;
      }

      #systemSetupModal[data-desktop-setup-section="awards-houses"]
      #houseManagementCard {
        grid-column: 2 !important;
        grid-row: 1 / 3 !important;
      }

      #systemSetupModal[data-desktop-setup-section="awards-houses"]
      #publicHouseBoardCard {
        grid-column: 1 / -1 !important;
        grid-row: 3 !important;
      }


      #systemSetupModal[data-desktop-setup-section="awards-houses"]
      #publicHouseBoardCard {
        grid-column: 1 / -1 !important;
      }


      #publicHouseBoardCard.public-house-board-access-hidden {
        display: none !important;
      }


      /* Teacher Access - full-width desktop layout */
      #systemSetupModal[data-desktop-setup-section="teacher-access"]
      .setup-cards-container {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        width: 100% !important;
        max-width: none !important;
      }


      #systemSetupModal[data-desktop-setup-section="teacher-access"]
      #joinCodeCard {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
      }


      #systemSetupModal[data-desktop-setup-section="teacher-access"]
      #teacherAccessOnboardingPanel {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-rows: auto auto auto auto 1fr;
        column-gap: 24px;
        row-gap: 8px;
        align-items: start;
        padding: 20px !important;
      }


      #systemSetupModal[data-desktop-setup-section="teacher-access"]
      #teacherAccessOnboardingPanel[style*="display: block"] {
        display: grid !important;
      }


      #teacherAccessOnboardingPanel > div:first-child {
        grid-column: 1;
        grid-row: 1 / 6;
        height: 100%;
        padding-right: 24px;
        border-right: 1px solid #e2e8f0;
      }


      #teacherAccessOnboardingPanel > div:nth-child(2) {
        display: none !important;
      }


      #teacherAccessOnboardingPanel > div:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
        font-size: 13px !important;
      }


      #teacherAccessOnboardingPanel > div:nth-child(4) {
        grid-column: 2;
        grid-row: 2;
        margin: 0 !important;
      }


      #teacherAccessOnboardingPanel > div:nth-child(5) {
        grid-column: 2;
        grid-row: 3;
        margin-top: 8px;
      }


      #teacherAccessOnboardingPanel > div:nth-child(6) {
        grid-column: 2;
        grid-row: 4;
        margin-top: 4px !important;
      }


      #teacherAccessOnboardingPanel > div:nth-child(7) {
        grid-column: 2;
        grid-row: 5;
        margin-top: 0 !important;
        font-size: 11px;
        color: #64748b;
      }


      #teacherAccessOnboardingPanel > div:first-child > div:first-child {
        align-items: flex-start;
      }


      #teacherAccessOnboardingPanel > div:first-child > div:first-child > div:first-child > div:first-child {
        font-size: 13px !important;
      }


      #teacherAccessOnboardingPanel button {
        min-height: 38px;
        transition: background .18s ease, border-color .18s ease;
      }


      #teacherInvitationsList:empty,
      #teacherInvitationsStatus:empty {
        display: none;
      }

      /* Teacher Access - readable desktop typography */
      @media (min-width: 1371px) {
        #teacherStudentManagementPermissionPanel > div > div:first-child > div:first-child {
          font-size: 16px !important;
          font-weight: 800 !important;
        }

        #teacherStudentManagementPermissionPanel > div > div:first-child > div:nth-child(2) {
          font-size: 14px !important;
          line-height: 1.6 !important;
        }

        #teacherStudentManagementPermissionPanel > div > div:first-child > div:nth-child(3) {
          font-size: 13px !important;
          line-height: 1.5 !important;
        }
        #teacherAccessOnboardingPanel {
          font-size: 14px !important;
          line-height: 1.55 !important;
        }

        #teacherAccessOnboardingPanel > div:first-child > div:first-child > div:first-child > div:first-child,
        #teacherAccessOnboardingPanel > div:nth-child(3) {
          font-size: 16px !important;
          font-weight: 800 !important;
        }

        #teacherAccessOnboardingPanel > div:first-child > div:first-child > div:first-child > div:nth-child(2),
        #teacherAccessOnboardingPanel > div:nth-child(4) {
          font-size: 14px !important;
          line-height: 1.6 !important;
        }

        #teacherAutoApprovalStatus,
        #teacherInvitationsStatus,
        #teacherInvitationsList,
        #teacherAccessHelpText {
          font-size: 13px !important;
          line-height: 1.5 !important;
        }

        #teacherAccessOnboardingPanel button,
        #teacherAccessOnboardingPanel label {
          font-size: 13px !important;
          font-weight: 700 !important;
        }
      }


      /* ==========================================
         SECURITY & ACTIVITY LOG - DESKTOP ONLY
         ========================================== */

      .security-activity-desktop-only {
        display: none !important;
      }


      @media (min-width: 1371px) {

        .security-activity-desktop-only {
          display: block !important;
        }

      }


      /* Admin Access */
      #systemSetupModal[data-desktop-setup-section="admin-access"]
      .setup-cards-container {
        display: grid !important;

        grid-template-columns:
          minmax(0, 1fr)
          minmax(0, 1fr) !important;

        gap: 14px !important;

        align-items: start !important;
      }


      #systemSetupModal[data-desktop-setup-section="admin-access"]
      #systemAdminCard,
      #systemSetupModal[data-desktop-setup-section="admin-access"]
      #authorizedEmailsCard,
      #systemSetupModal[data-desktop-setup-section="admin-access"]
      #securityActivityLogCard {
        display: block !important;
      }


      /* School Owner: desktop only, but normal block layout */
      .school-owner-desktop-only {
        display: none !important;
      }


      @media (min-width: 1371px) {

        .school-owner-desktop-only {
          display: block !important;
          width: 100% !important;
        }

        #systemSetupModal[data-desktop-setup-section="admin-access"]
        #securityActivityLogCard {
          grid-column: 1 / -1 !important;
          max-width: none !important;
        }

      }


      /* ==========================================
         IMPORT STUDENTS
         ========================================== */

      #systemSetupModal[data-desktop-setup-section="import-students"]
      .import-section-container {
        display: grid !important;

        grid-template-columns:
          repeat(
            2,
            minmax(0, 1fr)
          ) !important;

        gap: 14px !important;

        margin-bottom: 0 !important;
      }


      #systemSetupModal
      .import-section-container
      > div {
        min-height: 0 !important;
      }


      /* ==========================================
         IMPORT STUDENTS - READABILITY
         ========================================== */

      #systemSetupModal[data-desktop-setup-section="import-students"]
      #desktopSetupPanelDescription {
        font-size: 13px !important;
        line-height: 1.55 !important;
      }


      #systemSetupModal[data-desktop-setup-section="import-students"]
      .import-section-container h4 {
        font-size: 17px !important;
        line-height: 1.3 !important;
      }


      #systemSetupModal[data-desktop-setup-section="import-students"]
      .import-section-container p {
        font-size: 13px !important;
        line-height: 1.55 !important;
      }


      #systemSetupModal[data-desktop-setup-section="import-students"]
      #googleClassroomImportCard span,
      #systemSetupModal[data-desktop-setup-section="import-students"]
      #wondeImportCard span {
        font-size: 11px !important;
        line-height: 1.5 !important;
      }


      #systemSetupModal[data-desktop-setup-section="import-students"]
      #googleClassroomConnectionStatus,
      #systemSetupModal[data-desktop-setup-section="import-students"]
      #wondeRosterPreviewStatus {
        font-size: 12px !important;
        line-height: 1.5 !important;
      }


      #systemSetupModal[data-desktop-setup-section="import-students"]
      #connectGoogleClassroomBtn,
      #systemSetupModal[data-desktop-setup-section="import-students"]
      #connectWondeBtn {
        font-size: 13px !important;
      }


      /* ==========================================
         HOUSE ASSIGNMENT
         ========================================== */

      #systemSetupModal[data-desktop-setup-section="house-assignment"]
      #bulkBalanceSection {
        display: block !important;

        margin-bottom: 0 !important;
      }


      #systemSetupModal
      #bulkBalanceSection
      .filters-stack {
        display: grid !important;

        grid-template-columns:
          repeat(
            3,
            minmax(0, 1fr)
          ) !important;

        gap: 12px !important;
      }


      #systemSetupModal
      #bulkBalanceSection
      > div:nth-of-type(2) {
        display: grid !important;

        grid-template-columns:
          repeat(
            3,
            minmax(0, 1fr)
          ) !important;

        gap: 10px !important;
      }

    }


    /* ==========================================
       MOBILE / IPAD SYSTEM SETUP NAVIGATION
       Horizontal swipe bar only
       Desktop remains untouched
       ========================================== */
    @media (max-width: 1370px) {

      #systemSetupModal .desktop-setup-layout {
        display: block;
      }


      /* Hide desktop title/description panel only */
      #systemSetupModal .desktop-setup-panel-header {
        display: none !important;
      }


      /* Reuse desktop setup navigation as mobile swipe tabs */
      #systemSetupModal .desktop-setup-nav {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;

        width: 100% !important;

        gap: 8px !important;

        margin: 0 0 18px 0 !important;
        padding: 4px 2px 10px 2px !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        white-space: nowrap !important;

        position: static !important;

        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;

        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;

        scrollbar-width: none;
      }


      #systemSetupModal .desktop-setup-nav::-webkit-scrollbar {
        display: none;
      }


      /* Desktop category labels not needed in horizontal bar */
      #systemSetupModal .desktop-setup-nav-heading,
      #systemSetupModal .desktop-setup-nav-group {
        display: none !important;
      }


      #systemSetupModal .desktop-setup-nav-item {
        flex: 0 0 auto !important;

        width: auto !important;
        min-width: max-content !important;

        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;

        gap: 7px !important;

        padding: 9px 12px !important;

        background: #ffffff !important;

        border: 1px solid #e2e8f0 !important;
        border-radius: 12px !important;

        color: #475569 !important;

        text-align: left !important;

        box-shadow:
          0 1px 3px
          rgba(15, 23, 42, 0.05) !important;

        scroll-snap-align: start;

        touch-action: manipulation;
      }


      #systemSetupModal .desktop-setup-nav-item.active {
        background: #eff6ff !important;
        border-color: #93c5fd !important;
        color: #1d4ed8 !important;
      }


      #systemSetupModal .desktop-setup-nav-icon {
        width: 27px !important;
        height: 27px !important;
        min-width: 27px !important;

        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;

        border-radius: 8px !important;

        background: #f1f5f9 !important;

        color: #64748b !important;

        font-size: 10px !important;
      }


      #systemSetupModal .desktop-setup-nav-item.active
      .desktop-setup-nav-icon {
        background: #dbeafe !important;
        color: #2563eb !important;
      }


      #systemSetupModal .desktop-setup-nav-item strong {
        display: block !important;

        font-size: 11px !important;
        line-height: 1.1 !important;
        font-weight: 800 !important;
      }


      /* Hide descriptions inside horizontal tabs */
      #systemSetupModal .desktop-setup-nav-item small {
        display: none !important;
      }


      /* ==========================================
         MOBILE / IPAD SETUP TAB CONTENT
         Only show the selected section
         ========================================== */

      /* Hide all main setup content by default */
      #systemSetupModal.mobile-setup-tabs
      .setup-wizard-card,

      #systemSetupModal.mobile-setup-tabs
      .setup-cards-container,

      #systemSetupModal.mobile-setup-tabs
      .import-section-container,

      #systemSetupModal.mobile-setup-tabs
      #bulkBalanceSection {
        display: none !important;
      }


      /* OVERVIEW */
      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="overview"]
      .setup-wizard-card {
        display: block !important;
      }


      /* SCHOOL PROFILE */
      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="school-profile"]
      .setup-cards-container {
        display: block !important;
      }

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="school-profile"]
      .setup-cards-container
      > .setup-card {
        display: none !important;
      }

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="school-profile"]
      #schoolBrandingCard {
        display: block !important;
      }


      /* PRIVACY */
      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="privacy"]
      .setup-cards-container {
        display: block !important;
      }

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="privacy"]
      .setup-cards-container
      > .setup-card {
        display: none !important;
      }

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="privacy"]
      #studentNamePrivacyCard,

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="privacy"]
      #exportSchoolDataCard,

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="privacy"]
      #systemMaintenanceCard {
        display: block !important;
      }


      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="privacy"]
      #deleteSchoolAccountCard.owner-visible {
        display: block !important;
      }


      /* TEACHER ACCESS */
      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="teacher-access"]
      .setup-cards-container {
        display: block !important;
      }

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="teacher-access"]
      .setup-cards-container
      > .setup-card {
        display: none !important;
      }

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="teacher-access"]
      #joinCodeCard {
        display: block !important;
      }

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="teacher-access"]
      #teacherAccessOnboardingPanel[style*="display: block"] {
        display: block !important;
      }


      /* ADMIN ACCESS */
      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="admin-access"]
      .setup-cards-container {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 16px !important;
      }

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="admin-access"]
      .setup-cards-container
      > .setup-card {
        display: none !important;
      }

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="admin-access"]
      #systemAdminCard,

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="admin-access"]
      #authorizedEmailsCard {
        display: block !important;
      }


      /* HOUSES & AWARDS */
      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="awards-houses"]
      .setup-cards-container {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 16px !important;
      }

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="awards-houses"]
      .setup-cards-container
      > .setup-card {
        display: none !important;
      }

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="awards-houses"]
      #awardReasonsCard,

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="awards-houses"]
      #houseManagementCard,

      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="awards-houses"]
      #publicHouseBoardCard {
        display: block !important;
      }


      #systemSetupModal.mobile-setup-tabs
      #publicHouseBoardCard.public-house-board-access-hidden {
        display: none !important;
      }


      /* IMPORT STUDENTS */
      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="import-students"]
      .import-section-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
      }


      /* HOUSE ASSIGNMENT */
      #systemSetupModal.mobile-setup-tabs[data-desktop-setup-section="house-assignment"]
      #bulkBalanceSection {
        display: block !important;
      }

    }


    /* ==========================================
       HOUSE DETAIL - IPAD AND PHONE LAYOUT
       ========================================== */
    @media (max-width: 1370px) {

      /* Stack Top Classes and Top Students panels */
      #expandedHouseView .house-v2-body > div:last-child {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 16px !important;
      }

      /* Student name above class.
         Class name above percentage. */
      #expandedHouseView .house-v2-body > div:last-child
      > div > div:nth-child(2) > div > div:nth-child(2) {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        flex-wrap: nowrap !important;
        gap: 4px !important;
        min-width: 0 !important;
      }

      /* Allow full names to wrap instead of being cut off */
      #expandedHouseView .house-v2-body > div:last-child
      > div > div:nth-child(2) > div > div:nth-child(2)
      > div:first-child {
        max-width: 100% !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        overflow-wrap: anywhere !important;
        line-height: 1.3 !important;
      }

      /* Keep class and percentage information readable */
      #expandedHouseView .house-v2-body > div:last-child
      > div > div:nth-child(2) > div > div:nth-child(2)
      > div:nth-child(2) {
        white-space: normal !important;
        line-height: 1.35 !important;
        color: #475569 !important;
      }
    }

    /* ==========================================
       HOUSE DETAIL - TOP TEACHER MOBILE
       ========================================== */

    @media (max-width: 780px) {

      #expandedHouseView #houseTopTeacherCard {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 16px !important;
        border-radius: 16px !important;
        box-sizing: border-box !important;
      }

      /* Teacher information must fill the card */
      #expandedHouseView
      .house-top-teacher-result {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        padding: 16px !important;
        min-width: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
      }

      /* Hide rank 1 because only one winner is shown */
      #expandedHouseView
      .house-top-teacher-result
      > div:first-child {
        display: none !important;
      }

      /* Main information area */
      #expandedHouseView
      .house-top-teacher-result
      > div:nth-child(2) {
        width: 100% !important;
        min-width: 0 !important;
        text-align: center !important;
      }

      /* Teacher name */
      #expandedHouseView
      .house-top-teacher-result
      > div:nth-child(2)
      > div:first-child {
        font-size: 19px !important;
        font-weight: 900 !important;
        line-height: 1.3 !important;
        color: #0f172a !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        overflow-wrap: anywhere !important;
      }

      /* Statistics container */
      #expandedHouseView
      .house-top-teacher-result
      > div:nth-child(2)
      > div:nth-child(2) {
        margin-top: 14px !important;
        font-size: 12px !important;
        white-space: normal !important;
        overflow: visible !important;
      }

      /* Hide desktop sentence only on phones */
      #expandedHouseView
      .house-top-teacher-desktop-activity {
        display: none !important;
      }

      /* Three clear statistic boxes */
      #expandedHouseView
      .house-top-teacher-mobile-stats {
        display: grid !important;
        grid-template-columns:
          repeat(3, minmax(0, 1fr)) !important;
        gap: 7px !important;
        width: 100% !important;
      }

      #expandedHouseView
      .house-top-teacher-mobile-stats > div {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 5px !important;

        min-width: 0 !important;
        padding: 12px 5px !important;

        background: #ffffff !important;
        border: 1px solid #d1fae5 !important;
        border-radius: 11px !important;
        box-sizing: border-box !important;
      }

      #expandedHouseView
      .house-top-teacher-mobile-stats strong {
        font-size: 20px !important;
        line-height: 1.1 !important;
        font-weight: 900 !important;
        color: #047857 !important;
      }

      #expandedHouseView
      .house-top-teacher-mobile-stats span {
        font-size: 10px !important;
        font-weight: 700 !important;
        line-height: 1.3 !important;
        color: #475569 !important;
        text-align: center !important;
        white-space: normal !important;
      }

      /* Full-width points badge */
      #expandedHouseView
      .house-top-teacher-result
      > div:last-child {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;

        width: 100% !important;
        min-width: 0 !important;
        min-height: 46px !important;

        padding: 12px !important;

        border-radius: 11px !important;
        background: #059669 !important;
        color: #ffffff !important;

        white-space: normal !important;
        box-sizing: border-box !important;
      }

      #expandedHouseView
      .house-top-teacher-result
      > div:last-child span {
        font-size: 16px !important;
        font-weight: 900 !important;
        color: #ffffff !important;
      }

      /* Hide the floating award button while
         House Details is open */
      body:has(#expandedHouseView.show)
      #awardPointsFloatingBtn,
      body:has(#expandedHouseView.show)
      #awardPointsButton {
        display: none !important;
      }

    }

    /* ==========================================
       HOUSE DETAIL V2 - MOBILE
       ========================================== */
    @media (max-width: 780px) {

      .house-detail-v2 {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        overflow-x: hidden !important;
      }


      /* Sticky header */
      .house-v2-sticky-header {
        background: #ffffff !important;
        box-shadow: 0 3px 14px rgba(15, 23, 42, 0.08) !important;
      }


      .house-v2-header-main {
        grid-template-columns: 36px minmax(0, 1fr) auto !important;
        gap: 7px !important;
        padding: 9px 10px 10px !important;
      }


      /* Previous */
      .house-v2-header-main > button:first-child {
        width: 36px !important;
        height: 36px !important;
        min-height: 36px !important;
        padding: 0 !important;
        border-radius: 10px !important;
        font-size: 13px !important;
      }


      /* House identity */
      .house-v2-identity {
        justify-content: flex-start !important;
        gap: 8px !important;
        min-width: 0 !important;
        overflow: hidden !important;
      }


      .house-v2-identity > div:first-child {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        border-radius: 11px !important;
      }


      .house-v2-identity > div:nth-child(2) {
        min-width: 0 !important;
      }


      .house-v2-identity > div:nth-child(2) > div:first-child {
        gap: 5px !important;
        flex-wrap: nowrap !important;
      }


      .house-v2-identity > div:nth-child(2) > div:first-child > div:first-child {
        font-size: 17px !important;
        line-height: 1.05 !important;
        letter-spacing: -0.25px !important;
        max-width: 105px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
      }


      .house-v2-identity span {
        padding: 2px 6px !important;
        font-size: 9px !important;
      }


      .house-v2-identity > div:nth-child(2) > div:last-child {
        margin-top: 2px !important;
        font-size: 8.5px !important;
        max-width: 130px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
      }


      /* Next + Close */
      .house-v2-header-main > div:last-child {
        gap: 4px !important;
      }


      .house-v2-header-main > div:last-child button {
        width: 34px !important;
        height: 34px !important;
        min-height: 34px !important;
        padding: 0 !important;
        border-radius: 10px !important;
        font-size: 12px !important;
      }


      /* Main body */
      .house-v2-body {
        padding: 10px 10px 26px !important;
        gap: 10px !important;
      }


      /* Summary */
      .house-v2-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 7px !important;
      }


      .house-v2-summary-card {
        min-width: 0 !important;
        padding: 10px !important;
        border-radius: 12px !important;
        gap: 7px !important;
      }


      /* Hide Current Badge summary on mobile.
         The badge is shown again in House Achievement below. */
      .house-v2-summary-card:nth-child(3) {
        display: none !important;
      }


      .house-v2-summary-card > div:first-child {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        border-radius: 9px !important;
        font-size: 15px !important;
      }


      .house-v2-summary-card:nth-child(3) > div:first-child {
        font-size: 19px !important;
      }


      .house-v2-summary-card > div:nth-child(2) {
        min-width: 0 !important;
      }


      .house-v2-summary-card > div:nth-child(2) > div:first-child {
        font-size: 16px !important;
        line-height: 1 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
      }


      .house-v2-summary-card > div:nth-child(2) > div:last-child {
        font-size: 7px !important;
        letter-spacing: 0.3px !important;
        white-space: nowrap !important;
      }


      /* Achievement */
      .house-v2-milestone {
        padding: 13px !important;
        border-radius: 15px !important;
      }


      .house-v2-milestone > div:first-child {
        display: grid !important;
        grid-template-columns: auto minmax(0, 1fr) !important;
        align-items: center !important;
        gap: 10px !important;
      }


      .house-v2-milestone > div:first-child > div:first-child {
        display: contents !important;
      }


      .house-v2-milestone > div:first-child > div:first-child > div:first-child {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        border-radius: 13px !important;
        font-size: 27px !important;
      }


      .house-v2-milestone > div:first-child > div:first-child > div:nth-child(2) {
        min-width: 0 !important;
      }


      .house-v2-milestone > div:first-child > div:first-child > div:nth-child(2) > div:first-child {
        font-size: 8px !important;
      }


      .house-v2-milestone > div:first-child > div:first-child > div:nth-child(2) > div:nth-child(2) {
        font-size: 17px !important;
        line-height: 1.15 !important;
        white-space: normal !important;
      }


      .house-v2-milestone > div:first-child > div:first-child > div:nth-child(2) > div:nth-child(3) {
        font-size: 9px !important;
      }


      /* Certificate = compact beside progress bar */
      .house-v2-milestone > div:first-child > button {
        grid-column: 2 !important;

        width: auto !important;
        min-width: max-content !important;

        min-height: 32px !important;

        justify-content: center !important;

        margin-top: 0 !important;

        padding:
          7px
          10px !important;

        align-self: end !important;

        font-size: 10px !important;
      }


      .house-v2-milestone > div:nth-child(2) {
        margin-top: 12px !important;
        padding-top: 12px !important;
      }


      /* Captains and lower cards */
      .house-v2-body > div:nth-child(3) {
        padding: 13px !important;
        border-radius: 15px !important;
      }


      /* Top Classes + Top Students */
      .house-v2-body > div:last-child {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
      }


      .house-v2-body > div:last-child > div {
        min-width: 0 !important;
        padding: 13px !important;
        border-radius: 15px !important;
      }

    }
    
    
    .housepoints-user-guide-header{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:12px;
    }
    
    .housepoints-header-right{
      display:flex;
      align-items:center;
      gap:12px;           /* space between byline and Close */
    }
    
    .housepoints-header-right .byline{
      margin:0;
      font-size:14px;
      color:#fff;
      opacity:.9;
      white-space:nowrap; /* keeps it on one line */
    }
    
    .housepoints-header-right .byline a{
      color:#fff;
      text-decoration:underline;
    }
    
    #awardHistoryTable th {
      background: var(--primary-blue);
      color: var(--light-text);
      padding: 12px 16px;
      font-size: 14px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }
    #awardHistoryTable td {
      padding: 12px 16px;
      font-size: 13px;
      border-bottom: 1px solid var(--gray-light);
    }
    #awardHistoryTable tr:hover td {
      background: rgba(30, 58, 138, 0.1);
    }
    #awardHistoryTable tbody tr:last-child td {
      border-bottom: none;
    }
    
    .category-title {
      font-size: 12px;
      font-weight: 600;
      color: var(--primary-blue);
      padding: 8px 12px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      border-radius: var(--radius-sm);
      transition: var(--transition);
    }
    
    /* Dynamically assign colors based on data-category-index */
    .category-title[data-category-index="0"] { background: var(--category-color-1); }
    .category-title[data-category-index="1"] { background: var(--category-color-2); }
    .category-title[data-category-index="2"] { background: var(--category-color-3); }
    .category-title[data-category-index="3"] { background: var(--category-color-4); }
    .category-title[data-category-index="4"] { background: var(--category-color-5); }
    .category-title[data-category-index="5"] { background: var(--category-color-6); }
    .category-title[data-category-index="6"] { background: var(--category-color-7); }
    .category-title[data-category-index="7"] { background: var(--category-color-8); }
    
    .category-title:hover {
      opacity: 0.9;
    }
    
    
    
    @keyframes fadeInScale {
      0% { opacity: 0; transform: scale(0.8); }
      100% { opacity: 1; transform: scale(1); }
    }
    .ticker-item.winner {
      box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
      border: 2px solid gold;
    }
    
    
    
    .announcement-content {
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 14px;
      font-weight: 600;
      color: #334155;
      width: 92%;
      max-width: 1400px;
      min-width: 0;
      overflow: hidden;

      /* Fade text gently at both edges */
      -webkit-mask-image: linear-gradient(
        to right,
        transparent 0%,
        black 3%,
        black 97%,
        transparent 100%
      );
      mask-image: linear-gradient(
        to right,
        transparent 0%,
        black 3%,
        black 97%,
        transparent 100%
      );
    }

    .announcement-icon {
      font-size: 16px;
      color: #d97706;
      opacity: 0.9;
    }
    #announcementText {
      white-space: nowrap;
      display: inline-block;
      padding-left: 10px;
    }
    #announcementText .text-content {
      display: inline-block;
      padding-right: 40px; /* Adds space before the loop repeats */
    }
    .announcement-title {
      font-weight: 800;
      color: #92400e;
      margin-right: 6px;
      text-transform: none;
    }
    .announcement-content.scrolling #announcementText {
      animation: marquee var(--animation-duration, 60s) linear infinite;
    }
    .announcement-content:hover #announcementText {
      animation-play-state: paused;
    }
    
    /* Desktop Default */
    .announcement-item {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 12px;
      padding: 12px;
      background: #ffffff;
      border: 1px solid #e2e8f0;
      border-radius: 12px;
      box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    }

    /* 📱 SMARTPHONE STACK: Title and Text on their own rows */
    @media (max-width: 780px) {
      .announcement-item {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        padding: 16px !important;
      }

      /* Title Input - Full Width */
      .announcement-title-input {
        width: 100% !important;
        font-weight: 800 !important;
      }

      /* Text Input - Full Width */
      .announcement-text {
        width: 100% !important;
      }

      /* Points & Delete - Side by side at the bottom */
      .announcement-points-input {
        width: 100% !important;
      }
      
      /* Create a wrapper row for points and delete if they look too big alone */
      .announcement-item .btn-danger {
        width: 100% !important;
        height: 44px !important;
      }
    }
    .announcement-text {
      flex: 1;
    }
    .announcement-title-input {
      flex: 0.5;
      min-width: 120px;
    }
    @media (max-width: 1370px) {
      .announcement-bar {
        padding: 8px 12px;
      }
      .announcement-content {
        font-size: 14px;
      }
      .announcement-icon {
        font-size: 16px;
      }
      .announcement-content.scrolling #announcementText {
        animation: marquee 32s linear infinite;
      }
      .announcement-title {
        font-size: 13px;
      }
    }
    @media (max-width: 480px) {
      .announcement-content {
        font-size: 12px;
      }
      .announcement-icon {
        font-size: 14px;
      }
      .announcement-content.scrolling #announcementText {
        animation: marquee 24s linear infinite;
      }
      .announcement-title {
        font-size: 11px;
      }
    }
    
    
    .hero-progress-container {
      position: relative;
      margin-top: 6px;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 2px;
      width: 100%;
    }
    .hero-milestone-badge {
      display: flex;
      align-items: center;
      gap: 8px;
      background: linear-gradient(135deg, #ffd700, #fffacd, #d4a017);
      color: var(--dark-text);
      font-size: 24px;
      font-weight: 800;
      padding: 10px 20px;
      border-radius: 999px;
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), 0 0 12px rgba(255, 215, 0, 0.5);
      border: 2px solid #fffacd;
      z-index: 2;
      width: fit-content; /* Ensure badge width is content-based */
    }
    
    /* Specific style for full-screen mode individual house pages */
    .leaderboard-fullscreen .hero-house-card .hero-milestone-badge {
      font-size: 28px; /* Increased by 40% from 20px (20 * 1.4 = 28) */
      padding: 11.2px 22.4px; /* Increased by 40% from 8px 16px (8 * 1.4 = 11.2, 16 * 1.4 = 22.4) */
      width: fit-content; /* Maintain content-based width */
      max-width: 420px; /* Increased by 40% from 300px (300 * 1.4 = 420) */
      border-radius: 999px; /* Maintain pill shape */
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 10px rgba(255, 215, 0, 0.6);
    }
    
    .leaderboard-fullscreen .hero-milestone-badge {
      font-size: 28.8px; /* 20% larger than 24px */
      padding: 12px 24px; /* Scaled up 20% */
    }
    .hero-milestone-badge.animate-flip {
      animation: flipGlow 1.2s ease-out;
    }
    @keyframes flipGlow {
      0% { transform: perspective(400px) rotateY(90deg); opacity: 0; box-shadow: 0 0 0 rgba(255, 215, 0, 0); }
      50% { transform: perspective(400px) rotateY(0deg); opacity: 1; box-shadow: 0 0 20px rgba(255, 215, 0, 0.7); }
      100% { transform: perspective(400px) rotateY(0deg); opacity: 1; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), 0 0 12px rgba(255, 215, 0, 0.5); }
    }
    .hero-progress {
      height: 32px !important; /* Taller bar */
      background: var(--gray-light) !important;
      border-radius: 16px !important; /* Proportional rounded ends */
      overflow: hidden;
      position: relative;
      width: 100%;
      max-width: 800px;
    }
    .hero-progress-fill {
      height: 100% !important;
      background: linear-gradient(90deg, var(--house-color, #1e40af), #60a5fa) !important;
      transition: width 0.6s ease;
    }
    .hero-progress-fill.animate-fill {
      animation: fillBar 1.2s ease-out;
    }
    @keyframes fillBar {
      0% { width: 0%; opacity: 0.7; }
      50% { opacity: 1; }
      100% { opacity: 1; }
    }
    .hero-milestone-current-icon {
      position: absolute;
      left: 8px;
      top: 50%;
      transform: translateY(-50%);
      font-size: 18px !important; /* Slightly larger for taller bar */
      color: var(--dark-text) !important;
      z-index: 2;
    }
    .hero-milestone-next {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      font-size: 24px !important; /* Larger for balance with earned badge */
      font-weight: 700 !important;
      color: var(--dark-text) !important;
      background: rgba(255,255,255,0.85) !important; /* Slightly stronger opacity */
      border-radius: 999px !important;
      padding: 8px 18px !important; /* Larger padding */
      opacity: 0.6 !important;
      z-index: 2;
      display: flex;
      align-items: center;
      gap: 8px !important;
      box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important; /* Stronger shadow */
    }
    .hero-milestone-next.unlocked {
      opacity: 1 !important;
      background: linear-gradient(135deg, #ffd700, #fffacd) !important;
      box-shadow: 0 6px 16px rgba(0,0,0,0.3), 0 0 12px rgba(255,215,0,0.5) !important; /* Match earned badge */
    }
    .hero-milestone-next.maxed {
      font-size: 24px !important;
      font-weight: 800 !important;
      color: #ffd700 !important;
      background: linear-gradient(135deg, #ffd700, #fffacd) !important;
      padding: 8px 18px !important;
      border-radius: 999px !important;
      box-shadow: 0 6px 16px rgba(0,0,0,0.3), 0 0 12px rgba(255,215,0,0.5) !important;
      opacity: 1 !important;
    }
    .hero-confetti {
      position: absolute;
      top: -20px;
      left: 0;
      width: 100%;
      height: 60px;
      pointer-events: none;
      z-index: 3;
    }
    .hero-confetti.animate {
      animation: confettiBurst 1.5s ease-out;
    }
    @keyframes confettiBurst {
      0% {
        background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="10" cy="10" r="4" fill="%23ff4444"/><circle cx="20" cy="20" r="4" fill="%23ffeb3b"/><rect x="30" y="30" width="8" height="8" fill="%2300f"/><circle cx="40" cy="40" r="4" fill="%23ffeb3b"/></svg>') repeat;
        opacity: 1;
        transform: translateY(0);
      }
      100% {
        opacity: 0;
        transform: translateY(-30px);
      }
    }
    @media (max-width: 1370px) {
      .hero-milestone-badge {
        font-size: 20px;
        padding: 8px 16px;
      }
      .hero-progress {
        height: 24px;
        border-radius: 12px;
        max-width: 100%;
      }
      .hero-milestone-current-icon {
        font-size: 14px;
        left: 6px;
      }
      .hero-milestone-next {
        font-size: 16px;
        padding: 3px 10px;
        right: 6px;
      }
    }
    @media (max-width: 480px) {
      .hero-milestone-badge {
        font-size: 18px;
        padding: 6px 12px;
      }
      .hero-progress {
        height: 20px;
        border-radius: 10px;
      }
      .hero-milestone-current-icon {
        font-size: 12px;
        left: 4px;
      }
      .hero-milestone-next {
        font-size: 14px;
        padding: 2px 8px;
        right: 4px;
      }
    }
    
    .hero-milestone-current {
      position: absolute;
      left: 8px;
      top: 50%;
      transform: translateY(-50%);
      font-size: 16px;
      color: var(--dark-text);
      z-index: 2;
    }
    .hero-milestone-next {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      font-size: 22px; /* Larger for balance with earned badge */
      font-weight: 700; /* Bolder for prominence */
      color: var(--dark-text);
      background: rgba(255,255,255,0.8); /* Semi-transparent white */
      border-radius: 999px;
      padding: 6px 16px; /* Larger padding */
      opacity: 0.6; /* Faded until unlocked */
      z-index: 2;
      display: flex;
      align-items: center;
      gap: 8px; /* Slightly larger gap */
      box-shadow: 0 2px 8px rgba(0,0,0,0.15); /* Subtle shadow for premium look */
    }
    .hero-milestone-next.maxed {
      color: #ffd700;
      opacity: 1; /* Full opacity when maxed */
      font-weight: 800;
    }
    .hero-confetti {
      position: absolute;
      top: -20px;
      left: 0;
      width: 100%;
      height: 60px;
      pointer-events: none;
      z-index: 3;
    }
    .hero-confetti.animate {
      animation: confettiBurst 1.5s ease-out;
    }
    @keyframes confettiBurst {
      0% {
        background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="10" cy="10" r="4" fill="%23ff4444"/><circle cx="20" cy="20" r="4" fill="%23ffeb3b"/><rect x="30" y="30" width="8" height="8" fill="%2300f"/><circle cx="40" cy="40" r="4" fill="%23ffeb3b"/></svg>') repeat;
        opacity: 1;
        transform: translateY(0);
      }
      100% {
        opacity: 0;
        transform: translateY(-30px);
      }
    }
    @media (max-width: 1370px) {
      .hero-milestone-badge {
        font-size: 20px;
        padding: 8px 16px;
      }
      .hero-progress {
        height: 24px; /* Slightly thinner for tablet */
        border-radius: 12px;
        max-width: 100%;
      }
      .hero-milestone-current {
        font-size: 14px;
        left: 6px;
      }
      .hero-milestone-next {
        font-size: 22px;
        padding: 4px 8px;
        right: 6px;
      }
    }
    @media (max-width: 480px) {
      .hero-milestone-badge {
        font-size: 18px;
        padding: 6px 12px;
      }
      .hero-progress {
        height: 20px; /* Thinner for mobile */
        border-radius: 10px;
      }
      .hero-milestone-current {
        font-size: 12px;
        left: 4px;
      }
      .hero-milestone-next {
        font-size: 18px;
        padding: 3px 6px;
        right: 4px;
      }
    }
    
    .leaderboard-fullscreen.show .leaderboard-brand img {
      display: none;
    }
    
    
    
    
    
    .hero-head {
      display: flex;
      flex-direction: column;
      gap: 8px;
      position: relative; /* Make .hero-head the positioning context for absolute badge */
    }
    .hero-rank-badge {
  position: absolute;
  right: -10px;
  top: -10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  padding: 0 24px;
  border-radius: 999px;

  background:
    linear-gradient(
      135deg,
      var(--house-color, #1e40af),
      rgba(255, 255, 255, 0.72)
    );

  color: #1e293b;

  font-size: 48px;
  font-weight: 900;

  border:
    3px solid
    var(--house-color, #1e40af);

  text-shadow:
    0 1px 1px
    rgba(255, 255, 255, 0.45);

  box-shadow:
    0 4px 12px
    rgba(0, 0, 0, 0.3);

  animation:
    gentle-pulse
    2s
    ease-in-out
    infinite;
}
    @media (max-width: 1370px) {
      .hero-rank-badge {
        height: 84px;
        padding: 0 28px;
        font-size: 40px;
        border: 3px solid var(--house-color, #1e40af);
        right: -10px; /* Maintain 10px offset */
        top: 6px; /* Adjust for mobile */
      }
    }
    
    
    
    .hero-gap-gauge {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-top: 20px; /* Increased from 12px to move slightly downward */
      width: fit-content;
      padding: 10px 16px;
      background: rgba(255, 255, 255, 0.9);
      border-radius: 8px;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
      font-size: 18px;
      font-weight: 600;
      color: var(--dark-text);
    }
    .hero-gap-gauge.leader {
      background: linear-gradient(135deg, #ffd700, #fffacd);
      color: var(--dark-text);
      font-weight: 700;
    }
    .hero-gap-gauge-text {
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .hero-gap-message {
      display: block;
      width: fit-content;
      max-width: 100%;

      padding: 12px 20px;

      background: rgba(255,255,255,0.2);

      border-radius: 40px;

      font-weight: 700;

      font-size:
        clamp(14px, 1.7vw, 28px);

      line-height: 1.15;

      color: var(--house-display-color, var(--house-color, #1e40af));

      white-space: nowrap;

      overflow: hidden;

      box-sizing: border-box;
    }
    .hero-gap-gauge-bar {
      height: 8px;
      background: var(--gray-light);
      border-radius: 4px;
      overflow: hidden;
    }
    .hero-gap-gauge-fill {
      height: 100%;
      background: var(--house-color, #1e40af);
      transition: width 0.6s ease;
    }
    @media (max-width: 1370px) {
      .hero-gap-gauge {
        font-size: 14px;
        padding: 8px 12px;
      }
      .hero-gap-gauge-bar {
        height: 6px;
      }
    }
    
    
    
    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 8px 24px;
      background: rgba(255,255,255,0.98);
      border-bottom: 1px solid #e2e8f0;
      height: 60px;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      z-index: 1000;
      box-shadow: 0 1px 3px rgba(15,23,42,0.06);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
    }

    .header::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 24px;
      right: 24px;
      height: 1px;
      background: linear-gradient(
        90deg,
        transparent,
        rgba(16,185,129,0.7),
        transparent
      );
    }
    
    
    
    
    @media (max-width: 1370px) {
      /* GLOBAL CENTERING FOR ALL MOBILE CARDS */
      .student-card-header {
        display: flex;
        flex-direction: column;
        align-items: center; /* Centers items horizontally */
        text-align: center;   /* Centers text lines */
        justify-content: center;
        width: 100%;
      }
    
      /* REFINED COLLAPSED NAME FOR LARGE ICON */
      #students-section .student-card.collapsed .student-card-name {
        font-size: 13px !important;
        font-weight: 800 !important;
        line-height: 1.1 !important;
        margin-top: 4px !important;
        padding: 0 8px !important;
        color: #0f172a !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-align: center;
        width: 100%;
      }
    
      #studentsList .student-card.collapsed .student-card-house,
      #studentsList .student-card.collapsed .student-card-class {
        font-size: 9px !important;
      }
    
      /* Bigger ID in Collapsed View as requested */
      #studentsList .student-card.collapsed .student-card-header span[style*="font-family: monospace"] {
        font-size: 11px !important;
        padding: 2px 5px !important;
        font-weight: 800 !important;
        color: #334155 !important;
      }
    
      /* --- NOT COLLAPSED (EXPANDED) STATE --- */
      #studentsList .student-card.expanded .student-card-name {
        font-size: 24px !important; /* Significant increase */
        font-weight: 900 !important;
        margin-bottom: 8px;
        color: var(--primary-blue);
      }
    
      #studentsList .student-card.expanded .student-card-house {
        font-size: 18px !important; /* Much bigger for readability */
        font-weight: 700 !important;
      }
    
      #studentsList .student-card.expanded .student-card-class {
        font-size: 16px !important;
        margin-bottom: 10px;
      }
    
      /* Centered ID Label and Tag in Expanded View */
      #studentsList .student-card.expanded .student-card-header div[style*="display: flex"] {
        justify-content: center !important; 
        margin-top: 8px !important;
      }
    
      #studentsList .student-card.expanded .student-card-header span[style*="font-family: monospace"] {
        font-size: 14px !important; /* Bigger ID in Expanded view */
        padding: 3px 8px !important;
      }
    }
    
    
    @media (max-width: 1370px) {
      .header::after {
        height: 1px; /* Thinner on mobile */
      }
    }
    
    @media (max-width: 1370px) {
      /* --- GLOBAL APP SHELL FIXES --- */
      .header { padding: 6px 12px; height: 48px; }
      .logo { font-size: 1.1rem; }
      .logo-pe { font-size: 0.9rem; padding: 1px 3px; }
      .app-container { grid-template-columns: 1fr; padding-top: 48px; }
      body.mobile .main-content { padding-top: 0; margin-top: 44px; }
      
      /* --- HEADER ACTIONS: TABLET (781px to 1370px) --- */
      .header-actions { display: flex; gap: 6px; align-items: center; }
      
      /* Reset buttons to show text on iPads */
      .header-actions .btn { 
        padding: 6px 10px !important; 
        min-height: 34px !important; 
        width: auto !important; 
        text-indent: 0 !important; 
        overflow: visible !important; 
        display: flex !important; 
        align-items: center; 
        justify-content: center; 
      }
      
      .header-actions .btn .btn-text { 
        display: inline !important; 
        font-size: 11px;
        font-weight: 700;
      }
    
      /* HIDE OLD DROPDOWNS: Relocating to the Standings card */
      .header-term-filter,
      #dashboard-section .page-actions .filter-group.desktop-only,
      #termFilterDropdown {
        display: none !important;
      }
    
      /* --- HEADER ACTIONS: MOBILE LOCKDOWN (780px and below) --- */
      @media (max-width: 780px) {
        /* Apply squish ONLY to buttons that don't have .always-show-text */
        .header-actions .btn:not(.always-show-text) { 
          padding: 0 !important; 
          width: 32px !important; 
          height: 32px !important;
          text-indent: -9999px !important; 
          overflow: hidden !important; 
        }
        .header-actions .btn:not(.always-show-text) i { 
          font-size: 14px; 
          text-indent: 0; 
          margin: 0; 
        }
        .header-actions .btn:not(.always-show-text) .btn-text { 
          display: none !important; 
        }
        .trackedu-logo-header { display: none !important; }
        .logo-inline { gap: 0 !important; }
      }
    
      /* NEW: Style for the Inline Standings Select */
      .inline-term-select {
        font-size: 10px !important;
        font-weight: 800 !important;
        height: 24px !important;
        padding: 0 20px 0 8px !important;
        border-radius: 6px !important;
        background-color: #f1f5f9 !important;
        border: 1px solid #cbd5e1 !important;
        color: var(--primary-blue) !important;
        width: auto !important;
        text-transform: uppercase;
        appearance: none;
        -webkit-appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e40af' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
        background-repeat: no-repeat !important;
        background-position: right 6px center !important;
        background-size: 10px !important;
      }
      
      /* HIDE DESKTOP ELEMENTS */
      #dashboard-section .page-actions .filter-group,
      #students-section .page-actions .filter-group { display: none !important; }
      #students-section .page-header { padding: 0 12px; }
      #students-section .page-title { display: flex; justify-content: space-between; align-items: center; margin: 0; gap: 8px; }
      #students-section .page-title h1 { font-size: 1.2rem; line-height: 1.5; margin: 0; }
      #students-section .page-title .btn.mobile-only { width: 50px; height: 32px; padding: 4px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
      #students-section .page-title .btn.mobile-only i { margin: 0; }
    
      /* --- SWIMLANE GROUP SYSTEM --- */
      #students-section #studentsList {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        padding: 10px 0 120px 0 !important;
        background: transparent;
      }
      
      .house-group-header {
        background: white;
        border-radius: 12px;
        padding: 14px 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 4px 10px rgba(0,0,0,0.05);
        border: 1px solid #e2e8f0;
        cursor: pointer;
        transition: all 0.2s ease;
        border-left: 6px solid var(--group-color, #64748b);
        margin-bottom: 8px;
      }
      
      .house-group-header:active { transform: scale(0.98); }
      .house-group-title { font-size: 16px; font-weight: 800; color: #1e293b; display: flex; align-items: center; gap: 10px; }
      .house-group-count { background: #f1f5f9; color: #64748b; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
      .house-chevron { font-size: 14px; color: #94a3b8; transition: transform 0.3s ease; }
      .house-group-header.active .house-chevron { transform: rotate(180deg); }
      .house-group-grid { display: none; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 4px 0 12px 0; width: 100%; box-sizing: border-box; padding-right: 2px; }
      .house-group-grid.show { display: grid; }


      /* UNASSIGNED - neutral holding area, not a real House */
      .unassigned-group {
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        padding: 8px;
      }

      .unassigned-group .house-group-header {
        background: #f1f5f9;
        border-color: #dbe2ea;
        border-left-color: #94a3b8;
        box-shadow: none;
      }

      .unassigned-group .house-group-title {
        color: #64748b;
      }

      .unassigned-group .house-group-count {
        background: #e2e8f0;
        color: #64748b;
      }

      .unassigned-group .house-group-pts {
        color: #94a3b8;
      }

      .unassigned-group .house-chevron {
        color: #94a3b8;
      }

      .unassigned-group .house-group-grid {
        opacity: 0.78;
      }

      .unassigned-group .student-card {
        background: #f8fafc !important;
        border-color: #e2e8f0 !important;
        box-shadow: 0 2px 6px rgba(15,23,42,0.04) !important;
      }

      .unassigned-group .student-card-name {
        color: #475569 !important;
      }

      .unassigned-group .hero-shield {
        border-color: #94a3b8 !important;
        background: #f1f5f9 !important;
        box-shadow: 0 5px 10px rgba(15,23,42,0.08) !important;
      }
    
      #students-section .student-card.collapsed .student-card-header {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 2px;
        height: 100%;
        text-align: center;
        gap: 2px;
      }
      
      /* Hide student ID in collapsed state */
      #students-section .student-card.collapsed .hero-id-tag,
      #students-section .student-card.collapsed .student-id-badge {
        display: none !important;
      }
    
      .hero-shield {
        width: 65px !important;
        height: 65px !important;
        background: white !important;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 32px !important;
        margin: 0 auto 10px auto !important;
        box-shadow: 0 8px 15px rgba(0,0,0,0.15), 0 0 0 4px white;
        border: 3px solid var(--house-color) !important;
        z-index: 2;
      }
    
      .hero-id-tag { display: none !important; }
      .xp-bar-container { width: 100%; height: 8px; background: #f1f5f9; border-radius: 4px; margin: 8px 0; overflow: hidden; position: relative; border: 1px solid #e2e8f0; }
      .xp-bar-fill { height: 100%; background: linear-gradient(90deg, #4ade80, #22c55e); width: var(--xp-percent, 0%); transition: width 0.5s ease; }
    
      .student-card.selected { border-color: #10b981 !important; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.4); transform: scale(0.95); background: #ecfdf5; }
      #students-section .student-card.expanded { padding: 12px 14px !important; grid-column: 1 / -1 !important; transform: scale(1.02) !important; background: linear-gradient(to bottom, #ffffff 45%, var(--house-color) 150%); box-shadow: 0 20px 40px rgba(0,0,0,0.2) !important; border: 3px solid var(--house-color) !important; z-index: 10 !important; margin: 12px 0 !important; }


      /* ==========================================
         UNASSIGNED STUDENT CARDS
         Must come AFTER normal student-card styles
         ========================================== */

      #students-section .house-group-section[data-house="Unassigned"] .student-card,
      #students-section .house-group-section[data-house="Unassigned"] .student-card.collapsed,
      #students-section .house-group-section[data-house="Unassigned"] .student-card.expanded {
        background: #eef2f6 !important;
        background-image: none !important;

        border-color: #cbd5e1 !important;

        box-shadow:
          0 2px 5px rgba(15,23,42,0.035) !important;
      }

      #students-section .house-group-section[data-house="Unassigned"] .student-card-name {
        color: #64748b !important;
      }

      #students-section .house-group-section[data-house="Unassigned"] .hero-shield {
        background: #e2e8f0 !important;
        border-color: #94a3b8 !important;

        box-shadow:
          0 4px 10px rgba(15,23,42,0.06) !important;
      }

      #students-section .house-group-section[data-house="Unassigned"] .collapsed-points-pill {
        background: #e2e8f0 !important;
        color: #64748b !important;

        border-color: #cbd5e1 !important;

        box-shadow: none !important;
      }

      #students-section .house-group-section[data-house="Unassigned"] .expansion-indicator {
        background: #e2e8f0 !important;
        color: #94a3b8 !important;
        border-color: #cbd5e1 !important;
      }


      #students-section .student-card.expanded .student-card-header { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 8px !important; width: 100%; }
      #students-section .student-card.expanded .hero-shield { width: 80px; height: 80px; font-size: 40px; margin-bottom: 10px; }
      #students-section .student-card.expanded .student-card-name { color: #1e293b; font-size: 24px !important; font-weight: 900; margin-bottom: 4px; }
    
      #students-section .student-card.expanded .hero-id-tag { color: #000000 !important; font-weight: 600 !important; font-size: 14px !important; background: #f1f5f9; padding: 6px 14px; border-radius: 6px; margin-top: 5px; border: 1px solid #cbd5e1; letter-spacing: 1px; }
    
      .xp-stats { display: flex; justify-content: space-between; width: 100%; font-size: 14px; color: #64748b; font-weight: 600; margin-top: 4px; }
      .student-card.collapsed .student-card-details, .student-card.collapsed .student-card-actions, .student-card.collapsed .expanded-badge-name, .student-card.collapsed .xp-stats, .student-card.collapsed .xp-bar-container { display: none; }
      .student-card.collapsed .hero-shield, .student-card.collapsed .hero-house-tag { display: flex; }
      .student-card.expanded .student-card-details, .student-card.expanded .student-card-actions, .student-card.expanded .expanded-badge-name, .student-card.expanded .xp-stats, .student-card.expanded .xp-bar-container { display: block; }
      .student-card.expanded .hero-shield, .student-card.expanded .hero-house-tag { display: none; }
    
      .mobile-dropdown-row { display: flex; gap: 10px; margin-bottom: 0 !important; }
      .mobile-dropdown-row > div { flex: 1; }
      #students-section .student-card-actions .points-edit-buttons { display: flex; gap: 10px; }
      #students-section .student-card-actions .btn { flex: 1; padding: 12px; font-size: 16px; }
    
      body.mobile #dashboard-section { padding: 1px 12px !important; }
      body.mobile #dashboard-section .page-header { margin: 0 !important; }
      body.mobile #dashboard-section .card:has(#houseOverview) { margin-top: 1px !important; margin-bottom: 12px !important; }
      body.mobile #dashboard-section .page-actions { margin: 0 !important; padding: 0 !important; }
      #dashboard-section .card { margin-top: 0 !important; }
    }
    
    
    @media (min-width: 769px) {
      .header-actions .btn {
        padding: 6px 10px;
        font-size: 12px;
      }
      .header-actions .btn i {
        font-size: 12px;
        margin-right: 4px;
      }
      .header-actions .btn .btn-text {
        display: inline;
      }
      .header-actions .header-term-filter {
        display: none !important;
      }
      #students-section .page-actions .btn.desktop-only {
        width: 100px;
        height: 36px;
        padding: 6px;
        font-size: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      #students-section .page-actions .btn.desktop-only i {
        font-size: 14px;
        margin-right: 6px;
      }
      #students-section .page-title .btn.mobile-only {
        display: none !important;
      }
    }
    @media (max-width: 480px) {
      .header {
        padding: 4px 8px;
      }
      .logo {
        font-size: 1rem;
      }
      .logo-pe {
        font-size: 0.85rem;
      }
      .header-actions .btn {
        padding: 3px;
        min-height: 28px;
        width: 28px;
      }
      .header-actions .btn i {
        font-size: 13px;
      }
      .header-actions .header-term-filter .form-control {
        font-size: 11px;
        padding: 3px;
        height: 28px;
        min-width: 70px;
        max-width: 100px;
      }
      #students-section .page-title .btn {
        padding: 3px 6px;
        font-size: 11px;
      }
      #students-section .page-title .btn i {
        font-size: 11px;
      }
    }
    
    
    
    .nav-bar {
      display: flex;
      justify-content: space-between;
      gap: 6px;
      flex-direction: row;
      align-items: center;
      background: linear-gradient(145deg, #e6f0fa, #bfdbfe);
      padding: 8px 20px;
      border-radius: 0;
      box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
      border: 1px solid var(--gray);
      z-index: 998;
      width: 100%;
      position: fixed;
      top: 48px; /* Adjusted to new header height */
      left: 0;
    }
    
    .announcement-bar {
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 9px 20px;
      background: #fffdf5;
      border-bottom: 1px solid #fde68a;
      box-shadow: 0 1px 2px rgba(15,23,42,0.04);
      position: fixed;
      top: 48px;
      left: 0;
      width: 100%;
      z-index: 998;
      overflow: hidden;
      animation: none;
    }
    
    
    
    
    .announcement-points-input {
      flex: 0.3;
      min-width: 80px;
    }
    .leaderboard-announcement-bar .announcement-points {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #ff6b6b, #ff8e53);
      color: #fff;
      font-weight: 200;
      font-size: 24px;
      padding: 4px 12px;
      border-radius: 999px;
      margin-left: 12px;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    }
    @media (max-width: 1370px) {
      .leaderboard-announcement-bar .announcement-points {
        font-size: 18px;
        padding: 3px 10px;
      }
    }
    @media (max-width: 480px) {
      .leaderboard-announcement-bar .announcement-points {
        font-size: 14px;
        padding: 2px 8px;
      }
    }
    
    .sidebar-logo {
      padding: 4px 12px 0;
      text-align: center;
      margin-bottom: 2px;
    }

.sidebar-logo .logo-normal {
  width: 68px;
  height: 68px;
  display: block;
  background: #ffffff;
  border: none;
  border-radius: 50%;
  padding: 0;
  object-fit: cover;
  object-position: center;
  box-shadow: none;
  overflow: hidden;
}


.sidebar-logo-edit-wrap {
  position: relative;

  width: fit-content;

  margin: 0 auto;
}


.sidebar-logo-edit-btn {
  position: absolute;

  top: -6px;
  right: -18px;

  width: 30px;
  height: 30px;

  align-items: center;
  justify-content: center;

  padding: 0;

  border:
    1px solid
    #dbeafe;

  border-radius: 50%;

  background: #ffffff;

  color: #2563eb;

  font-size: 11px;

  cursor: pointer;

  box-shadow:
    0 3px 10px
    rgba(15,23,42,0.15);

  transition:
    transform 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease;

  z-index: 5;
}


.sidebar-logo-edit-btn:hover {
  transform: scale(1.08);

  background: #2563eb;

  color: #ffffff;

  box-shadow:
    0 5px 14px
    rgba(37,99,235,0.25);
}

    .sidebar-logo img {
      transition: transform 0.18s ease;
    }

    .sidebar-logo img:hover {
      transform: scale(1.03);
      box-shadow: none;
    }
    
    @media (max-width: 1024px) {
      .sidebar-logo {
        display: none;
      }
    }
    
    
    /* Sidebar (Normal Mode) */
    .logo-normal {
  width: 82px;
  height: 82px;
  object-fit: contain;
  object-position: center center;
  display: block;
  margin: 4px auto 6px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  animation: none;
  padding: 4px;
  box-sizing: border-box;
  overflow: visible;
}
    
    /* Fullscreen Mode */
    .logo-fullscreen {
  width: 80px;
  height: 80px;
  border-radius: 0;
  object-fit: contain;
  object-position: center;
  margin: 0;
  padding: 3px;
  background: transparent;
  overflow: visible;
  animation: float 3s ease-in-out infinite;
}
    
    
    .hero-captain-banner {
      font-size: 18px;
      font-weight: 700;
      padding: 14px 16px;
      border-radius: 10px;
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
      width: 100%;
      overflow: hidden;
    }
    .hero-captain-label {
      font-size: 13px;
      font-weight: 600;
      color: #fff;
      text-transform: uppercase;
      letter-spacing: 1px;
      background: linear-gradient(135deg, rgba(139, 183, 255, 0.9), rgba(59, 130, 246, 0.7));
      padding: 4px 10px;
      border-radius: 6px;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      margin-bottom: 8px;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
      font-family: 'Inter', sans-serif;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .hero-captain-label::before {
      content: '👑'; /* Crown icon for premium feel */
      font-size: 14px;
    }
    .hero-captain-banner {
      font-size: 18px;
      font-weight: 700;
      padding: 14px 16px;
      border-radius: 10px;
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
      width: 100%;
      overflow: hidden;
    }
    .hero-captain-banner-text {
      white-space: normal;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2; /* Allow up to 2 lines */
      line-clamp: 2;
      -webkit-box-orient: vertical;
    }
    
    .hero-captain-banner-text::before {
      content: '💬 ';
      font-size: 28px; /* Increased from 20px to 28px for proportionality */
      margin-right: 8px;
    }
    @media (max-width: 1370px) {
      .hero-captain-label {
        font-size: 12px;
        padding: 3px 8px;
        margin-bottom: 6px;
      }
      .hero-captain-label::before {
        font-size: 12px;
      }
      .hero-captain-banner {
        font-size: 16px;
        padding: 12px;
      }
      .hero-captain-banner-text::before {
        font-size: 16px;
      }
      .hero-captain-banner-text {
        -webkit-line-clamp: 1;
        line-clamp: 1; /* standard property for broader compatibility */
      }
    }
    @media (max-width: 480px) {
      .hero-captain-label {
        font-size: 11px;
        padding: 3px 6px;
      }
      .hero-captain-label::before {
        font-size: 11px;
      }
      .hero-captain-banner {
        font-size: 14px;
        padding: 10px;
      }
      .hero-captain-banner-text::before {
        font-size: 14px;
      }
    }
    
    .leaderboard-fullscreen.show .hero-house-card .hero-progress {
      margin-top: 16px; /* Reduced to align with content moved down */
    }
    .leaderboard-fullscreen.show .hero-house-card .hero-points {
      margin-top: 8px; /* Unchanged, keeps points slightly below progress bar */
    }
    
    .hero-identity {
      display: flex;
      align-items: center;
      gap: 20px;
      margin-top: 40px;
      flex-direction: row;
      min-width: 0;
      width: 100%;
    }
    
    /* Adjusts the name specifically when inside the side-by-side container */
    .hero-identity .hero-name {
      margin: 0;
      line-height: 1;
      flex: 1 1 auto;
      min-width: 0;
      max-width: 100%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    
    
    
    
    
    
    
    #badgesInfoModal {
      background: rgba(0, 0, 0, 0.65);
      z-index: 1100; /* Above other modals (1000) */
      display: none;
      opacity: 0;
      transition: opacity 0.3s ease;
    }
    #badgesInfoModal.show {
      display: flex;
      opacity: 1;
      pointer-events: all;
    }
    #badgesInfoModal .house-expanded-content {
      width: 100vw;
      max-width: none;
      height: 100vh;
      max-height: none;
      border-radius: 0; /* Remove curved edges */
    }
    .badge-item {
      background: var(--card-light);
      border-radius: var(--radius-md);
      padding: 16px;
      margin-bottom: 16px;
      box-shadow: var(--shadow-sm);
    }
    @media (max-width: 1370px) {
      #badgesInfoModal .house-expanded-content {
        width: 100vw;
        max-width: none;
        height: 100vh;
        max-height: none;
        border-radius: 0;
      }
      .badges-info-content {
        padding: 16px;
      }
      .badge-item h3 {
        font-size: 20px;
      }
      .badge-item p {
        font-size: 16px;
        margin: 6px 0 0 30px;
      }
    
      
    }
    @media (max-width: 480px) {
      .badge-item h3 {
        font-size: 18px;
      }
      .badge-item p {
        font-size: 14px;
        margin: 4px 0 0 28px;
      }
      .badges-info-content ul {
        font-size: 14px;
      }
    }
    
    
    /* --- HOW IT WORKS LIST FIX --- */
    .badges-info-content ul {
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
        padding-left: 0;
        list-style: none;
    }
    
    .badges-info-content li {
        display: flex !important;
        flex-direction: row !important; /* Force side-by-side icon and text */
        align-items: flex-start !important; /* Align to top of text */
        text-align: left !important;
        gap: 15px !important;
        margin-bottom: 20px !important;
        width: 100%;
    }
    
    .badges-info-content li i {
        font-size: 20px !important;
        color: var(--success);
        margin-top: 4px; /* Slight offset to center with first line of text */
        flex-shrink: 0; /* Prevent icon from squishing */
    }
    
    .badges-info-content li div {
        flex: 1;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }
    
    /* Specific override for the iPad/Tablet range */
    @media (max-width: 1370px) {
        body.mobile #badgesInfoModal .badges-info-content > div[style*="margin-top: 24px"] ul li {
            display: flex !important;
            flex-direction: row !important;
            text-align: left !important;
            align-items: flex-start !important;
        }
    
        body.mobile #badgesInfoModal .badges-info-content > div[style*="margin-top: 24px"] ul li i {
            margin: 4px 0 0 0 !important; /* Reset auto margins */
        }
    }
    
    .milestone-timeline {
      display: grid;
      grid-template-columns: repeat(5, 1fr); /* 5 badges per row */
      grid-template-rows: repeat(2, auto); /* 2 rows for 10 badges */
      gap: 8px;
      padding: 8px;
      margin: 0 auto;
      background: var(--card-light);
      border-radius: 12px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.1);
      width: 100%;
      max-width: 1400px;
    }
    
    .milestone-step {
      background: var(--light);
      border-radius: 12px;
      padding: 12px;
      display: flex;
      align-items: center;
      gap: 4px;
      border-left: 4px solid var(--milestone-color);
      box-shadow: 0 2px 6px rgba(0,0,0,0.1);
      transition: transform 0.2s ease, box-shadow 0.2s ease;
      min-height: 80px;
      width: 100%;
    }
    .milestone-icon {
      width: 29px; /* Slightly increased from 22px */
      height: 29px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px; /* Reduced from 20px for balance */
      background: var(--milestone-color);
      color: var(--dark-text);
      flex-shrink: 0;
    }
    .milestone-title {
      font-size: 14px; /* Reduced from 14px for compactness */
      font-weight: 700;
      color: var(--dark-text);
      white-space: normal;
      line-height: 1.3;
    }
    .milestone-caption {
      font-size: 12px; /* Reduced from 11px for hierarchy */
      color: var(--gray);
      white-space: normal;
      line-height: 1.4;
    }
    @media (max-width: 1370px) {
      
      .milestone-icon {
        width: 20px;
        height: 20px;
        font-size: 16px;
      }
      .milestone-title {
        font-size: 12px;
      }
      .milestone-caption {
        font-size: 9px;
      }
    body.mobile #badgesInfoModal .badges-info-content > div[style*="margin-top: 24px"] h3 {
        text-align: left;
      }
    
      body.mobile #badgesInfoModal .badges-info-content > div[style*="margin-top: 24px"] {
        width: 100%;
        margin-left: auto;
        margin-right: auto;
        padding: 0 16px; /* Match .badges-info-content padding */
        box-sizing: border-box;
      }
    
      body.mobile #badgesInfoModal .badges-info-content > div[style*="margin-top: 24px"] ul {
        padding-left: 0; /* Override inline padding-left: 20px */
        text-align: left; /* Center text */
        width: 100%;
        margin: 0 auto;
      }
    
      body.mobile #badgesInfoModal .badges-info-content > div[style*="margin-top: 24px"] ul li {
        display: block; /* Override inline display: flex */
        text-align: left; /* Center text */
        width: 100%;
        margin-bottom: 16px; /* Slightly increase for spacing */
        padding: 0 8px; /* Add padding for readability */
        box-sizing: border-box;
        line-height: 1.5; /* Improve text wrapping */
      }
    
      body.mobile #badgesInfoModal .badges-info-content > div[style*="margin-top: 24px"] ul li i {
        display: block; /* Place icon above text */
        margin: 0 auto 8px; /* Center icon and add spacing */
        font-size: 24px; /* Slightly larger for visibility */
      }
    
      body.mobile #badgesInfoModal .badges-info-content > div[style*="margin-top: 24px"] ul li strong {
        display: inline; /* Ensure strong text wraps naturally */
        font-weight: 700;
      }
    
      
      
      body.mobile #badgesInfoModal .badges-info-content .milestone-step,
      body.mobile #badgesInfoModal .badges-info-content .student-badge-item {
        transition: transform 0.3s ease;
      }
      body.mobile #badgesInfoModal .badges-info-content .milestone-step:hover,
      body.mobile #badgesInfoModal .badges-info-content .milestone-step:active,
      body.mobile #badgesInfoModal .badges-info-content .student-badge-item:hover,
      body.mobile #badgesInfoModal .badges-info-content .student-badge-item:active {
        transform: scale(1.3) !important; /* Override inline transform */
        z-index: 10; /* Ensure zoomed badge is above others */
        box-shadow: 0 12px 24px rgba(0,0,0,0.3); /* Enhance shadow for depth */
      }
    
    
      body.mobile #badgesInfoModal .house-badges .house-badge-cta {
        display: none;
      }
    
      body.mobile #badgesInfoModal .house-badge-item {
        pointer-events: none; /* Disable clicking/tapping */
        cursor: default; /* Remove pointer cursor */
      }
      
    }
    @media (max-width: 480px) {
      .milestone-timeline {
        grid-template-columns: repeat(5, 1fr); /* Maintain 5 per row */
        gap: 4px;
        padding: 4px;
      }
      .milestone-step {
        padding: 8px;
        min-height: 60px;
      }
      .milestone-icon {
        width: 18px;
        height: 18px;
        font-size: 14px;
      }
      .milestone-title {
        font-size: 11px;
      }
      .milestone-caption {
        font-size: 8px;
      }
    }
    
    
    
    
    
    
    .milestone-step:hover {
      transform: scale(1.05);
      box-shadow: 0 4px 12px rgba(0,0,0,0.2), 0 0 8px rgba(255,215,0,0.3);
    }
    
    
    
    .milestone-label {
      flex: 1;
      min-width: 0; /* Prevent overflow */
       max-width: 100; /* Prevent overflow */
    }
    
    
    
    
    @keyframes pulseGradient {
      0% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
      100% { background-position: 0% 50%; }
    }
    .milestone-connector::before,
    .milestone-connector::after {
      content: '▶';
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      font-size: 10px;
      color: var(--gray);
    }
    .milestone-connector::before {
      left: 0;
    }
    .milestone-connector::after {
      right: 0;
    }
    .house-badges {
      background: #e6f0ff;
      padding: 16px;
      border-radius: 10px;
      box-shadow: 0 3px 10px rgba(0,0,0,0.08);
      margin-top: 24px;
    }
    .house-badges > div#houseBadgesList {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 12px;
      background: transparent; /* Keep cards white */
    }
    @media (max-width: 1200px) {
      .house-badges > div#houseBadgesList {
        grid-template-columns: repeat(3, 1fr);
      }
    }
    @media (max-width: 1370px) {
      .house-badges > div#houseBadgesList {
        grid-template-columns: repeat(2, 1fr);
      }
    }
    @media (max-width: 480px) {
      .house-badges > div#houseBadgesList {
        grid-template-columns: 1fr;
      }
    }
    div[style*="margin-top: 24px"] {
      background: #f9fafb;
      padding: 16px;
      border-radius: 10px;
      box-shadow: 0 3px 8px rgba(0,0,0,0.05);
    }
    
    
    .badges-info-content {
      padding: 16px;
      overflow-y: auto;
      height: 100%; /* Use full height of parent */
      display: flex;
      flex-direction: column;
      gap: 16px;
    }
    
    .house-badge-item {
      background: var(--card-light);
      border-radius: 12px;
      padding: 12px;
      display: flex;
      align-items: center;
      gap: 12px;
      box-shadow: 0 2px 6px rgba(0,0,0,0.1);
      transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    .house-badge-cta {
      font-size: 12px;
      color: var(--gray);
      font-style: italic;
      text-align: center;
      margin-top: 8px;
    }
    
    .student-badges {
      background: #f1f5f9;
      padding: 16px;
      border-radius: 10px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.1);
      margin-top: 24px;
    }
    
    .student-badges > div#studentBadgesList {
      background: transparent;
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      gap: 12px;
      padding: 12px;
      margin: 0 auto;
      justify-items: center;
    }
    @media (max-width: 1200px) {
      .student-badges > div#studentBadgesList { grid-template-columns: repeat(4, 1fr); }
    }
    
    /* Force edge-to-edge on mobile for Rewards page */
@media (max-width: 1370px) {
  /* Target the modal content itself */
  #badgesInfoModal .house-expanded-content {
    padding: 0 !important;
    margin: 0 !important;
    width: 100vw !important;
    overflow-x: hidden !important;
  }
  
  /* Remove padding from badges info content */
  .badges-info-content {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
  
  /* Add padding to the introductory text paragraph */
  .badges-info-content > p {
    padding: 0 16px !important;
    margin: 16px 0 !important;
    display: block !important;
    width: auto !important;
    box-sizing: border-box !important;
  }
  
  /* Also target any h3 or text elements at the top */
  .badges-info-content h3 {
    padding: 0 16px !important;
    margin: 20px 0 12px 0 !important;
    box-sizing: border-box !important;
  }
  
  /* Force student badges container with tiny gap */
  .student-badges {
    padding: 0 8px !important; /* Tiny gap on left and right */
    margin: 0 !important;
    background: transparent !important;
    width: 100% !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
  }
  
  /* Student badges list - edge to edge grid */
  .student-badges > div#studentBadgesList {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    background: transparent !important;
  }
  
  /* Individual badge cards */
  .student-badge-item {
    padding: 12px 4px !important;
    min-height: 85px !important;
    gap: 6px !important;
    width: 100% !important;
    flex-direction: column !important;
    text-align: center;
    border-radius: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    border-right: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
  }
  
  /* Remove right border from 3rd column */
  .student-badge-item:nth-child(3n) {
    border-right: none !important;
  }
  
  /* House badges section also edge-to-edge */
  .house-badges {
    padding: 0 8px !important; /* Tiny gap on left and right */
    margin: 16px 0 0 0 !important;
    border-radius: 0 !important;
  }
  
  /* House badges header text */
  .house-badges h3 {
    padding: 0 8px !important;
    margin: 20px 0 12px 0 !important;
  }



  
  .student-badge-emoji {
    font-size: 28px !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 auto !important;
  }
  
  .student-badge-name {
    font-size: 11px !important;
    font-weight: 800 !important;
    line-height: 1.2;
    display: block;
    width: 100%;
    white-space: normal !important;
  }
  
  .student-badge-points {
    display: inline-block !important;
    font-size: 10px !important;
    padding: 3px 8px !important;
    margin-top: 5px !important;
    border-radius: 12px !important;
    background: rgba(0, 0, 0, 0.25) !important;
    color: white !important;
    font-weight: 800 !important;
    text-align: center !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
  
  /* Fix the ecosystem info cards section */
  .badges-info-content > div[style*="margin-top: 40px"] {
    padding: 0 16px !important;
    margin: 40px 0 0 0 !important;
    box-sizing: border-box !important;
  }
  
  /* How It Works grid cards */
  .badges-info-content > div[style*="display: grid"] {
    padding: 0 16px !important;
    margin: 20px 0 !important;
    box-sizing: border-box !important;
  }
  
  /* Footer button */
  #rewardsFooterBtn {
    padding: 20px 16px !important;
    margin: 0 !important;
    text-align: center !important;
  }
}
  
  /* iPads/Tablets (768px to 1370px): 2 columns side by side */
  @media (min-width: 768px) and (max-width: 1370px) {
    .house-badges > div#houseBadgesList {
      display: grid !important;
      grid-template-columns: repeat(2, 1fr) !important; /* 2 columns on iPad */
      gap: 0 !important;
      padding: 0 !important;
      margin: 0 !important;
      width: 100% !important;
    }
    
    .house-badge-item {
      border-radius: 0 !important;
      margin: 0 !important;
      padding: 16px !important;
      border-right: 1px solid #e2e8f0 !important;
      border-bottom: 1px solid #e2e8f0 !important;
    }
    
    /* Remove right border from 2nd column */
    .house-badge-item:nth-child(2n) {
      border-right: none !important;
    }
  }
  
  /* Mobile phones (below 768px): 1 column */
  @media (max-width: 767px) {
    .house-badges > div#houseBadgesList {
      display: grid !important;
      grid-template-columns: 1fr !important; /* 1 column on mobile */
      gap: 0 !important;
      padding: 0 !important;
      margin: 0 !important;
      width: 100% !important;
    }
    
    .house-badge-item {
      border-radius: 0 !important;
      margin: 0 !important;
      padding: 16px !important;
      border-bottom: 1px solid #e2e8f0 !important;
      border-right: none !important;
    }
  }

/* Extra small phones: 2 columns */
@media (max-width: 480px) {
  .student-badges > div#studentBadgesList {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .student-badge-item:nth-child(2n) {
    border-right: none !important;
  }
  
  .student-badge-item:nth-child(3n) {
    border-right: 1px solid rgba(255, 255, 255, 0.15) !important;
  }
  
  .student-badge-item {
    min-height: 80px !important;
    padding: 10px 4px !important;
  }
  
  .student-badge-emoji {
    font-size: 24px !important;
    width: 36px !important;
    height: 36px !important;
  }
  
  .student-badge-name {
    font-size: 10px !important;
  }
  
  .student-badge-points {
    font-size: 9px !important;
    padding: 2px 6px !important;
  }
  
  /* Adjust text padding for very small screens */
  .badges-info-content > p {
    padding: 0 12px !important;
  }
  
  .badges-info-content > div[style*="margin-top: 40px"] {
    padding: 0 12px !important;
  }
  
  .badges-info-content > div[style*="display: grid"] {
    padding: 0 12px !important;
  }
}
    
    @media (max-width: 480px) {
      /* On very small phones, keep 2 per row but shrink even more */
      .student-badges > div#studentBadgesList {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
      }
      
      .student-badge-item {
        transform: scale(0.85) !important; /* Uniform reduction */
        margin: -2px; /* Pull them together slightly */
      }
    }
    
    
    
    .student-badge-item {
      background: var(--badge-color, linear-gradient(135deg, #e6e6e6, #c0c0c0));
      border-radius: 12px;
      padding: 12px;
      display: flex;
      align-items: center;
      gap: 8px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.15);
      transition: transform 0.3s ease, box-shadow 0.3s ease;
      width: 100%;
      max-width: 100%;
      min-height: 48px;
      box-sizing: border-box;
    }
    .student-badge-item:hover {
      transform: scale(1.05);
      box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    }
    @media (max-width: 1370px) {
      .student-badge-item {
        padding: 10px;
        min-height: 44px;
      }
      .student-badge-emoji {
        font-size: 24px;
        width: 32px;
        height: 32px;
      }
      .student-badge-name {
        font-size: 14px;
      }
      .student-badge-points {
        font-size: 12px;
        padding: 2px 6px;
      }
    }
    .student-badge-item.bronze {
      border: 1.71px solid #CD7F32;
      border-style: solid;
      box-shadow: 0 2.565px 6.84px rgba(0,0,0,0.15);
    }
    .student-badge-item.silver {
      border: 1.71px double #C0C0C0;
    }
    .student-badge-item.gold {
      border: 2.565px ridge #FFD700;
    }
    .student-badge-item.diamond {
      border: 3.42px outset #00E5FF;
    }
    .student-badge-item:hover {
      transform: scale(1.1); /* Increased for more noticeable hover */
      box-shadow: 0 10.26px 23.94px rgba(0,0,0,0.3);
      animation-play-state: paused; /* Pause animation on hover */
    }
    @keyframes zoom-in-out {
      0% { transform: scale(1); }
      50% { transform: scale(1.05); }
      100% { transform: scale(1); }
    }
    @keyframes pop {
      0% { transform: scale(0.72675); } /* Reduced by 10% from 0.8075 */
      50% { transform: scale(0.9405); } /* Reduced by 10% from 1.045 */
      100% { transform: scale(0.855); } /* Reduced by 10% from 0.95 */
    }
    @keyframes shimmer {
      0% { background-position: 0% 50%; box-shadow: 0 3.42px 10.26px rgba(0,0,0,0.2), 0 0 10.26px rgba(192,192,192,0.5); } /* Reduced by 10% */
      50% { background-position: 100% 50%; box-shadow: 0 3.42px 10.26px rgba(0,0,0,0.2), 0 0 17.1px rgba(192,192,192,0.7); } /* Reduced by 10% */
      100% { background-position: 0% 50%; box-shadow: 0 3.42px 10.26px rgba(0,0,0,0.2), 0 0 10.26px rgba(192,192,192,0.5); } /* Reduced by 10% */
    }
    @keyframes pulse {
      0% { box-shadow: 0 5.13px 13.68px rgba(0,0,0,0.25), 0 0 13.68px rgba(255,215,0,0.6); } /* Reduced by 10% */
      50% { box-shadow: 0 6.84px 17.1px rgba(0,0,0,0.3), 0 0 20.52px rgba(255,215,0,0.8); } /* Reduced by 10% */
      100% { box-shadow: 0 5.13px 13.68px rgba(0,0,0,0.25), 0 0 13.68px rgba(255,215,0,0.6); } /* Reduced by 10% */
    }
    @keyframes glow-pulse {
      0% { box-shadow: 0 6.84px 17.1px rgba(0,0,0,0.3), 0 0 17.1px rgba(0,229,255,0.7); } /* Reduced by 10% */
      50% { box-shadow: 0 8.55px 20.52px rgba(0,0,0,0.35), 0 0 27.36px rgba(0,229,255,0.9); } /* Reduced by 10% */
      100% { box-shadow: 0 6.84px 17.1px rgba(0,0,0,0.3), 0 0 17.1px rgba(0,229,255,0.7); } /* Reduced by 10% */
    }
    
    .student-badge-emoji.creative-star::after {
      content: '✨';
      position: absolute;
      top: -5.13px; /* Reduced by 10% from -5.7px */
      right: -5.13px; /* Reduced by 10% from -5.7px */
      font-size: 15.39px; /* Reduced by 10% from 17.1px */
      opacity: 0.7;
    }
    .student-badge-emoji.trailblazer::after {
      content: '🔥';
      position: absolute;
      top: -5.13px; /* Reduced by 10% from -5.7px */
      right: -5.13px; /* Reduced by 10% from -5.7px */
      font-size: 15.39px; /* Reduced by 10% from 17.1px */
      opacity: 0.7;
    }
    .student-badge-emoji {
      font-size: 34.2px;
      width: 41.04px;
      height: 41.04px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #ffffff;
      border-radius: 50%;
      box-shadow: 0 2.565px 6.84px rgba(0,0,0,0.3);
    }
    .student-badge-name {
      font-size: 15.39px;
      font-weight: 900;
      color: #ffffff;
      text-shadow: 0 1.71px 3.42px rgba(0,0,0,0.5);
    }
    .student-badge-points {
      font-size: 11.97px;
      font-weight: 800;
      color: #ffffff;
      padding: 3.42px 8.55px;
      border-radius: 5.13px;
      text-shadow: 0 1.71px 3.42px rgba(0,0,0,0.5);
      background: linear-gradient(135deg, #8B4513, #A0522D); /* Default bronze gradient - will be overridden by JS */
    }
    .badge-confetti {
      position: absolute;
      top: -30px;
      left: 0;
      width: 100%;
      height: 80px;
      background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="10" cy="10" r="5" fill="%23ff4444"/><circle cx="20" cy="20" r="5" fill="%23ffeb3b"/><rect x="30" y="30" width="10" height="10" fill="%2300f"/><circle cx="40" cy="40" r="5" fill="%23ffeb3b"/></svg>') repeat;
      opacity: 0;
      pointer-events: none;
      animation: confettiBurst 1.8s ease-out;
    }
    @keyframes confettiBurst {
      0% { opacity: 1; transform: translateY(0); }
      100% { opacity: 0; transform: translateY(-40px); }
    }
    @media (max-width: 1370px) {
      .badges-info-content {
        padding: 12px;
      }
      .student-badges {
        padding: 12px;
      }
      .student-badge-item {
        padding: 12px;
      }
      .student-badge-item.bronze { transform: scale(0.8); }
      .student-badge-item.silver { transform: scale(0.9); }
      .student-badge-item.gold { transform: scale(0.95); }
      .student-badge-item.diamond { transform: scale(1.1); }
      .student-badge-emoji {
        font-size: 36px;
        width: 44px;
        height: 44px;
      }
      .student-badge-emoji.creative-star::after, .student-badge-emoji.trailblazer::after {
        font-size: 16px;
      }
      .student-badge-name {
        font-size: 16px;
      }
      .student-badge-points {
        font-size: 13px;
        padding: 3px 8px;
      }
    }
    
    .toggle-panel {
        display: none;
        padding: 15px;
        background: var(--card-light);
        border-radius: 0 0 var(--radius-md) var(--radius-md);
        box-shadow: var(--shadow-sm);
      }
      .toggle-panel.show {
        display: block;
      }
      #importClassesModal .house-expanded-content {
        max-width: 500px;
        padding: 20px;
      }
      #importClassesModal .form-group-row {
        display: flex;
        flex-direction: column;
        gap: 12px;
      }
      #csvUpload, #csvUploadMobile {
        border: 1px solid var(--gray-light);
        border-radius: var(--radius-sm);
        padding: 8px;
        background: var(--white);
      }
      #importStatus, #importStatusMobile {
        align-self: center;
        margin-top: 8px;
      }
    
    @media (max-width: 480px) {
      .badges-info-content {
        padding: 10px;
      }
      .student-badges {
        padding: 10px;
      }
      .student-badge-item {
        padding: 10px;
      }
      .student-badge-item.bronze { transform: scale(0.75); }
      .student-badge-item.silver { transform: scale(0.85); }
      .student-badge-item.gold { transform: scale(0.9); }
      .student-badge-item.diamond { transform: scale(1); }
      .student-badge-emoji {
        font-size: 32px;
        width: 40px;
        height: 40px;
      }
      .student-badge-emoji.creative-star::after, .student-badge-emoji.trailblazer::after {
        font-size: 14px;
      }
      .student-badge-name {
        font-size: 14px;
      }
      .student-badge-points {
        font-size: 12px;
        padding: 2px 6px;
      }
    }
    
    .house-badge-item:hover {
      transform: scale(1.05);
      box-shadow: 0 6px 16px rgba(0,0,0,0.2), 0 0 12px rgba(59,130,246,0.3);
      cursor: pointer;
    }
    .house-badge-item:active, .house-badge-item.clicked {
      animation: pulseClick 0.2s ease-out;
    }
    
    @keyframes spinWheel {
      0% { transform: rotate(0deg) scale(1.05); }
      50% { transform: rotate(180deg) scale(1.1); }
      100% { transform: rotate(360deg) scale(1); }
    }
    .house-badge-item.clicked {
      animation: spinWheel 0.5s ease-out;
    }
    
    @keyframes bounceIn {
      0% { transform: scale(0.7); opacity: 0; }
      50% { transform: scale(1.05); opacity: 0.8; }
      100% { transform: scale(1); opacity: 1; }
    }
    @keyframes glowPulse {
      0% { box-shadow: 0 4px 12px rgba(0,0,0,0.2), 0 0 0 rgba(59,130,246,0); }
      50% { box-shadow: 0 6px 16px rgba(0,0,0,0.3), 0 0 12px rgba(59,130,246,0.5); }
      100% { box-shadow: 0 4px 12px rgba(0,0,0,0.2), 0 0 0 rgba(59,130,246,0); }
    }
    .house-details-header {
      background: linear-gradient(135deg, var(--house-color, #1e40af), rgba(var(--house-color-rgb, 30,64,175), 0.85));
      padding: 20px;
      border-radius: 14px;
      box-shadow: 0 8px 20px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.2);
      display: flex;
      align-items: center;
      gap: 16px;
      margin-bottom: 20px;
      animation: bounceIn 0.5s ease-out;
    }
    .house-details-emoji {
      font-size: 56px;
      width: 90px;
      height: 90px;
      background: linear-gradient(135deg, rgba(255,255,255,0.4), rgba(0,0,0,0.15));
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 6px 16px rgba(0,0,0,0.25);
      animation: glowPulse 2s ease-in-out infinite;
    }
    .house-details-header-info {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .house-details-title {
      font-size: 32px;
      font-weight: 800;
      color: #ffffff;
      text-shadow: 0 2px 4px rgba(0,0,0,0.4);
    }
    .house-details-motto {
      font-size: 16px;
      color: #e6e6ff;
      font-style: italic;
    }
    .house-details-header-stats {
      display: flex;
      gap: 12px;
      margin-top: 8px;
    }
    .house-details-stat {
      background: var(--milestone-color, linear-gradient(135deg, rgba(255,255,255,0.95), rgba(230,240,255,0.9)));
      border-radius: 10px;
      padding: 12px;
      text-align: center;
      box-shadow: 0 4px 12px rgba(0,0,0,0.2);
      flex: 1;
    }
    .house-details-stat-value {
      font-size: 22px;
      font-weight: 800;
      color: #000000 !important; /* Black with higher specificity */
      text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    }
    .house-details-stat-value.maxed-out {
      font-style: italic;
      font-size: 20px;
    }
    
    .house-details-stat-label {
      font-size: 12px;
      color: #000000 !important; /* Black with higher specificity */
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }
    .house-details-content {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
      max-height: calc(100vh - 180px);
      overflow: hidden;
    }
    .house-details-top {
      display: flex;
      flex-direction: column;
    }
    .house-details-top-title {
      font-size: 20px;
      font-weight: 700;
      color: #1e40af;
      margin-bottom: 12px;
      display: flex;
      align-items: center;
      gap: 8px;
      animation: bounceIn 0.5s ease-out;
    }
    @keyframes sparkle {
      0% { box-shadow: 0 3px 8px rgba(0,0,0,0.1), 0 0 0 rgba(255,215,0,0); }
      50% { box-shadow: 0 3px 8px rgba(0,0,0,0.1), 0 0 12px rgba(255,215,0,0.5); }
      100% { box-shadow: 0 3px 8px rgba(0,0,0,0.1), 0 0 0 rgba(255,215,0,0); }
    }
    .house-details-content {
      display: grid;
      grid-template-columns: 2fr 1fr 1fr; /* Top Classes gets more space */
      gap: 16px;
      max-height: calc(100vh - 180px);
      overflow: hidden;
    }
    .house-details-top-list#houseDetailsTopClasses {
      display: grid;
      gap: 10px;
      max-height: calc(100vh - 260px);
    }
    .house-details-top-list:not(#houseDetailsTopClasses) {
      display: grid;
      gap: 8px;
      max-height: calc(100vh - 260px);
    }
    .house-details-top-item {
      display: flex;
      align-items: center;
      padding: 12px;
      background: rgba(255,255,255,0.95);
      border-radius: 10px;
      font-size: 14px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.15);
      animation: fadeIn 0.4s ease-out;
      transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    .house-details-top-item:hover {
      transform: scale(1.02);
      box-shadow: 0 6px 16px rgba(0,0,0,0.2), 0 0 8px rgba(59,130,246,0.4);
    }
    .house-details-top-item.leader {
      background: linear-gradient(135deg, rgba(255,215,0,0.4), rgba(255,255,255,0.95));
      font-weight: 700;
      border: 2px solid #FFD700;
      animation: sparkle 1.5s ease-in-out infinite;
    }
    .house-details-top-item.class-item {
      background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(255,255,255,0.95));
      padding: 14px;
      font-size: 16px;
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .house-details-top-item.class-item.leader {
      background: linear-gradient(135deg, rgba(255,215,0,0.4), rgba(59,130,246,0.1));
      animation: sparkle 1.5s ease-in-out infinite;
    }
    .house-details-top-item .class-badge {
      width: 28px;
      text-align: center;
      font-size: 18px;
    }
    .house-details-top-item .class-progress {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .house-details-top-item .class-progress-bar {
      height: 8px;
      background: rgba(0,0,0,0.1);
      border-radius: 4px;
      overflow: hidden;
    }
    .house-details-top-item .class-progress-fill {
      height: 100%;
      background: linear-gradient(90deg, #3b82f6, #60a5fa);
      border-radius: 4px;
      transition: width 0.6s ease;
      box-shadow: 0 0 6px rgba(59,130,246,0.5);
    }
    .house-details-top-item .class-stats {
      display: flex;
      gap: 12px;
    }
    .house-details-top-item .class-stats-points,
    .house-details-top-item .class-stats-percent {
      font-weight: 700;
      color: #10b981;
      font-size: 15px;
    }
    
    
    
    
    
    @keyframes float {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-10px); }
    }
    
    
    
    
    
    @media (max-width: 1370px) {
      .house-details-top-item.class-item {
        font-size: 14px;
      }
      .house-details-top-item .class-badge {
        font-size: 16px;
      }
      .house-details-top-item .class-stats-points,
      .house-details-top-item .class-stats-percent {
        font-size: 14px;
      }
    }
    @media (max-width: 480px) {
      .house-details-top-item.class-item {
        font-size: 12px;
        padding: 10px;
      }
      .house-details-top-item .class-badge {
        font-size: 14px;
      }
      .house-details-top-item .class-stats-points,
      .house-details-top-item .class-stats-percent {
        font-size: 13px;
      }
    }
    .house-badge-emoji {
      font-size: 24px;
      width: 40px;
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .house-badge-name {
      font-size: 16px;
      font-weight: 600;
      color: var(--dark-text);
    }
    .house-badge-milestone {
      font-size: 14px;
      color: var(--primary-blue);
    }
    .house-badge-points {
      font-size: 14px;
      font-weight: 700;
      color: var(--success);
    }
    @media (min-width: 1200px) {
      .milestone-timeline {
        overflow-x: visible;
        justify-content: center;
        gap: 4px;
        margin: 0;
      }
      .milestone-step {
        width: 140px;
      }
      .milestone-connector {
        flex: 0 0 16px;
      }
      .house-badges {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
      }
    }
    
    
    
    
    
    /* Add after existing .hero-section styles */
    .hero-captain-avatar {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      background: var(--house-color, #1e40af);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      font-weight: 600;
    }
    .hero-captain-banner .animate-zoom {
      display: inline-block;
      animation: zoomInOut 2s ease-in-out infinite;
    }
    .hero-section .hero-row.leader .hero-pts {
      font-size: 12px; /* Smaller points for captains */
      color: var(--gray);
    }
    @keyframes zoomInOut {
      0% { transform: scale(1); }
      50% { transform: scale(1.05); }
      100% { transform: scale(1); }
    }
    @media (max-width: 1370px) {
      .hero-captain-avatar {
        width: 28px;
        height: 28px;
        font-size: 16px;
      }
      .hero-section .hero-row.leader .hero-pts {
        font-size: 11px;
      }
    }
    @media (max-width: 480px) {
      .hero-captain-avatar {
        width: 24px;
        height: 24px;
        font-size: 14px;
      }
      .hero-section .hero-row.leader .hero-pts {
        font-size: 10px;
      }
    }
    
    
    
    
    
    .badges-info-label {
      font-size: 14px;
      font-weight: 600;
      color: #3b82f6;
      text-align: center;
      margin-bottom: 12px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      animation: fadeIn 0.5s ease-out;
    }
    
    
    
    
    /* Add after existing .hero-captain-avatar styles */
    .achievements-page {
      width: 100vw;
      height: calc(100vh - 150px); /* Account for header and announcement bar */
      margin: 0;
      padding: 0 16px 16px;
      display: flex;
      flex-direction: column;
      gap: 16px;
      background: linear-gradient(180deg, #0B1220, #1E2A44); /* Premium gradient */
      opacity: 0;
      transform: translateY(20px);
      transition: opacity .5s ease, transform .5s ease;
    }
    .achievements-page.show {
      opacity: 1;
      transform: translateY(0);
    }
    .achievements-title {
      font-size: 1px; /* Reduced from 60px */
      font-weight: 600;
      color: #fff;
      text-align: center;
      letter-spacing: .2px;
      text-shadow: 0 4px 20px rgba(0,0,0,.35);
      margin: 8px 0 4px;
    }
    .badges-subtitle {
      color: #B6C2E0;
      text-align: center;
      font-size: 20px;
      margin-bottom: 8px;
    }
    .achievements-house-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(280px, 360px));
      justify-content: center;
      gap: 20px;
      flex: 1;
    }
    .achievements-house-card {
      background: linear-gradient(145deg, var(--house-color, #1e40af), rgba(var(--house-color-rgb, 30,64,175), 0.6));
      border-radius: 18px;
      padding: 12px; /* Reduced from 16px */
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px; /* Reduced from 12px */
      box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 10px 28px rgba(0,0,0,.25);
      height: 100%;
    }
    .achievements-house-name {
      font-size: 48px; /* 1x larger (28px * 2) */
      font-weight: 800;
      color: #fff;
      text-align: center;
      letter-spacing: .2px;
    }
    .achievements-house-points {
      font-size: 23px; /* Base size */
      font-weight: 600;
      color: #fff;
      background: rgba(0,0,0,0.4);
      padding: 6px 12px;
      border-radius: 999px;
      box-shadow: 0 4px 12px rgba(0,0,0,.2);
    }
    
    .leaderboard-fullscreen .achievements-house-points {
      font-size: 28.6px; /* 20% larger than 28px */
      padding: 7.2px 14.4px; /* Scaled up 20% */
    }
    .achievements-house-card .achievements-milestone-icon {
      font-size: 80px; /* Reduced from 280px */
      color: var(--milestone-color, #FFF176);
      text-shadow: 0 4px 12px rgba(0,0,0,.3);
    }
    .achievements-milestone-name {
      font-size: 20px;
      font-weight: 700;
      color: #fff;
      text-align: center;
    }
    .achievements-milestone-next {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px; /* Tighter gap */
      background: rgba(0,0,0,0.2);
      padding: 8px 12px; /* Tighter padding */
      border-radius: 999px;
      box-shadow: 0 4px 12px rgba(0,0,0,.2);
      margin-top: 8px; /* Reduced from 12px */
    }
    .achievements-milestone-next-title {
      font-size: 12px; /* Reduced from 14px */
      font-weight: 600;
      color: #B6C2E0;
      text-align: center;
    }
    .achievements-milestone-next-highlight {
      font-size: 16px; /* Base size */
      font-weight: 800;
      color: #ffffff; /* Changed to white for better contrast */
      text-align: center;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); /* Added subtle shadow for readability */
      background: var(--milestone-color, #FFF176); /* Maintain milestone color as background */
      padding: 2px 6px; /* Slight padding to frame text */
      border-radius: 4px; /* Subtle rounding for clarity */
    }
    .achievements-milestone-next-subtext {
      font-size: 11px; /* Reduced from 12px */
      font-weight: 500;
      color: #B6C2E0;
      opacity: 0.7;
      text-align: center;
    }
    .achievements-timeline {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      grid-template-rows: repeat(2, auto);
      gap: 12px;
      padding: 16px;
      margin-top: 24px;
      background: linear-gradient(180deg, #0C1526, #0B1220);
      border-radius: 14px;
      box-shadow: 0 8px 24px rgba(0,0,0,.3);
    }
    .achievements-milestone-step {
      padding: 12px;
      border-radius: 12px;
      background: #0F1A2F;
      opacity: .9;
      display: flex;
      align-items: center;
      gap: 10px;
      border: 1px solid rgba(255,255,255,.06);
      box-shadow: 0 4px 12px rgba(0,0,0,.22);
    }
    .achievements-milestone-step.completed {
      opacity: 1;
      box-shadow: 0 6px 18px rgba(0,0,0,.28), 0 0 0 2px rgba(255,215,0,.15) inset;
    }
    .achievements-milestone-step::before {
      content: attr(data-number);
      position: absolute;
      top: -20px;
      left: 12px;
      font-size: 14px;
      font-weight: 700;
      color: #B6C2E0;
    }
    .achievements-timeline .achievements-milestone-icon {
      width: 30px;
      height: 30px;
      border-radius: 999px;
      display: grid;
      place-items: center;
      font-size: 20px;
      color: #001;
      background: var(--milestone-color, #94A3B8);
    }
    .achievements-milestone-label {
      flex: 1;
      min-width: 0;
    }
    .achievements-milestone-title {
      font-size: 14px;
      font-weight: 800;
      color: #EAF1FF;
      line-height: 1.15;
    }
    .achievements-spotlight {
      background: linear-gradient(90deg, #0E2A75, #1E3A8A);
      border-radius: 14px;
      padding: 14px 18px;
      min-height: 56px;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 10px 30px rgba(0,0,0,.28);
    }
    .spotlight-messages {
      width: 100%;
      text-align: center;
    }
    .spotlight-message {
      color: #fff;
      font-size: 24px;
      font-weight: 800;
    }
    .spotlight-message.animate-fade {
      animation: fadeIn .4s ease-out;
    }
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(4px); }
      to { opacity: 1; transform: none; }
    }
    @media (max-width: 1200px) {
    .achievements-house-grid {
        grid-template-columns: repeat(3, 1fr);
      }
      .achievements-title {
        font-size: 46px;
      }
      .achievements-timeline {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(4, auto);
      }
    }
    
    
    .points-preview-chip {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 8px 16px;
      background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
      color: var(--light-text);
      font-size: 14px;
      font-weight: 600;
      border-radius: 999px;
      box-shadow: var(--shadow-sm), 0 0 8px rgba(59, 130, 246, 0.3);
      text-align: center;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      width: fit-content; /* Prevent stretching */
      margin: 0 auto; /* Center within parent */
      animation: fadeIn 0.3s ease-out;
      transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .points-preview-chip i {
      font-size: 16px;
      color: var(--light-text);
      flex-shrink: 0;
    }
    
    .points-preview-chip span {
      flex: 1;
      text-align: center;
    }
    
    .points-preview-chip:hover {
      transform: scale(1.05);
      box-shadow: var(--shadow-md), 0 0 12px rgba(59, 130, 246, 0.5);
    }
    
    .points-preview-chip:empty,
    .points-preview-chip:has(span:empty) {
      background: var(--gray-light);
      color: var(--gray);
      font-style: italic;
      box-shadow: var(--shadow-sm);
    }
    
    .points-preview-chip:empty i,
    .points-preview-chip:has(span:empty) i {
      color: var(--gray);
    }
    
    @media (max-width: 1370px) {
      .points-preview-chip {
        font-size: 12px;
        padding: 6px 12px;
        border-radius: 20px;
        transition: transform 0.2s ease, background 0.2s ease;
      }
      .points-preview-chip i {
        font-size: 14px;
      }
      /* Real-time Pulse Animation */
    /* Add this inside your mobile media query */
    .points-updated-pulse {
      animation: badgeSuccess 0.6s ease-out !important;
      background-color: #10b981 !important; /* Force Green */
      color: white !important;
    }
    
    @keyframes badgeSuccess {
      0% { transform: scale(1); }
      50% { transform: scale(1.1); box-shadow: 0 0 20px rgba(16, 185, 129, 0.6); }
      100% { transform: scale(1); }
    }
    
    /* Ensure individual student inputs can also pulse */
    .points-input.points-updated-pulse {
      border-color: #10b981 !important;
      box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    }
    
    }
    


    /* --- ENABLE SELECTION TOOLBAR GLOBALLY --- */
    #selectionToolbar {
      position: fixed;
      bottom: 40px;
      left: 50%;
      transform: translateX(-50%);
      background: #0f172a; /* Deep charcoal for premium contrast */
      border: 1px solid rgba(255, 255, 255, 0.1);
      backdrop-filter: blur(10px);
      color: white;
      height: 64px; /* Larger for Desktop/iPad */
      padding: 0 16px 0 24px;
      border-radius: 40px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      min-width: 340px;
      box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
      z-index: 5000;
      opacity: 0;
      visibility: hidden;
      transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    #selectionToolbar.active {
      display: flex !important;
      opacity: 1;
      visibility: visible;
      bottom: 50px; /* Slight pop up when active */
    }

    /* ACTION GROUP & BUTTONS (Global so they work on Desktop!) */
    .action-group {
      display: flex;
      align-items: center;
      gap: 12px;
      height: 100%;
    }

    .btn-bulk {
      height: 44px;
      min-width: 60px;
      border-radius: 12px;
      border: none;
      font-weight: 800;
      font-size: 16px;
      color: white;
      background: #10b981; /* Success Green */
      box-shadow: 0 4px 0 #059669; /* 3D "Tap" effect */
      transition: all 0.1s ease;
      cursor: pointer;
    }

    .btn-bulk:active {
      transform: translateY(2px);
      box-shadow: none;
    }

    .btn-custom {
      height: 44px;
      width: 44px;
      border-radius: 12px;
      border: none;
      background: #6366f1; 
      color: white;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      transition: all 0.1s ease;
      cursor: pointer;
    }

    .btn-custom:active {
      transform: scale(0.95);
    }

    .btn-dismiss {
      background: none;
      border: none;
      color: #94a3b8;
      font-size: 28px;
      padding: 0 12px;
      cursor: pointer;
      transition: color 0.2s;
    }
    
    .btn-dismiss:hover {
      color: #ef4444;
    }

    #selectionCount {
      display: flex;
      flex-direction: column;
      align-items: center;
      line-height: 1;
      min-width: 40px;
    }

    #selectionCount .num {
      font-size: 18px;
      font-weight: 900;
      color: #3b82f6;
    }

    #selectionCount i {
      font-size: 11px;
      margin-top: 2px;
      opacity: 0.8;
    }

    /* Card selection state */
    .student-card.selected {
      border: 3px solid #10b981 !important;
      background-color: rgba(16, 185, 129, 0.08) !important;
      transform: scale(0.98);
      box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
    }

    /* ==========================================
   TABLET / IPAD SELECTION TOOLBAR
   769px - 1370px
   ========================================== */

@media (max-width: 1370px) {

  #studentsList {
    padding-bottom: 120px !important;
  }

  #selectionToolbar {
    bottom: calc(95px + env(safe-area-inset-bottom));
  }

  #selectionToolbar.active {
    bottom: calc(105px + env(safe-area-inset-bottom));
  }

}


/* iPad / tablet layout only */
@media (min-width: 769px) and (max-width: 1370px) {

  #selectionToolbar {
    width: min(620px, calc(100vw - 48px)) !important;
    min-width: 0 !important;

    height: 58px !important;

    padding: 0 10px !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    gap: 8px !important;

    border-radius: 22px !important;

    box-sizing: border-box !important;
  }


  /* Keep selected count on ONE line */
  #selectionCount {
    width: auto !important;
    min-width: 96px !important;

    height: 40px !important;

    padding: 0 12px !important;

    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;

    gap: 5px !important;

    background: rgba(255,255,255,0.08) !important;

    border:
      1px solid
      rgba(255,255,255,0.12) !important;

    border-radius: 999px !important;

    line-height: 1 !important;

    white-space: nowrap !important;

    flex-shrink: 0 !important;
  }


  #selectionCount .num {
    font-size: 17px !important;
    font-weight: 900 !important;
    line-height: 1 !important;

    color: #60a5fa !important;
  }


  #selectionCount .selected-label {
    font-size: 10px !important;
    font-weight: 750 !important;
    line-height: 1 !important;

    color: #e2e8f0 !important;

    white-space: nowrap !important;
  }


  /* Select All / Deselect All stays on one line */
  #selectionToolbar #btn-toggle-all {
    width: auto !important;
    min-width: 108px !important;

    height: 40px !important;

    margin: 0 !important;

    padding: 0 12px !important;

    border-radius: 11px !important;

    font-size: 12px !important;
    font-weight: 800 !important;

    white-space: nowrap !important;

    flex-shrink: 0 !important;
  }


  #selectionToolbar #btn-toggle-all i {
    font-size: 11px !important;
  }


  /* Do not allow action group to stretch */
  #selectionToolbar .action-group {
    display: flex !important;

    flex: 0 0 auto !important;

    width: auto !important;
    height: 100% !important;

    align-items: center !important;
    justify-content: center !important;

    gap: 6px !important;
  }


  /* +1 / +2 */
  #selectionToolbar .action-group .btn-bulk {
    width: 44px !important;
    min-width: 44px !important;

    height: 44px !important;

    margin: 0 !important;
    padding: 0 !important;

    border-radius: 11px !important;

    font-size: 16px !important;

    flex: 0 0 44px !important;
  }


  /* Reason + Manage */
  #selectionToolbar .action-group .btn-custom {
    width: 40px !important;
    min-width: 40px !important;

    height: 40px !important;

    margin: 0 !important;
    padding: 0 !important;

    border-radius: 10px !important;

    font-size: 14px !important;

    flex: 0 0 40px !important;
  }


  /* Close */
  #selectionToolbar .btn-dismiss {
    width: 36px !important;
    min-width: 36px !important;

    height: 36px !important;

    margin: 0 !important;
    padding: 0 !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    background:
      rgba(255,255,255,0.07) !important;

    border:
      1px solid
      rgba(255,255,255,0.11) !important;

    border-radius: 50% !important;

    color: #cbd5e1 !important;

    font-size: 21px !important;
    line-height: 1 !important;

    flex: 0 0 36px !important;
  }

}

    /* ==========================================
   MOBILE SELECTION TOOLBAR
   FINAL COMPACT VERSION
   ========================================== */
@media (max-width: 768px) {

  #selectionToolbar {
    width: auto !important;
    max-width: calc(100vw - 14px) !important;
    min-width: 0 !important;

    height: 50px !important;

    padding: 0 6px !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    gap: 5px !important;

    border-radius: 18px !important;

    white-space: nowrap !important;

    box-sizing: border-box !important;
  }


  /* Selected count */
  #selectionCount {
    height: 36px !important;

    min-width: 62px !important;
    width: auto !important;

    padding: 0 8px !important;

    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;

    gap: 4px !important;

    background: rgba(255,255,255,0.08) !important;

    border:
      1px solid
      rgba(255,255,255,0.12) !important;

    border-radius: 999px !important;

    flex-shrink: 0 !important;
  }


  #selectionCount .num {
    font-size: 14px !important;
    line-height: 1 !important;

    font-weight: 900 !important;

    color: #60a5fa !important;
  }


  #selectionCount .selected-label {
    font-size: 8px !important;
    line-height: 1 !important;

    font-weight: 750 !important;

    color: #e2e8f0 !important;
  }


  /* All / Clear */
  #selectionToolbar #btn-toggle-all {
    width: auto !important;
    min-width: 52px !important;

    height: 36px !important;

    margin: 0 !important;

    padding: 0 7px !important;

    border-radius: 10px !important;

    font-size: 10px !important;
    line-height: 1 !important;

    font-weight: 800 !important;

    gap: 3px !important;

    flex-shrink: 0 !important;
  }


  #selectionToolbar #btn-toggle-all i {
    font-size: 10px !important;
  }


  /* Do NOT allow this wrapper to stretch */
  #selectionToolbar .action-group {
    display: flex !important;

    align-items: center !important;
    justify-content: center !important;

    flex: 0 0 auto !important;

    width: auto !important;
    height: 100% !important;

    gap: 4px !important;
  }


  /* +2 / -2 */
  #selectionToolbar .action-group .btn-bulk {
    width: 38px !important;
    min-width: 38px !important;

    height: 38px !important;

    padding: 0 !important;
    margin: 0 !important;

    border-radius: 10px !important;

    font-size: 14px !important;
    font-weight: 900 !important;

    flex: 0 0 38px !important;
  }


  /* Reasons / Adjust */
  #selectionToolbar .action-group .btn-custom {
    width: auto !important;
    min-width: 0 !important;

    height: 34px !important;

    padding: 0 8px !important;
    margin: 0 !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    gap: 4px !important;

    border-radius: 9px !important;

    font-size: 11px !important;
    font-weight: 800 !important;

    flex: 0 0 auto !important;

    white-space: nowrap !important;

    box-shadow:
      0 2px 5px
      rgba(0,0,0,0.22) !important;
  }


  #selectionToolbar
  .reason-award-toolbar-label,
  #selectionToolbar
  .adjust-toolbar-label {
    display: inline !important;

    font-size: 9px !important;
    font-weight: 800 !important;

    line-height: 1 !important;
  }


  /* Close */
  #selectionToolbar .btn-dismiss {
    width: 32px !important;
    min-width: 32px !important;

    height: 32px !important;

    margin: 0 !important;
    padding: 0 !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    background:
      rgba(255,255,255,0.07) !important;

    border:
      1px solid
      rgba(255,255,255,0.11) !important;

    border-radius: 50% !important;

    color: #cbd5e1 !important;

    font-size: 19px !important;
    line-height: 1 !important;

    flex: 0 0 32px !important;
  }


  #selectionToolbar .btn-dismiss:active {
    background:
      rgba(239,68,68,0.18) !important;

    color: #fca5a5 !important;
  }

}


/* Extra-small phones */
@media (max-width: 360px) {

  #selectionToolbar {
    gap: 3px !important;
    padding: 0 4px !important;
  }


  #selectionCount {
    min-width: 55px !important;
    padding: 0 6px !important;
  }


  #selectionCount .selected-label {
    font-size: 7px !important;
  }


  #selectionToolbar #btn-toggle-all {
    min-width: 58px !important;
    padding: 0 6px !important;
  }


  #selectionToolbar .action-group {
    gap: 3px !important;
  }


  #selectionToolbar .action-group .btn-bulk {
    width: 34px !important;
    min-width: 34px !important;
    flex-basis: 34px !important;
  }


  #selectionToolbar .action-group .btn-custom {
    width: auto !important;
    min-width: 0 !important;
    flex-basis: auto !important;

    padding:
      0
      5px !important;

    font-size: 10px !important;
  }


  #selectionToolbar .btn-dismiss {
    width: 30px !important;
    min-width: 30px !important;
    flex-basis: 30px !important;
  }

}
    
    
    @media (max-width: 480px) {
      .points-preview-chip {
        font-size: 11px;
        padding: 5px 10px;
      }
      .points-preview-chip i {
        font-size: 12px;
      }
    }
    
    /* Ensure form-group doesn't stretch */
    .form-group:has(#pointsPreview) {
      display: flex;
      justify-content: center; /* Center chip */
      margin-bottom: 12px;
    }
    
    /* Prevent table container from shrinking */
    .table-container {
      width: 100%;
      max-width: 100%;
      overflow-x: auto;
    }
    
    
    @media (max-width: 1370px) {
    .achievements-house-grid {
        grid-template-columns: repeat(2, 1fr);
      }
      .achievements-title {
        font-size: 36px;
      }
      .badges-subtitle {
        font-size: 16px;
      }
      .achievements-milestone-step {
        padding: 10px;
      }
      .spotlight-message {
        font-size: 18px;
      }
    }
    
    
    
    
    .house-badge-item .loader {
      display: none;
      width: 28px;
      height: 28px;
      border: 5px solid #3b82f6;
      border-top: 5px solid transparent;
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      z-index: 10;
      box-shadow: 0 0 8px rgba(59,130,246,0.5);
    }
    .house-badge-item.loading {
      position: relative;
      background: rgba(255,255,255,0.95);
    }
    .house-badge-item.loading .loader {
      display: block;
    }
    .house-badge-item.loading > *:not(.loader) {
      opacity: 0;
    }
    @keyframes spin {
      0% { transform: translate(-50%, -50%) rotate(0deg); }
      100% { transform: translate(-50%, -50%) rotate(360deg); }
    }
    
    
    .house-details-top-rank {
      width: 40px;
      text-align: center;
      font-weight: 800;
      color: #1e40af;
      font-size: 15px;
      padding-right: 12px;
    }
    .house-details-top-points {
      font-weight: 700;
      color: #10b981;
      font-size: 15px;
      padding: 4px 8px;
      border-radius: 6px;
      background: rgba(16,185,129,0.1);
    }
    .house-details-top-points .points-value {
      font-weight: 800;
      color: #047857;
    }
    @media (max-width: 1370px) {
      .house-details-top-rank {
        width: 36px;
        font-size: 14px;
        padding-right: 10px;
      }
      .house-details-top-points {
        font-size: 14px;
        padding: 3px 6px;
      }
    }
    @media (max-width: 480px) {
      .house-details-top-rank {
        width: 32px;
        font-size: 13px;
        padding-right: 8px;
      }
      .house-details-top-points {
        font-size: 13px;
        padding: 2px 5px;
      }
    }
    
    .announcement-bar .announcement-points {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #ff6b6b, #ff8e53);
      color: #fff;
      font-weight: 700;
      font-size: 16px;
      padding: 4px 12px;
      border-radius: 999px;
      margin-left: 12px;
      margin-right: 12px; /* Added for gap after points */
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    }
    @media (max-width: 1370px) {
      .announcement-bar .announcement-points {
        font-size: 14px;
        padding: 3px 10px;
      }
    }
    @media (max-width: 480px) {
      .announcement-bar .announcement-points {
        font-size: 12px;
        padding: 2px 8px;
      }
    }
    
    
    .logo-house-card {
      width: 120px;   /* adjust as needed */
      height: 120px;
      border-radius: 50%;
      object-fit: contain; /* ensures no white gap */
      background: transparent;
      display: block;
      margin: 0 auto;
    }
    
    
    
    @media (max-width: 1370px) {
      body.mobile #badgesInfoModal .milestone-timeline {
        display: grid;
        grid-template-columns: repeat(2, 1fr); /* 2 badges per row */
        gap: 12px;
        padding: 12px;
        max-width: 100%;
      }
    
      body.mobile #badgesInfoModal .house-expanded-content {
        height: auto; /* Remove 100vh constraint */
        min-height: 100vh; /* Ensure at least full viewport height */
        max-height: none; /* Remove max-height restriction */
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Prevent unwanted overflow */
      }
    
      body.mobile #badgesInfoModal .badges-info-content {
        height: auto; /* Allow natural height based on content */
        min-height: 0; /* Allow flex item to shrink if needed */
        flex: 1 1 auto; /* Grow to fill space, allow shrinkage */
        overflow-y: auto; /* Maintain vertical scrolling */
        -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
        padding: 16px;
      }
    
      body.mobile #badgesInfoModal .milestone-timeline {
        height: auto; /* Ensure grid can expand */
        min-height: auto; /* Remove any min-height constraints */
        overflow: visible; /* Allow grid to render fully */
      }
    
      body.mobile #badgesInfoModal .milestone-step {
        width: 100%;
        margin: 0; /* Remove any inline spacing */
        border-radius: 14px; /* Optional polish for app-like feel */
        padding: 12px; /* Optional polish for balanced content */
        box-sizing: border-box; /* Ensure padding doesn’t cause overflow */
      }
    }
    
    /* Desktop styles for house points container and tiles */
    @media (min-width: 769px) {
      .house-points-container {
        width: 100%;
        max-width: none; /* Remove any width constraints */
        margin-top: 12px; /* Space below award form */
      }
    
      #housePointsOverview {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
        align-items: center;
        justify-items: center; /* Center tiles for balanced appearance */
        padding: 12px;
        background: var(--gray-light);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        width: 100%;
      }
    
      .house-pill {
        display: flex;
        flex-direction: row; /* Horizontal layout */
        align-items: center;
        justify-content: flex-start; /* Align from the left */
        width: 100%;
        max-width: 200px;
        min-height: 36px; /* Much smaller height */
        padding: 6px 14px; /* Tighter padding */
        background: var(--card-light);
        border-radius: 50px; /* Fully rounded pill shape */
        box-shadow: var(--shadow-sm);
        opacity: 1;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        gap: 8px; /* Space between dot and text */
      }
    
      .house-pill:hover {
        transform: scale(1.05);
        box-shadow: var(--shadow-md);
      }
    
      .house-pill .color-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        flex-shrink: 0; /* Prevents dot from shrinking */
      }
    
      .house-pill .pill-text {
        display: flex;
        flex-direction: row; /* Side-by-side text */
        align-items: baseline;
        gap: 6px; /* Space between house name and points */
        width: 100%;
        overflow: hidden;
        white-space: nowrap;
      }
    
      .house-pill .house-name {
        font-size: 13px;
        font-weight: 700;
        color: var(--dark-text);
        text-overflow: ellipsis;
        overflow: hidden;
      }
    
      .house-pill .house-points {
        font-size: 12px;
        font-weight: 800;
        color: var(--primary-blue);
        flex-shrink: 0; /* Ensures points always stay visible */
      }
    
      /* Ensure award form layout is flexible */
      .form-group-row.award-class-house {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        align-items: flex-start;
        width: 100%;
        max-width: none;
      }
    
      .form-group-row.award-class-house > div:nth-child(1) {
        display: flex;
        flex-direction: row;
        gap: 12px;
        flex: 1;
        min-width: 300px;
      }
    
      .form-group-row.award-class-house .form-group {
        flex: 1;
        min-width: 150px;
        max-width: none;
      }
    
      .form-group-row.award-class-house #pointsPreview {
        font-size: 14px;
        color: var(--primary-blue);
        text-align: left;
        margin-top: 8px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
      }
    }
    
    /* Mobile styles */
    @media (max-width: 1370px) {
      .house-points-container {
        display: none; /* Hide container on mobile */
      }
    
      #housePointsOverview {
        display: none !important; /* Ensure hidden */
      }
    
      .form-group-row.award-class-house {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
        width: 100%;
      }
    
      .form-group-row.award-class-house > div:nth-child(1) {
        flex-direction: column;
        gap: 8px;
        width: 100%;
      }
    
      .form-group-row.award-class-house .form-group {
        min-width: 0;
        max-width: 100%;
        margin-bottom: 0;
      }
    
      .form-group-row.award-class-house #pointsPreview {
        font-size: 12px;
        text-align: center;
        margin-top: 4px;
      }
    }
    
    
    
    
    
    /* Adjust tooltip for compact header */
    .form-group-row.award-class-house .tooltip .tooltiptext {
      width: 120px; /* Smaller tooltip */
      font-size: 10px;
      background-color: var(--primary-blue);
      color: var(--light-text);
      padding: 4px 6px; /* Reduced padding */
      border-radius: var(--radius-sm);
      top: calc(100% + 6px); /* Adjusted position */
      left: 50%;
      transform: translateX(-50%);
      z-index: 2000;
      opacity: 0;
      transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    
    .form-group-row.award-class-house .tooltip:hover .tooltiptext {
      visibility: visible;
      opacity: 1;
    }
    
    
    /* UPDATED: Added !important and 'background' shorthand to fix grey buttons */
        .btn-danger {
          background: var(--danger) !important; 
          color: var(--light-text) !important;
          border: none !important;
        }
    
        .btn-danger:hover {
          background: #b91c1c !important;
        }
    
    
    /* Responsive adjustments */
    @media (max-width: 1370px) {
    .form-group-row.award-class-house {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
      }
    
    /* Hide Refresh Data button in Dashboard on mobile */
      #dashboard-section #refresh-dashboard-btn {
        display: none !important;
      }
    
    #students-section .card .form-group-row.award-class-house {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
        margin: 0;
        align-items: stretch;
        width: 100%;
      }
      #students-section .card .form-group-row.award-class-house > div:nth-child(1) {
        display: flex;
        flex-direction: row;
        gap: 8px;
        width: 100%;
        align-items: flex-start;
      }
      #students-section .card .form-group-row.award-class-house > div:nth-child(1) > .form-group:nth-child(1),
      #students-section .card .form-group-row.award-class-house > div:nth-child(1) > .form-group:nth-child(2) {
        flex: 1;
        min-width: 0;
        max-width: 50%;
      }
      #students-section .card .form-group-row.award-class-house .form-group {
        min-width: 0;
        max-width: 100%;
        margin-bottom: 0;
      }
      #students-section .card .form-group-row.award-class-house .form-label {
        font-size: 12px;
        margin-bottom: 2px;
        font-weight: 500;
        color: var(--dark-text);
      }
      #students-section .card .form-group-row.award-class-house .form-control {
        width: 100%;
        height: 40px;
        font-size: 14px;
        padding: 8px;
        border-radius: 6px;
        border: 1px solid var(--gray-light);
        background: var(--bg-light);
        touch-action: manipulation;
      }
      #students-section .card .form-group-row.award-class-house select.form-control {
        padding-right: 24px;
        background-size: 12px;
      }
        #students-section .card .form-group-row.award-class-house .points-award-container {
        display: flex;
        flex-direction: column;
        width: 100%;
      }
      #students-section .card .form-group-row.award-class-house .points-award-row {
        display: flex;
        flex-direction: row;
        gap: 8px;
        align-items: center;
        width: 100%;
      }
      #students-section .card .form-group-row.award-class-house .points-award-row .form-control {
        flex: 1;
        height: 40px;
        font-size: 14px;
        padding: 8px;
        border-radius: 6px;
      }
      #students-section .card .form-group-row.award-class-house .points-award-row .btn {
        flex: 0 0 auto;
        width: 100px;
        height: 40px;
        font-size: 14px;
        padding: 8px;
        border-radius: 6px;
        background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
        color: var(--light-text);
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
      }
      #students-section .card .form-group-row.award-class-house #pointsPreview {
        font-size: 12px;
        color: var(--primary-blue);
        text-align: center;
        margin-top: 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
      }
      #students-section .card .form-group-row.award-class-house #housePointsOverview {
        display: none;
      }
      #students-section .card .form-group-row.award-class-house .tooltip .tooltiptext {
        top: calc(100% + 6px);
        left: 50%;
        transform: translateX(-50%);
        width: 120px;
        font-size: 10px;
      }
      /* Hide Refresh button in Student Management on mobile */
      #students-section #refresh-students-btn {
        display: none !important;
      }
      .student-card-actions .btn-danger:has(.fa-trash) {
        display: none !important;
      }
      /* Floating Save Button */
      
      .floating-save-btn {
        position: fixed;
        bottom: 60px;
        right: 20px;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: var(--shadow-lg);
        z-index: 1100;
        background: linear-gradient(135deg, rgba(52, 211, 153, 0.7), rgba(16, 185, 129, 0.7));
        color: var(--light-text);
        touch-action: manipulation;
      }
      .floating-save-btn .save-text {
        display: none;
      }
      .floating-save-btn i {
        font-size: 20px;
      }
      .floating-save-btn .unsaved-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        font-size: 10px;
        line-height: 1;
      }
      .floating-save-btn:hover {
        transform: scale(1.1);
      }
    }
    
    /* Updated Floating Save Button for Mobile */
    @media (max-width: 1370px) {
      .floating-save-btn {
        position: fixed;
        /* MOVED UP: Adjusted from 60px to 90px + Safe Area to clear the 76px tall nav bar */
        bottom: calc(90px + env(safe-area-inset-bottom, 0px)); 
        right: 20px;
        width: 54px; /* Slightly larger for better thumb reach */
        height: 54px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); /* Stronger shadow so it "pops" over content */
        z-index: 1100;
        background: linear-gradient(135deg, #10b981, #059669); /* Solidified success colors */
        color: var(--light-text);
        touch-action: manipulation;
        border: 2px solid rgba(255, 255, 255, 0.2);
      }
    
      .floating-save-btn i {
        font-size: 24px;
      }
    
      /* Ensure the badge doesn't get cut off */
      .floating-save-btn .unsaved-badge {
        position: absolute;
        top: 2px;
        right: 2px;
        font-size: 12px;
        background: var(--danger);
        color: white;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 2px solid white;
      }
    
       .floating-save-btn:hover {
        transform: scale(1.05);
      }
    }
    
    
    @media (max-width: 480px) {
      .form-group-row.award-class-house .form-label {
        font-size: 10px;
      }
    
      .form-group-row.award-class-house .form-control {
        font-size: 10px;
        padding: 3px 6px;
        height: 26px;
      }
    
      .form-group-row.award-class-house .btn {
        font-size: 10px;
        padding: 3px 6px;
        height: 26px;
      }
    
      .form-group-row.award-class-house #pointsPreview {
        font-size: 10px;
        padding: 4px 6px;
      }
    
      .form-group-row.award-class-house #housePointsOverview {
        font-size: 10px;
        padding: 6px;
      }
    
    }
    
    
    @media (max-width: 1280px) {
      .form-group-row.award-class-house #pointsPreview {
        font-size: 11px;
        padding: 4px 0;
      }
    }
    
    
    /* Desktop: Show desktop buttons, hide mobile buttons */
@media (min-width: 1371px) {
  .desktop-btn-group {
    display: flex !important;
  }
  .mobile-btn-group {
    display: none !important;
  }
  .mobile-nav {
    display: none !important;
  }

  .mobile-menu-only {
    display: none !important;
  }
}

/* Mobile and iPad: Hide desktop buttons, show mobile buttons */
@media (max-width: 1370px) {
  .desktop-btn-group {
    display: none !important;
  }
  .mobile-btn-group {
    display: flex !important;
  }
  .page-actions.mobile-only,
  .mobile-only {
    display: block !important;
  }
}
    
    /* Mobile Navigation - YouTube-style hide on scroll */
    .mobile-nav {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      display: flex;
      overflow-x: auto;
      white-space: nowrap;
      gap: 6px;
      padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)) 12px;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
      background: var(--card-light);
      border-top: 1px solid rgba(0, 0, 0, 0.05);
      box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
      z-index: 1000;
      
      /* YouTube-style animation */
      transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      transform: translateY(0);
    }
    
    /* Hide on scroll down */
    .mobile-nav.hide {
      transform: translateY(100%);
    }
    
    /* Show on scroll up or tap - default visible */
    .mobile-nav.show {
      transform: translateY(0);
    }
    
    .mobile-nav::-webkit-scrollbar {
      display: none;
    }
    
    .mobile-nav-item {
      flex: 0 0 auto;
      min-width: 72px;
      text-align: center;
      cursor: pointer;
      transition: all 0.2s ease;
    }
    
    /* Default: Show toast messages on desktop */
    .status-message,
    .toast-central[data-content*="Announcements loaded"],
    .toast-central[data-content*="House settings loaded"] {
      display: block;
    }
    
    
    
    
    .teacher-badge {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      font-weight: 600;
      white-space: nowrap;
    }
    .teacher-badge::before {
      content: '👩‍🏫';
      font-size: 14px;
    }
    @media (max-width: 1370px) {
      .teacher-badge {
        font-size: 12px !important;
      }
      .teacher-badge::before {
        font-size: 12px;
      }
    }
    #addEditTeacherModal.house-expanded {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.65);
      z-index: 1100;
      display: none;
      justify-content: center;
      align-items: center;
      opacity: 0;
      transition: opacity 0.3s ease;
    }
    #addEditTeacherModal.house-expanded.show {
      display: flex;
      opacity: 1;
      pointer-events: all;
    }
    #addEditTeacherModal .house-expanded-content {
      background: var(--card-light);
      border-radius: 8px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
      max-width: 400px;
      width: 90%;
      padding: 20px;
      transform: scale(0.8);
      transition: transform 0.3s ease;
    }
    #addEditTeacherModal.show .house-expanded-content {
      transform: scale(1);
    }
    #addEditTeacherModal .form-group {
      margin-bottom: 12px;
    }
    #addEditTeacherModal .form-control {
      font-size: 13px;
      padding: 8px;
      width: 100%;
      border: 1px solid var(--gray-light);
      border-radius: var(--radius-sm);
      background: var(--bg-light);
    }
    #addEditTeacherModal .form-error {
      color: var(--danger);
      font-size: 12px;
      margin-top: 4px;
    }
    @media (max-width: 1370px) {
      #addEditTeacherModal .house-expanded-content {
        width: 100%;
        height: 100vh;
        padding: 16px;
        margin: 0;
        border-radius: 0;
        overflow-y: auto;
        box-sizing: border-box;
      }
      #addEditTeacherModal .form-control {
        font-size: 14px;
        padding: 10px;
        height: 40px;
      }
      #addEditTeacherModal .btn {
        font-size: 14px;
        padding: 10px;
        width: 100%;
        min-height: 40px;
      }
      #addEditTeacherModal .form-group {
        margin-bottom: 12px;
      }
    }
    @media (max-width: 480px) {
      #addEditTeacherModal .house-expanded-content {
        padding: 12px;
      }
      #addEditTeacherModal .form-control {
        font-size: 12px;
        padding: 8px;
        height: 36px;
      }
      #addEditTeacherModal .btn {
        font-size: 12px;
        padding: 8px;
        min-height: 36px;
      }
    }
    
    
    
    @media (max-width: 1370px) {
      #housePointsOverview {
        display: none !important;
      }
    }
    
    
    /* Desktop table column width adjustments - Rebalanced for Role Visibility */
    @media (min-width: 769px) {
        /* ID Column (Column 2) - Narrower */
        #students-section .table-container table th:nth-child(2),
        #students-section .table-container table td:nth-child(2) {
          width: 8%;
        }
        /* House Column (Column 5) - Slightly Narrower */
        #students-section .table-container table th:nth-child(5),
        #students-section .table-container table td:nth-child(5) {
          width: 12%;
        }
        /* Role Column (Column 6) - Increased significantly */
        #students-section .table-container table th:nth-child(6),
        #students-section .table-container table td:nth-child(6) {
          width: 18%; 
        }
        /* Ensure dropdown fits its container */
        #students-section .table-container table td select {
          width: 100%;
          min-width: 140px;
        }
      }
    
    /* Increase badge text and icon size */
    #students-section .student-badge-item {
      padding: 14px; /* Slightly more padding for larger content */
    }
    #students-section .student-badge-emoji {
      font-size: 41.04px; /* 20% larger than 34.2px */
      width: 49.25px; /* 20% larger than 41.04px */
      height: 49.25px; /* 20% larger than 41.04px */
    }
    #students-section .student-badge-name {
      font-size: 18.47px; /* 20% larger than 15.39px */
    }
    #students-section .student-badge-points {
      font-size: 14.36px; /* 20% larger than 11.97px */
      padding: 4.1px 10.26px; /* 20% larger than 3.42px 8.55px */
    }
    
    /* Mobile card layout remains unchanged */
    @media (max-width: 1370px) {
      #students-section .student-badge-emoji {
        font-size: 36px; /* Revert to original mobile size */
        width: 44px;
        height: 44px;
      }
      #students-section .student-badge-name {
        font-size: 16px; /* Revert to original mobile size */
      }
      #students-section .student-badge-points {
        font-size: 13px; /* Revert to original mobile size */
        padding: 3px 8px;
      }
    }
    
    
    @media (max-width: 1370px) {
      #students-section .page-actions {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 0 4px;
      }
    
      #students-section .page-actions .filter-group {
        flex: 1;
        min-width: 100px;
        max-width: 50%;
      }
    
      #students-section .page-actions .btn {
        flex: 0 0 auto;
        padding: 6px 8px;
        font-size: 12px;
        min-height: 40px;
        max-width: 120px;
        white-space: nowrap;
        line-height: 1.5;
      }
    
      #students-section .page-actions .btn i {
        margin-right: 4px;
        font-size: 12px;
      }
    
      #students-section .page-actions #refresh-students-btn {
        display: none !important;
      }
    
      #students-section .page-actions .form-control {
        font-size: 14px;
        padding: 8px;
        height: 40px;
        border-radius: 6px;
      }
    
      #students-section .students-header h1 {
        flex-wrap: wrap;
        gap: 6px;
      }
    
      
    }
    
    @media (max-width: 480px) {
      #students-section .page-actions .filter-group {
        min-width: 80px;
      }
    
      #students-section .page-actions .btn {
        font-size: 11px; /* Even smaller for very narrow screens */
        padding: 5px 6px;
        max-width: 100px; /* Tighter max-width */
      }
    
      #students-section .page-actions .btn i {
        font-size: 11px;
      }
    
      #students-section .page-actions .form-control {
        font-size: 12px;
        padding: 6px;
        height: 36px;
      }
    }
    
    @media (max-width: 1370px) {
      #students-section .card .form-group-row.award-class-house {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
        margin: 0;
        align-items: stretch;
        width: 100%;
      }
      #students-section .card .form-group-row.award-class-house > div:nth-child(1) {
        display: flex;
        flex-direction: row;
        gap: 8px;
        width: 100%;
        align-items: flex-start;
      }
      #students-section .card .form-group-row.award-class-house > div:nth-child(1) > .form-group:nth-child(1),
      #students-section .card .form-group-row.award-class-house > div:nth-child(1) > .form-group:nth-child(2) {
        flex: 1;
        min-width: 0;
        max-width: 50%;
      }
      #students-section .card .form-group-row.award-class-house .form-group {
        min-width: 0;
        max-width: 100%;
        margin-bottom: 0;
      }
      #students-section .card .form-group-row.award-class-house .form-label {
        font-size: 12px;
        margin-bottom: 2px;
        font-weight: 500;
        color: var(--dark-text);
      }
      #students-section .card .form-group-row.award-class-house .form-control {
        width: 100%;
        height: 40px;
        font-size: 14px;
        padding: 8px;
        border-radius: 6px;
        border: 1px solid var(--gray-light);
        background: var(--bg-light);
        touch-action: manipulation;
      }
      #students-section .card .form-group-row.award-class-house select.form-control {
        padding-right: 24px;
        background-size: 12px;
      }
      #students-section .card .form-group-row.award-class-house .award-preview-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        width: 100%;
      }
        #students-section .card .form-group-row.award-class-house .btn {
        width: 100%;
        height: 48px;
        font-size: 16px;
        padding: 12px;
        border-radius: 8px;
        background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
        color: var(--light-text);
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
      }
      #students-section .card .form-group-row.award-class-house #pointsPreview {
        font-size: 12px;
        color: var(--primary-blue);
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
      }
      #students-section .card .form-group-row.award-class-house #housePointsOverview {
        display: none;
      }
      #students-section .card .form-group-row.award-class-house .tooltip .tooltiptext {
        top: calc(100% + 6px);
        left: 50%;
        transform: translateX(-50%);
        width: 120px;
        font-size: 10px;
      }
    }
    
    
    
    #addStudentSuccess, #editStudentSuccess, #teacherSuccess {
      background: rgba(0, 128, 0, 0.1);
      padding: 8px;
      border-radius: 4px;
    }
    
    @media (max-width: 1370px) {
      .student-card-details select[id^="roleSelect-"] {
        height: 40px; /* Increased from 32px to match other form controls */
        font-size: 14px; /* Slightly larger for readability, matches .form-control */
        padding: 8px; /* Reduced from 10px to balance space */
        line-height: 1.4; /* Ensures text is centered and not clipped */
        min-width: 100px; /* Slightly wider to accommodate longer role names */
        width: 100%; /* Ensure full width within card */
        box-sizing: border-box; /* Ensure padding doesn’t increase size */
      }
    }
    
    /* Hide Current Leaderboard on mobile */
    @media (max-width: 1370px) {
      #dashboard-section .card:has(#leaderboardBars) {
        display: none !important;
      }
    
      /* Style House Standings section on mobile */
      #dashboard-section .card:has(#houseOverview) .card-title {
        font-size: 18px;
        color: var(--primary-blue);
      }
    
      /* House card mobile styling */
     
    
    
    
      body.mobile .house-rank .rank-icon {
        font-size: 24px;
      }
    
      body.mobile .house-gap {
        font-size: 14px;
        font-weight: 600;
        color: var(--success);
        margin-top: 4px;
      }
    
      body.mobile .house-gap.negative {
        color: var(--danger);
      }
    
      body.mobile .house-progress {
        margin: 8px 0;
      }
      body.mobile .progress-bar {
        height: 8px;
        background: var(--gray-light);
        border-radius: 4px;
        width: 100%;
        max-width: 100%;
      }
      body.mobile .progress-fill {
        height: 100%;
        border-radius: 4px;
        background: var(--house-color);
        transition: width 0.3s ease;
        width: calc(var(--house-points, 0) / 10000 * 100%);
      }
    
    /* Floating Dashboard Cards - Fixed Edge Spacing */
              body.mobile .house-card {
                /* 16px left/right margin pulls cards away from the screen glass */
                margin: 0 16px 16px 16px !important; 
                padding: 12px;
                border-radius: 12px !important; 
                box-shadow: 0 4px 10px rgba(0,0,0,0.06) !important; 
                border: 1px solid #e2e8f0 !important; 
                background: var(--card-light);
                display: flex;
                flex-direction: column;
                gap: 8px;
                position: relative;
                min-height: 180px;
                --house-color: #1e40af; /* Fallback */
              }
      body.mobile .house-rank {
        font-size: 24px;
        font-weight: 800;
        color: var(--primary-blue);
        display: flex;
        align-items: center;
        gap: 6px;
        margin-bottom: 4px;
      }
      body.mobile .house-stats {
        display: none; /* Hide student count */
      }
    
      body.mobile .house-leaders {
        font-size: 11px;
        color: var(--primary-blue);
        margin-top: 6px;
      }
    
      /* Ensure house grid is single-column on mobile */
      body.mobile .house-grid {
        grid-template-columns: 1fr;
        gap: 8px;
      }
    }
    
    /* Ensure desktop remains unchanged */
    @media (min-width: 769px) {
      #dashboard-section .card:has(#leaderboardBars) {
        display: block !important;
      }
    
      .house-card {
        --house-color: var(--house-color, #1e40af); /* Maintain existing color logic */
      }
    
      .progress-fill {
        background: var(--house-color, linear-gradient(90deg, var(--primary-blue), var(--gradient-end)));
      }
    }
    
    
    /* Award Points Form Toggle */
    .award-class-house-container {
      width: 100%;
      margin-bottom: 12px;
    }
    
    .award-toggle-header {
      display: none; /* Hidden on desktop by default */
    }
    
    .award-toggle-header:hover {
      background: var(--primary-hover);
    }
    
    .award-toggle-title {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    
    .award-toggle-icon {
      font-size: 16px;
      transition: transform 0.3s ease;
    }
    
    .award-toggle-header.collapsed .award-toggle-icon {
      transform: rotate(0deg);
    }
    
    .award-toggle-header.expanded .award-toggle-icon {
      transform: rotate(180deg);
    }
    
    @media (max-width: 1370px) {
    .award-toggle-header {
      display: none; /* Hidden on desktop by default */
      padding: 12px;
      background: var(--primary-blue);
      color: var(--light-text);
      font-size: 16px;
      font-weight: 600;
      border-radius: var(--radius-md);
      cursor: pointer;
      user-select: none;
      display: flex;
      justify-content: space-between;
      align-items: center;
      transition: background 0.2s ease;
    }
      .award-class-house-container .award-class-house {
        display: none; /* Collapsed by default */
        opacity: 0;
        max-height: 0;
        overflow: hidden;
        transition: opacity 0.3s ease, max-height 0.3s ease;
      }
    
      .award-class-house-container .award-class-house.expanded {
        display: flex;
        opacity: 1;
        max-height: 500px; /* Adjust based on form height */
      }
    }
    
    /* UPDATED: Only force expand on screens larger than iPad Pro */
    /* --- REMOVE OLD HEADER FORM --- */
    @media (min-width: 1371px) {
      .award-class-house-container, 
      .award-toggle-header, 
      #awardForm, 
      .house-points-container {
        display: none !important;
      }
      
      /* Move the search bar up to fill the gap */
      .data-table-toolbar {
        margin-top: 0 !important;
        padding-top: 10px;
      }
    }
    
    @media (max-width: 1370px) {
      body.mobile .toast-central,
      .toast-central {
        display: none !important;
      }
    
      .house-captains-title {
      font-size: 12px;
      font-weight: 400;
      color: var(--primary-blue);
      margin-bottom: 8px;
    }
    }
    
    
    
    .house-captains-title {
      font-size: 14px;
      font-weight: 600;
      color: var(--primary-blue);
      margin-bottom: 8px;
    }
    .house-captains-list {
      display: grid;
      gap: 12px;
      font-size: 12px;
      justify-content: center;
      width: 100%;
      max-width: 800px;
      margin: 0 auto;
    }
    
    .house-captains-list .captains-row {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 12px;
    }
    
    /* Mobile: 2 per row */
    @media (max-width: 1370px) {
      .house-captains-list .captains-row {
        grid-template-columns: repeat(2, 1fr);
      }
    }
    
    /* Single captain row: center it */
    .house-captains-list .captains-row:has(.captain-item:nth-child(1):last-child) {
      grid-template-columns: 1fr;
    }
    .house-captains-list .captains-row:has(.captain-item:nth-child(2):last-child) {
      grid-template-columns: repeat(2, 1fr);
    }
    .captains-row {
      display: flex;
      gap: 16px;
      width: 100%;
    }
    .captain-item {
      flex: 1;
      display: flex;
      align-items: center;
      padding: 8px;
      background: var(--light);
      border-radius: var(--radius-sm);
    }
    .captain-item::before {
      content: "•";
      color: var(--primary-blue);
      margin-right: 8px;
    }
    .no-captains {
      font-style: italic;
      color: var(--gray);
      width: 100%;
      padding: 8px;
    }
    
    /* Add New Student Modal */
    #addStudentModal {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.65);
      z-index: 80000 !important; /* Boosted to sit above the detail modal */
      display: none;
      justify-content: center;
      align-items: center;
      opacity: 0;
      transition: opacity 0.3s ease;
    }
    
    #addStudentModal.show {
      display: flex;
      opacity: 1;
    }
    
    #addStudentModal .modal-content {
      background: var(--card-light);
      border-radius: 8px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
      max-width: 400px;
      width: 90%;
      padding: 20px;
      transform: scale(0.8);
      transition: transform 0.3s ease;
    }
    
    #addStudentModal.show .modal-content {
      transform: scale(1);
    }
    
    #addStudentModal .form-group {
      margin-bottom: 15px;
    }
    
    #addStudentModal .form-control {
      width: 100%;
      padding: 8px;
      font-size: 14px;
      border: 1px solid var(--gray-light);
      border-radius: var(--radius-sm);
      background: var(--bg-light);
    }
    
    #addStudentModal label {
      display: block;
      margin-bottom: 5px;
      font-weight: 500;
      color: var(--dark-text);
    }
    
    #addStudentModal .btn {
      padding: 8px 16px;
      font-size: 14px;
      border-radius: var(--radius-sm);
    }
    
    @media (max-width: 1370px) {
      #addStudentModal {
        padding: 0 !important; /* Remove outer overlay padding */
        align-items: flex-start !important; /* Align to top of screen */
      }
    
      #addStudentModal .modal-content {
        width: 100vw !important; /* Force full viewport width edge-to-edge */
        max-width: none !important; /* Remove any desktop width limits */
        height: 100vh !important; /* Full height */
        max-height: none !important;
        margin: 0 !important;
        padding: 20px !important;
        border-radius: 0 !important; /* Square edges for full-screen look */
        overflow-y: auto;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
      }
      
      /* Ensure the close button is easily reachable in the corner */
      #addStudentModal .house-expanded-close {
        top: 15px !important;
        right: 15px !important;
        z-index: 100;
      }
      #addStudentModal .form-control {
        font-size: 14px;
        padding: 10px;
        height: 40px;
      }
      #addStudentModal .btn {
        font-size: 14px;
        padding: 10px;
        width: 100%;
        min-height: 40px;
      }
      #addStudentModal .form-group {
        margin-bottom: 12px;
      }
      #editStudentModal {
        padding: 0 !important;
        align-items: flex-start !important; /* Align to top of screen */
      }

      #editStudentModal .modal-content {
        width: 100vw !important; /* Force full viewport width edge-to-edge */
        max-width: none !important; /* Override inline desktop max-width */
        height: 100vh !important; /* Full height */
        max-height: none !important;
        margin: 0 !important;
        padding: 20px !important;
        border-radius: 0 !important; /* Square edges for full-screen look */
        overflow-y: auto;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
      }
      #editStudentModal .form-control {
        font-size: 14px;
        padding: 10px;
        height: 40px;
      }
      #editStudentModal .btn {
        font-size: 14px;
        padding: 10px;
        width: 100%;
        min-height: 40px;
      }
      #editStudentModal .form-group {
        margin-bottom: 12px;
      }
    }
    
    @media (max-width: 480px) {
      #addStudentModal .modal-content {
        width: 100%;
        padding: 12px;
        border-radius: 8px;
      }
    
      #addStudentModal .form-control {
        font-size: 12px;
        padding: 8px;
        height: 36px;
      }
    
      #addStudentModal .btn {
        font-size: 12px;
        padding: 8px;
        min-height: 36px;
      }
    }
    
    
    /* Edit Student Modal */
    #editStudentModal {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.65);
      z-index: 80000 !important; /* Boosted to sit above the detail modal */
      display: none;
      justify-content: center;
      align-items: center;
      opacity: 0;
      transition: opacity 0.3s ease;
    }
    
    #editStudentModal.show {
      display: flex;
      opacity: 1;
    }
    
    #editStudentModal .modal-content {
      background: var(--card-light);
      border-radius: 8px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
      max-width: 400px;
      width: 90%;
      padding: 20px;
      transform: scale(0.8);
      transition: transform 0.3s ease;
    }
    
    #editStudentModal.show .modal-content {
      transform: scale(1);
    }
    
    #editStudentModal .form-group {
      margin-bottom: 15px;
    }
    
    #editStudentModal .form-control {
      width: 100%;
      padding: 8px;
      font-size: 14px;
      border: 1px solid var(--gray-light);
      border-radius: var(--radius-sm);
      background: var(--bg-light);
    }
    
    #editStudentModal label {
      display: block;
      margin-bottom: 5px;
      font-weight: 500;
      color: var(--dark-text);
    }
    
    #editStudentModal .btn {
      padding: 8px 16px;
      font-size: 14px;
      border-radius: var(--radius-sm);
    }
    
    @media (max-width: 1370px) {
      #editStudentModal .modal-content {
        width: 100%;
        height: 100vh; /* Full height */
        padding: 16px;
        margin: 0;
        border-radius: 0; /* Remove rounded corners */
        overflow-y: auto;
        box-sizing: border-box;
      }
      #editStudentModal .form-control {
        font-size: 14px;
        padding: 10px;
        height: 40px;
      }
      #editStudentModal .btn {
        font-size: 14px;
        padding: 10px;
        width: 100%;
        min-height: 40px;
      }
      #editStudentModal .form-group {
        margin-bottom: 12px;
      }
    }
    
    @media (max-width: 480px) {
      #editStudentModal .modal-content {
        width: 100%;
        padding: 12px;
        border-radius: 8px;
      }
    
      #editStudentModal .form-control {
        font-size: 12px;
        padding: 8px;
        height: 36px;
      }
    
      #editStudentModal .btn {
        font-size: 12px;
        padding: 8px;
        min-height: 36px;
      }
    }
    
    @media (max-width: 1370px) {
      .student-card {
        position: relative;
        padding-left: 12px; /* Increased from default to accommodate 4px border */
        border-left: none; /* Reset any default border */
      }
    }
    
    #schoolLogoPanel.toggle-panel {
      display: none;
      transition: opacity 0.3s ease 0.1s, max-height 0.3s ease 0.1s;
      opacity: 0;
      max-height: 0;
      overflow: hidden;
    }
    
    #schoolLogoPanel.toggle-panel.active,
    #schoolLogoPanel.toggle-panel[style*="display: block"] {
      display: block !important;
      opacity: 1 !important;
      max-height: 500px !important;
    }
    
    
    @media (max-width: 1370px) {
      /* New wrapper to force side-by-side layout */
      .mobile-dropdown-row {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        width: 100%;
        margin-bottom: 12px;
      }
    
      .mobile-dropdown-row > div {
        flex: 1; /* Ensures both dropdowns take equal width */
        min-width: 0; /* Prevents overflow */
      }
    
      #students-section .student-card-details select,
      #students-section .student-card-details input {
        font-size: 14px; /* Slightly smaller to fit side-by-side */
        padding: 8px;
        height: 42px; /* Adjusted height for better fit */
        border-radius: 8px;
        width: 100%;
      }
    
      #students-section .points-input {
        text-align: center;
        font-size: 18px;
        font-weight: 700;
        color: var(--primary-blue);
        background: rgba(30, 58, 138, 0.05);
        border: 2px solid var(--primary-blue);
      }
    
      /* Target both house and role selects */
      #students-section .student-card-details select[id^="roleSelect-"],
      #students-section .student-card-details select[id^="houseSelect-"] {
        height: 42px;
        font-size: 13px;
        padding: 4px 8px;
        width: 100%;
        box-sizing: border-box;
      }
    }

    /* Centre House name inside expanded student cards on phones only */
    @media (max-width: 780px) {
      #students-section .student-card.expanded .student-card-details select[id^="houseSelect-"] {
        text-align: center !important;
        text-align-last: center !important;
      }
    }
    
    .loading-overlay {
      position: fixed;
      inset: 0;
      /* NEW: Reduced opacity and added blur for a modern "glass" feel */
      background: rgba(255, 255, 255, 0.4); 
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px); /* Safari support */
      
      z-index: 1200;
      display: flex;
      justify-content: center;
      align-items: center;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.25s ease;
    }
    
    /* Pulse animation for empty leaderboard bars while waiting */
    .skeleton-loader {
      width: 100%;
      height: 20px;
      background: #e2e8f0;
      margin-bottom: 10px;
      border-radius: 4px;
      animation: pulse 1.5s infinite;
    }
    
    @keyframes pulse {
      0% { opacity: 1; }
      50% { opacity: 0.4; }
      100% { opacity: 1; }
    }
    
    .loading-overlay.show {
      opacity: 1;
      pointer-events: all;
    }
    
    .loading-logo {
      display: flex;
      align-items: center;
      gap: 4px;
      font-family: 'Inter', sans-serif;
      font-weight: 800;
      font-size: 48px;
      letter-spacing: -0.5px;
    
      animation: breathe 2.8s ease-in-out infinite,
                 float 2.8s ease-in-out infinite;
    }
    
    .loading-logo .track {
      color: var(--dark-text);
    }
    
    .loading-logo .edu {
      background: linear-gradient(
        110deg,
        #00e676 0%,
        #00ff00 40%,
        #7CFFB2 60%,
        #00ff00 100%
      );
      background-size: 200% 100%;
      -webkit-background-clip: text;
    background-clip: text;
      -webkit-text-fill-color: transparent;
    
      animation: shimmer 2.8s ease-in-out infinite;
    }
    
    /* Animations */
    @keyframes breathe {
      0% { transform: scale(1); }
      50% { transform: scale(1.03); }
      100% { transform: scale(1); }
    }
    
    @keyframes float {
      0% { translate: 0 0; }
      50% { translate: 0 -2px; }
      100% { translate: 0 0; }
    }
    
    @keyframes shimmer {
      0% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
      100% { background-position: 0% 50%; }
    }
    
    /* Responsive */
    @media (max-width: 1370px) {
      .loading-logo {
        font-size: 36px;
      }
    }
    
    @media (max-width: 480px) {
      .loading-logo {
        font-size: 28px;
      }
    }
    
    
    /* Search Input (Desktop) */
    .search-group {
      position: relative;
    }
    #studentSearchInput {
      padding: 8px 12px;
      font-size: 13px;
      border: 1px solid var(--gray-light);
      border-radius: var(--radius-sm);
      width: 100%;
      transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }
    #studentSearchInput:focus {
      outline: none;
      border-color: var(--primary-blue);
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    
    
    
    
    
    
    
    
    
    
    /* Global Search Modal Logic */
    #studentSearchModal {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,0.5); /* Semi-transparent for desktop */
      z-index: 12000;
      justify-content: center; /* Center on desktop */
      align-items: center;     /* Center on desktop */
    }
    
    #studentSearchModal.show {
      display: flex;
    }
    
    /* Mobile & iPad Specific - Full Screen Overrides */
    @media (max-width: 1370px) {
      #studentSearchModal {
        background: white !important; /* Opaque background for tablet/mobile */
        align-items: flex-start;      /* Align to top for tablet/mobile */
      }
    }
    
    
    
    
    
    #studentSearchInputMobile {
      padding: 10px 12px;
      font-size: 14px;
      border: 1px solid var(--gray-light);
      border-radius: var(--radius-sm);
      width: 100%;
    }
    
    
    /* Mobile Search Results */
    #searchResults {
      background: var(--light);
      border-radius: var(--radius-sm);
      border: 1px solid var(--gray-light);
      padding: 5px 0;
    }
    .search-result-item {
      padding: 18px 24px !important; /* More breathing room on iPad */
      font-size: 16px;
      color: var(--dark-text);
      cursor: pointer;
      border-bottom: 1px solid #f1f5f9;
      transition: background 0.2s ease;
      display: flex;
      flex-direction: row !important; /* Side-by-side layout for wider screens */
      align-items: center;
      justify-content: space-between;
      gap: 15px;
    }
    .search-result-item:hover,
    .search-result-item:focus {
      background: var(--gray-light);
    }
    .search-result-item:last-child {
      border-bottom: none;
    }
    .search-result-item .student-name {
      font-weight: 700;
      font-size: 22px;
    }
    .search-result-item .student-info {
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
    }
    .search-result-item .class-info,
    .search-result-item .house-info,
    .search-result-item .points-info {
      color: var(--gray);
      font-size: 19px;
    }
    .search-result-item .house-info span {
      margin-right: 4px;
    }
    .search-result-item .points-info {
      color: var(--primary-blue);
      font-weight: 900;
    }
    
    /* Highlighted Student Card */
    .student-card.highlighted {
      background: rgba(59, 130, 246, 0.1) !important;
      border: 2px solid var(--primary-blue) !important;
      animation: highlight-pulse 1s ease-in-out;
    }
    @keyframes highlight-pulse {
      0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
      50% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.3); }
      100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
    }
    
    /* Mobile Nav Search Icon */
    .mobile-nav-item .fa-search {
      font-size: 18px;
    }
    
    /* Responsive Adjustments */
    @media (max-width: 1370px) {
      .search-result-item {
        padding: 10px 12px;
      }
    }
    
    
    /* Default Search Layout (Desktop: Centered Box) */
    .student-search-layout {
      display: flex;
      flex-direction: column;
      background: white;
      padding: 25px;
      border-radius: 16px;
      width: 90%;
      max-width: 500px;
      max-height: 85vh;
      box-shadow: 0 20px 40px rgba(0,0,0,0.2);
      position: relative;
    }
    
    /* iPad & Mobile Overrides (Full Screen) */
    @media (max-width: 1370px) {
      .student-search-layout {
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 60px 20px 20px 20px !important; /* Extra top padding for the X button */
      }
    }
    
    @media (min-width: 1371px) {
      /* Restore desktop-only narrow view for very large screens if needed */
      .student-search-layout {
        max-width: 400px !important;
        margin: auto !important;
      }
    }
    /* Keep title + input fixed */
    .student-search-layout .form-group,
    .student-search-layout h2 {
      flex-shrink: 0;
    }
    
    /* Search results fill remaining height */
    #searchResults {
      flex: 1;
      overflow-y: auto;
      margin-top: 10px;
      padding: 5px 0;
    
      /* iOS smooth scrolling */
      -webkit-overflow-scrolling: touch;
    }
    
    
    
    @media (max-width: 1370px) {
      body.mobile #badgesInfoModal {
        display: none; /* Hidden by default */
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.65);
        z-index: 1100;
        justify-content: center;
        align-items: center;
        overflow: hidden;
      }
      body.mobile #badgesInfoModal.show {
        display: flex; /* Show when active */
        opacity: 1;
        pointer-events: all;
      }
      
      /* Hide houseDetailsModal on mobile */
      body.mobile #houseDetailsModal {
        display: none !important;
      }
    
    
       
    /* Update: Changed from green to a sleek, consistent branding blue */
    body.mobile .mobile-nav-item[data-section="dashboard"] {
        color: var(--primary-blue) !important; 
        background: var(--card-light) !important; /* Blends with the bar background */
        font-weight: 600;
    }
    body.mobile #badgesInfoModal.show ~ .mobile-nav {
        z-index: 1200; /* Above modal (z-index: 1100) */
        display: flex !important; /* Ensure visibility */
      }
      body.mobile #badgesInfoModal.show .house-expanded-content {
        padding-bottom: 50px; /* Match navbar height to prevent overlap */
      }
    
    
    
      
      }
    .challenges-grid {
      display: flex;
      flex-direction: column;
      gap: 24px;
      padding: 16px;
    }
    
    /* Accordion category header */
    /* Premium Category Header – light and calm */
    .challenge-category-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 18px 20px;
      background: rgba(240, 249, 245, 0.6); /* Very light green tint */
      backdrop-filter: blur(4px);
      border: 1px solid rgba(34, 197, 94, 0.15); /* Subtle green border */
      border-radius: var(--radius-lg);
      cursor: pointer;
      font-size: 18px;
      font-weight: 600;
      color: var(--dark-text);
      margin-bottom: 12px;
      transition: all 0.25s ease;
      user-select: none;
    }
    
    .challenge-category-header:hover {
      background: rgba(240, 249, 245, 0.9);
      border-color: rgba(34, 197, 94, 0.3);
      transform: translateY(-1px);
    }
    
    .challenge-category-header.active {
      background: white;
      border-color: var(--success);
      box-shadow: 0 4px 12px rgba(34, 197, 94, 0.12);
    }
    
    .challenge-category-header .chevron {
      font-size: 20px;
      color: var(--success);
      transition: transform 0.3s ease;
    }
    
    .challenge-category-header.active .chevron {
      transform: rotate(180deg);
    }
    
    /* Category Content – clean white when open */
    .challenge-category-content {
      display: none;
      padding: 24px 8px 8px;
      background: white;
      border-radius: var(--radius-lg);
      box-shadow: 0 4px 16px rgba(0,0,0,0.06);
      margin-bottom: 32px;
    }
    
    .challenge-category-content.show {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 20px;
      animation: fadeIn 0.4s ease;
    }
    
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(10px); }
      to { opacity: 1; transform: translateY(0); }
    }
    
    /* Premium Challenge Cards */
    /* Premium Challenge Cards */
    .challenge-card {
      background: white;
      border-radius: var(--radius-lg);
      padding: 24px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.08);
      transition: all 0.3s ease;
      cursor: pointer;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      
      /* UPDATED: Green Edge + darker border so it doesn't blend in */
      border: 1px solid rgba(34, 197, 94, 0.3); 
      border-left: 8px solid #10b981;
      
      height: 140px;
    }
    
    .challenge-card:hover {
      transform: translateY(-8px);
      box-shadow: 0 12px 24px rgba(34, 197, 94, 0.15);
      border-color: var(--success);
    }
    
    .challenge-card-title {
      font-size: 17px;
      font-weight: 700;
      color: var(--dark-text);
      line-height: 1.4;
      margin-bottom: 8px;
    }
    
    .challenge-card-meta {
      font-size: 13px;
      color: var(--success);
      font-weight: 500;
      opacity: 0.9;
    }
    
    .challenge-card-title {
      font-size: 16px;
      font-weight: 600;
      color: var(--dark-text);
      line-height: 1.4;
    }
    
    .challenge-card-meta {
      font-size: 13px;
      color: var(--gray);
    }
    
    /* Mode switch (left-aligned) */
    .mode-switch {
      display: flex;
      gap: 12px;
      justify-content: flex-start;
      margin: 24px 0 32px 0;
      padding: 0 16px;
    }
    
    .mode-btn {
      padding: 10px 20px;
      border-radius: var(--radius-sm);
      background: var(--gray-light);
      color: var(--dark-text);
      font-weight: 600;
      font-size: 15px;
      cursor: pointer;
      transition: all 0.2s ease;
      border: none;
    }
    
    .mode-btn.active {
      background: var(--primary-blue);
      color: white;
    }
    
    .mode-btn:hover:not(.active) {
      background: var(--gray);
    }
    
    /* During Events cards */
    /* During Events cards */
    .event-card {
      background: white;
      border-radius: var(--radius-md);
      padding: 16px;
      box-shadow: var(--shadow-sm);
      transition: transform 0.2s ease, box-shadow 0.2s ease;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 12px;
      
      /* UPDATED: Green Edge + darker border for visibility */
      border: 1px solid rgba(34, 197, 94, 0.3);
      border-left: 8px solid #10b981;
    }
    
    .event-card:hover {
      transform: translateY(-4px);
      box-shadow: var(--shadow-md);
    }
    
    .event-card-title {
      font-size: 16px;
      font-weight: 600;
      color: var(--dark-text);
      flex: 1;
    }
    
    .event-card-icon {
      font-size: 24px;
    }
    
    .event-card-button {
      font-size: 12px;
      padding: 4px 8px;
      border-radius: var(--radius-sm);
      background: var(--primary-blue);
      color: white;
    }
    
    /* Modal */
    #challengeDetailsModal {
      opacity: 0;
      transition: opacity 0.3s ease, transform 0.3s ease;
    }
    
    #challengeDetailsModal.show {
      opacity: 1;
      transform: translateY(0);
    }
    
    /* Mobile adjustments */
    @media (max-width: 1370px) {
      #challengeDetailsModal {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        transform: translateY(100vh);
      }
      #challengeDetailsModal.show {
        transform: translateY(0);
      }
    
      .challenge-category-content.show {
        grid-template-columns: 1fr;
      }
    
      .challenge-card {
        height: auto;
        min-height: 100px;
      }
    
      .mode-switch {
        justify-content: space-between;
      }
    
      .mode-btn {
        flex: 1;
        text-align: center;
      }
    }
    
    /* Premium Challenge Modal Styles */
    #challengeDetailsModal .house-expanded-content {
      max-width: 700px;
      padding: 52px 32px;         /* +40px taller on desktop */
      border-radius: 16px;        /* Curved corners on desktop */
      box-shadow: 0 20px 40px rgba(0,0,0,0.15);
      background: white;
    }
    
    /* Mobile only: tighter padding + sharp (square) corners */
    @media (max-width: 1370px) {
      #challengeDetailsModal .house-expanded-content {
       
        border-radius: 0;         /* No curved corners on mobile */
      }
    }
    
    .challenge-section {
      background: #f8fafc;
      border-radius: 12px;
      padding: 20px;
      margin-bottom: 20px;
      border-left: 4px solid var(--primary-blue);
    }
    
    .challenge-section:last-child {
      margin-bottom: 0;
    }
    
    .section-header {
      font-weight: 700;
      font-size: 18px;
      color: var(--dark-text);
      margin-bottom: 12px;
      display: flex;
      align-items: center;
      gap: 10px;
    }
    
    .section-icon {
      font-size: 24px;
    }
    
    .section-body {
      font-size: 16px;
      line-height: 1.7;
      color: #374151;
    }
    
    .numbered-list,
    .idea-list,
    .link-list {
      padding-left: 24px;
      margin: 8px 0;
    }
    
    .numbered-list li {
      margin-bottom: 8px;
      list-style: decimal;
    }
    
    .idea-list li,
    .link-list li {
      margin-bottom: 10px;
      list-style: disc;
    }
    
    .highlight-points {
      background: linear-gradient(135deg, #e0f2fe, #cffafe);
      border-left-color: #0ea5e9;
    }
    
    .points-highlight {
      font-size: 20px;
      font-weight: 700;
      color: #0369a1;
      text-align: center;
      padding: 16px;
      background: white;
      border-radius: 10px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }
    
    
    
    /* TrackEDU Logo in Header – Much smaller, refined */
    .trackedu-logo-header {
      display: inline-flex;
      align-items: center;
      font-family: 'Inter', sans-serif;
      font-weight: 800;
      font-size: 1.0rem;     /* Reduced further from 1.1rem → ~30% smaller than original 1.4rem */
      letter-spacing: -0.3px;
      margin-right: 0.6em;   /* Slightly more space before school name */
    }
    
    .trackedu-logo-header .track {
  color: var(--dark-text);
}

body.house-display-dark
.trackedu-logo-header .track {
  color: #f8fafc !important;
}
   .trackedu-logo-header .edu {
  background: linear-gradient(110deg, #00e676 0%, #00ff00 40%, #7CFFB2 60%, #00ff00 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  /* animation removed - gradient is now static */
}
    
    /* Reuse shimmer animation from loading overlay */
    @keyframes shimmer {
      0% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
      100% { background-position: 0% 50%; }
    }
    
    /* 1. Show the logo on iPad Pro and larger tablets (781px to 1370px) */
    @media (min-width: 781px) and (max-width: 1370px) {
      .trackedu-logo-header {
        display: inline-flex !important; /* Forces it to show */
        font-size: 0.9rem !important;    /* Slightly smaller for the tablet header */
      }
    }
    
    /* 2. Keep the logo hidden on standard mobile phones (780px and below) */
    @media (max-width: 780px) {
      .trackedu-logo-header {
        display: none !important;
      }
      
      /* Ensure the school name shifts to fill the gap on small screens */
      .logo-inline {
        gap: 0 !important;
      }
    }
    
    
    /* School name in header - Professional Pill Badge */
.school-name-header {
  display: inline-flex;
  align-items: center;
  background: #f8fafc;
  padding: 6px 16px;
  border-radius: 40px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: all 0.2s ease;
  white-space: nowrap;
}

/* Desktop specific */
@media (min-width: 1371px) {

  .school-name-header {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  @keyframes housepointsSchoolNameRotation {

    /* SCHOOL NAME */
    0%,
    28% {
      opacity: 1;
      visibility: visible;
      max-width: 320px;
      padding-left: 16px;
      padding-right: 16px;
      margin-left: 0;
    }

    /* COLLAPSE BEFORE UPDATE */
    33% {
      opacity: 0;
      visibility: hidden;
      max-width: 0;
      padding-left: 0;
      padding-right: 0;
      margin-left: 0;
      border-width: 0;
    }

    /* STAY GONE WHILE BOTH UPDATES SHOW */
    33%,
    95% {
      opacity: 0;
      visibility: hidden;
      max-width: 0;
      padding-left: 0;
      padding-right: 0;
      margin-left: 0;
      border-width: 0;
    }

    /* RETURN */
    100% {
      opacity: 1;
      visibility: visible;
      max-width: 320px;
      padding-left: 16px;
      padding-right: 16px;
      border-width: 1px;
    }
  }
  .logo-inline {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1 1 auto;
  }

  .housepoints-desktop-updates {
    position: relative;
    width: min(48vw, 720px);
    min-width: 360px;
    height: 34px;
    margin-left: 12px;
    overflow: hidden;
    flex: 1 1 auto;
  }

  .housepoints-desktop-update {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    text-decoration: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(5px);
    animation: housepointsDesktopUpdateRotation 24s infinite ease;
  }

  .housepoints-desktop-update:nth-child(1) {
    animation-delay: 0s;
  }

  .housepoints-desktop-update:nth-child(2) {
    animation-delay: 8s;
  }

  .housepoints-desktop-update:nth-child(3) {
    animation-delay: 16s;
  }

  .housepoints-desktop-updates:hover
  .housepoints-desktop-update {
    animation-play-state: paused;
  }

  .housepoints-desktop-update.school {
    background: #f8fafc;
  }

  .housepoints-update-school-name {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1e293b;
    font-size: 0.92rem;
    font-weight: 700;
  }

  .housepoints-update-kicker {
    flex: 0 0 auto;
    color: #64748b;
    font-size: 9px;
    line-height: 1;
    font-weight: 900;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .housepoints-update-text {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #334155;
    font-size: 11px;
    font-weight: 700;
  }

  .housepoints-update-arrow {
    flex: 0 0 auto;
    color: #16a34a;
    font-size: 11px;
    font-weight: 900;
  }

  .housepoints-desktop-update:hover {
    border-color: #bbf7d0;
    background: #f0fdf4;
  }

  @keyframes housepointsDesktopUpdateRotation {
    0% {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transform: translateY(5px);
    }

    5%,
    28% {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transform: translateY(0);
    }

    33%,
    100% {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transform: translateY(-5px);
    }
  }
}

@media (max-width: 1370px) {
  .housepoints-desktop-updates {
    display: none !important;
  }

  .school-name-header {
    display: inline-flex !important;
  }
}

/* iPad and Mobile (≤1370px) */
@media (max-width: 1370px) {
  .school-name-header {
    font-size: 0.85rem;
    padding: 5px 16px;
    margin: 0 16px;
    white-space: nowrap;
    text-align: center;
    overflow: visible;
    text-overflow: clip;
  }
  
  /* Center the entire logo container on mobile/ipad */
  .logo-inline {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    text-align: center !important;
    padding: 0 16px !important;
    box-sizing: border-box !important;
  }
  
  /* Hide the TrackEDU logo text on mobile/ipad to let school name shine */
  .trackedu-logo-header {
    display: none !important;
  }
}

/* Small mobile (≤480px) - Keep on one line, scale down font if needed */
@media (max-width: 480px) {
  .school-name-header {
    font-size: 0.7rem;
    padding: 4px 12px;
    margin: 0 12px;
    white-space: nowrap;
    text-align: center;
    overflow: visible;
    text-overflow: clip;
  }
}
    
    /* Hero Achievement Section */
    .house-hero-achievement {
      text-align: center;
    }
    
    .hero-badge-container {
      max-width: 1000px;
      margin: 0 auto;
    }
    
    .hero-badge-layout {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 40px;
      flex-wrap: wrap;
    }
    
    .desktop-only { display: flex; }
    .mobile-only { display: none; }
    
    @media (max-width: 1370px) {
      .desktop-only { display: none; }
      .mobile-only { display: block; }
      
      .hero-badge-layout {
        flex-direction: column;
        gap: 24px;
      }
    }
    
    /* Achievement Badge - Game Style (reduced ~10%) */
    .achievement-badge {
      position: relative;
      width: 252px;     /* 280px → 252px (-10%) */
      height: 252px;    /* 280px → 252px */
      background: rgba(255, 255, 255, 0.95);
      border-radius: 50%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      box-shadow: 
        0 0 36px rgba(var(--house-color-rgb), 0.3), /* slightly smaller glow */
        0 18px 36px rgba(0,0,0,0.15);
      border: 5px solid var(--house-color); /* 6px → 5px */
      animation: gentleFloat 6s ease-in-out infinite;
    }
    
    /* Mobile badge - reduced ~10% */
    .mobile-only .achievement-badge {
    width: clamp(180px, 35vw, 280px);     
      height: clamp(180px, 35vw, 280px);
      margin: 0 auto;
    }
    
    .badge-icon {
      font-size: 90px;  /* 100px → 90px (-10%) */
      margin-bottom: 14px;
      filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
    }
    
    .mobile-only .badge-icon {
      font-size: clamp(60px, 12vw, 95px); 
      margin-bottom: 10px;
    }
    
    .badge-name {
      font-size: 25px;  /* 28px → 25px (~-10%) */
      font-weight: 800;
      color: #1e293b;
      text-align: center;
      text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .mobile-only .badge-name {
      font-size: clamp(18px, 4vw, 28px);
    }
    
    /* Next badge teaser - reduced size (~10%) */
    .next-badge-teaser {
      margin-top: 22px;
      padding: 14px;    /* 16px → 14px */
      background: rgba(255,255,255,0.9);
      border-radius: 12px;
      border-left: 4px solid var(--house-color);
    }
    
    .teaser-title {
      font-size: 13px;  /* 14px → 13px */
      color: var(--gray);
      margin-bottom: 7px;
      text-transform: uppercase;
      letter-spacing: 1px;
    }
    
    .teaser-badge {
      display: flex;
      align-items: center;
      gap: 10px;        /* 12px → 10px */
      font-size: 16px;  /* 18px → 16px (-11%) */
      font-weight: 600;
      color: #1e293b;
    }
    
    /* Hide next milestone teaser completely on mobile */
    @media (max-width: 1370px) {
      .next-badge-teaser {
        display: none !important;
      }
      
      /* Extra centering for mobile layout */
      .mobile-only .hero-badge-layout {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
      }
      
      .mobile-only .mobile-badge-info {
        width: 100%;
        max-width: 300px;
      }
    }
    
    
    
    /* Swipe controls with centered stats - desktop arrows to edges */
    .house-swipe-controls.with-stats {
      display: flex;
      align-items: center;
      justify-content: space-between; /* Desktop: arrows to edges */
      gap: 24px;
      flex-wrap: wrap;
      margin-top: 28px;
      padding: 0 40px; /* Desktop: generous side padding for edge anchoring */
      max-width: 100%;
      box-sizing: border-box;
    }
    
    @media (max-width: 1370px) {
      .house-swipe-controls.with-stats {
        justify-content: space-between;
        flex-wrap: nowrap;      /* 🔑 PREVENT wrapping */
        padding: 0 12px;
        gap: 10px;
      }
    
      .house-centered-stats {
        flex: 1;                /* 🔑 allow stats to shrink */
        justify-content: center;
        min-width: 0;           /* 🔑 critical for flex shrink */
      }
    }
    
    
    .house-centered-stats {
      display: flex;
      gap: 24px;
      justify-content: center;
      flex-wrap: wrap;
    }
    
    .house-stat-item {
      text-align: center;
    }
    
    .house-stat-item .stat-value {
      font-size: 24px; /* Reduced from 28px */
      font-weight: 800;
      color: var(--house-color);
      line-height: 1.2;
    }
    
    .house-stat-item .stat-label {
      font-size: 13px; /* Slightly smaller */
      color: var(--gray);
      margin-top: 4px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }
    
    /* Mobile adjustments - even more compact */
    /* Mobile adjustments - stats reduced by ~15% */
    @media (max-width: 1370px) {
    
      
    
      .house-stat-item .stat-value {
        font-size: 14px; /* 20px → 17px (~15% smaller) */
      }
    
      .house-stat-item .stat-label {
        font-size: 12px; /* 12px → 11px */
      }
    }
    
    /* Swipe buttons - now blue and smaller */
    .swipe-btn {
      font-size: 20px; /* Reduced */
      width: 40px;
      height: 40px;
      border-radius: 50%;
      background: var(--house-color); /* Blue (house color) */
      color: white;
      border: none;
      box-shadow: 0 4px 12px rgba(0,0,0,0.15);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.2s ease;
    }
    
    .swipe-btn:hover {
      transform: scale(1.1);
    }
    
    .swipe-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }
    
    
    @media (max-width: 1370px) {
     /* Premium Mobile Navigation Bar - Clean White */
     .mobile-nav {
        height: 60px !important;
        background: #ffffff !important;
        border-top: 1px solid #f1f5f9 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-around !important;
        padding-bottom: env(safe-area-inset-bottom, 8px) !important;
        padding-top: 0 !important;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05) !important;
      }
    
      /* All mobile nav items - NO fading, solid colors */
      .mobile-nav-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        flex: 1 !important;
        height: 100% !important;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
        cursor: pointer !important;
        background: transparent !important;
        border-radius: 0 !important;
      }
      
      /* Icon base styling */
      .mobile-nav-item i {
        font-size: 22px !important;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
      }
      
      /* Text base styling */
      .mobile-nav-item span {
        font-size: 10px !important;
        font-weight: 600 !important;
        transition: all 0.2s ease !important;
      }
      
      /* Active state for regular items - Vibrant colors */
      .mobile-nav-item.active:not([data-section="dashboard"]) i {
        transform: scale(1.1) !important;
      }
      
      /* Press feedback */
      .mobile-nav-item:active {
        transform: translateY(-2px) !important;
      }
      
      .mobile-nav-item:active i {
        transform: scale(0.95) !important;
      }
    
      /* ==========================================
         INDIVIDUAL ICON COLORS - VIBRANT
         ========================================== */
      
      /* Students - Bold Blue */
      .mobile-nav-item[data-section="students"] i {
        color: #3b82f6 !important;
      }
      .mobile-nav-item[data-section="students"].active i {
        color: #1e40af !important;
        text-shadow: 0 0 8px rgba(59, 130, 246, 0.4) !important;
      }
      .mobile-nav-item[data-section="students"] span {
        color: #3b82f6 !important;
      }
      .mobile-nav-item[data-section="students"].active span {
        color: #1e40af !important;
        font-weight: 800 !important;
      }
      
      /* Toolkit - Vibrant Purple */
      .mobile-nav-item.nav-item-toolkit i {
        color: #8b5cf6 !important;
      }
      .mobile-nav-item.nav-item-toolkit.active i {
        color: #6d28d9 !important;
        text-shadow: 0 0 8px rgba(139, 92, 246, 0.4) !important;
      }
      .mobile-nav-item.nav-item-toolkit span {
        color: #8b5cf6 !important;
      }
      .mobile-nav-item.nav-item-toolkit.active span {
        color: #6d28d9 !important;
        font-weight: 800 !important;
      }
      
      /* Control/Houses - Vibrant Orange */
      .mobile-nav-item[data-section="houses"] i {
        color: #f59e0b !important;
      }
      .mobile-nav-item[data-section="houses"].active i {
        color: #d97706 !important;
        text-shadow: 0 0 8px rgba(245, 158, 11, 0.4) !important;
      }
      .mobile-nav-item[data-section="houses"] span {
        color: #f59e0b !important;
      }
      .mobile-nav-item[data-section="houses"].active span {
        color: #d97706 !important;
        font-weight: 800 !important;
      }
      
      /* Menu - Dark Slate */
      .mobile-nav-item#mobileMenuTrigger i {
        color: #475569 !important;
      }
      .mobile-nav-item#mobileMenuTrigger.active i {
        color: #0f172a !important;
      }
      .mobile-nav-item#mobileMenuTrigger span {
        color: #475569 !important;
      }
      .mobile-nav-item#mobileMenuTrigger.active span {
        color: #0f172a !important;
        font-weight: 800 !important;
      }
    
      /* ==========================================
         DASHBOARD BUTTON - PREMIUM CIRCLE
         ========================================== */
      .mobile-nav-item[data-section="dashboard"] {
        position: relative !important;
        top: -18px !important;
        width: 58px !important;
        height: 58px !important;
        min-width: 58px !important;
        max-width: 58px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border: 3px solid #ffffff !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 1000 !important;
        margin: 0 auto !important;
        flex-shrink: 0 !important;
        box-shadow: 0 8px 20px rgba(15, 102, 195, 0.3) !important;
      }
      
      .mobile-nav-item[data-section="dashboard"] i {
        font-size: 26px !important;
        margin: 0 !important;
        line-height: 1 !important;
        color: white !important;
      }
      
      /* Dashboard Inactive - Vibrant Blue Gradient */
      .mobile-nav-item[data-section="dashboard"]:not(.active) {
        background: linear-gradient(135deg, #60a5fa, #3b82f6) !important;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
      }
    
      /* Dashboard Active - TrackEDU Brand Gradient (Blue to Green) */
      .mobile-nav-item[data-section="dashboard"].active {
        background: linear-gradient(135deg, #0f66c3, #87C232) !important;
        box-shadow: 0 8px 25px rgba(15, 102, 195, 0.5) !important;
        transform: scale(1.08) !important;
      }
      
      /* Dashboard Active Pulse Animation */
      .mobile-nav-item[data-section="dashboard"].active i {
        animation: iconPulse 2s infinite ease-in-out !important;
      }
    
      /* Hide text for Dashboard button */
      .mobile-nav-item[data-section="dashboard"] span {
        display: none !important;
      }
    }
    
    @keyframes iconPulse {
      0% { transform: scale(1); opacity: 1; }
      50% { transform: scale(1.12); opacity: 0.95; }
      100% { transform: scale(1); opacity: 1; }
    }
    
    
    @media (max-width: 1370px) {
      .swipe-btn {
        font-size: 15px;
        width: 26px;
        height: 26px;
      }
    }
    
    /* Mobile-only certificate button: perfectly centered in the full page width */
    @media (max-width: 1370px) {
      .mobile-cert-btn {
        margin: 28px auto !important;     /* More breathing room from points text */
        padding: 11px 22px !important;    /* Slightly smaller */
        font-size: 15px !important;
        display: block;
        width: fit-content;
        min-width: 220px;
        max-width: 90vw;                  /* Never wider than screen */
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        text-align: center;
      }
    
      /* Force true centering within the modal content */
      .mobile-only .mobile-badge-info {
        display: flex;
        flex-direction: column;
        align-items: center;               /* Centers children horizontally */
        width: 100%;
        max-width: 100%;
      }
    
      
    }
    
    
    /* Desktop sidebar now uses one consistent navigation language. */
    .nav-item-warning {
      color:inherit;
      border-left:0;
    }

    .nav-item-warning i {
      color:inherit;
    }

    .nav-item-warning:hover {
      background:#f8fafc;
    }
    .mobile-nav-item-warning i {
      color: #f59e0b; /* orange icon */
    }
    
    .mobile-nav-item-warning.active {
      background: rgba(245, 158, 11, 0.12);
    }
    
    .mobile-nav-item-warning.active span {
      color: #1e3a8a; /* navy blue text */
      font-weight: 600;
    }
    
    .top-student-name-mobile {
      font-size: 15px; /* Desktop size */
    }
    
    @media (max-width: 1370px) {
      .top-student-name-mobile {
        font-size: 13px; /* Smaller on mobile */
      }
    }
    
    
    /* Fullscreen modal overrides */
    .fullscreen-modal {
      align-items: flex-start !important;
      justify-content: flex-start !important;
      padding: 0 !important;
    }
    
    .fullscreen-content {
      width: 100vw !important;
      height: 100vh !important;
      max-width: none !important;
      max-height: none !important;
      border-radius: 0 !important;
      padding: 0 !important;
      display: flex;
      flex-direction: column;
    }
    
    .fullscreen-modal-header {
      background: var(--primary-blue);
      color: white;
      padding: 16px 24px;
      text-align: center;
      flex-shrink: 0;
      box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .fullscreen-modal-header .house-expanded-title {
      color: white;
      font-size: 20px;
      margin: 0;
      font-weight: 700;
    }
    
    .fullscreen-table {
      flex: 1;
      overflow-y: auto;
      padding: 16px 24px;
    }
    
    .fullscreen-table table {
      width: 100%;
      border-collapse: separate;
      border-spacing: 0 8px;
    }
    
    .fullscreen-table thead th {
      background: var(--gray-light);
      color: var(--dark-text);
      font-weight: 600;
      padding: 12px 16px;
      position: sticky;
      top: 0;
      z-index: 1;
    }
    
    .fullscreen-table tbody tr {
      background: white;
      box-shadow: var(--shadow-sm);
      border-radius: 8px;
    }
    
    .fullscreen-table tbody td {
      padding: 16px;
      background: white;
    }
    
    .fullscreen-table tbody tr:first-child td {
      font-weight: 700;
      background: rgba(255,215,0,0.1);
    }
    
    /* Mobile adjustments */
    @media (max-width: 1370px) {
      .fullscreen-modal-header {
        padding: 12px 16px;
      }
      
      .fullscreen-modal-header .house-expanded-title {
        font-size: 18px;
      }
      
      .fullscreen-table {
        padding: 12px 16px;
      }
      
      .fullscreen-table tbody td {
        padding: 12px;
        font-size: 15px;
      }
    }
    
    /* Class Leaderboard Cards – Modern Layout */
    .class-leaderboard-cards {
      flex: 1;
      overflow-y: auto;
      padding: 16px 24px;
      display: flex;
      flex-direction: column;
      gap: 16px;
    }
    
    /* Top classes container – special layout */
    .class-top-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 16px;
      margin-bottom: 16px;
    }
    
    /* Rest of classes – normal stacked cards */
    .class-rest-list {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    
    /* Mobile overrides */
    @media (max-width: 1370px) {
      .class-top-grid {
        grid-template-columns: 1fr; /* 1st, 2nd, 3rd, 4th each take full row */
      }
      
      .class-rest-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr); /* 5th onwards: 2 per row */
        gap: 12px;
      }
      
      .class-leaderboard-cards {
        padding: 12px 16px;
        gap: 12px;
      }
    }
    
    /* Desktop: All groups use 4-column grid */
    @media (min-width: 769px) {
      .class-top-grid,
      .class-rest-group {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
      }
      
      .class-rest-list {
        display: flex;
        flex-direction: column;
        gap: 16px;
      }
    }

        /* --- CLASS REWARDS CARD STYLES --- */
        .reward-card {
      background: #f8fafc;
      border-radius: 16px;
      padding: 16px;
      border: 1px solid #e2e8f0;
      transition: all 0.3s ease;
      position: relative;
      overflow: hidden;
    }
    
    .reward-card.unlocked {
      background: linear-gradient(135deg, #f0fdf4, #dcfce7);
      border-left: 4px solid #10b981;
    }
    
    .reward-card.locked {
      opacity: 0.8;
    }


    /* Reward Grid Layout - Responsive */
    .rewards-grid-container {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    
    .rewards-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 16px;
    }
    
    
    .reward-progress {
      height: 6px;
      background: #e2e8f0;
      border-radius: 3px;
      overflow: hidden;
      margin: 12px 0;
    }
    
    .reward-progress-fill {
      height: 100%;
      background: linear-gradient(90deg, #3b82f6, #22d3ee);
      border-radius: 3px;
      transition: width 0.5s ease;
    }
    
    .reward-card.unlocked .reward-progress-fill {
      background: linear-gradient(90deg, #10b981, #34d399);
    }
    
    @keyframes rewardUnlock {
      0% { transform: scale(1); background: #f8fafc; }
      50% { transform: scale(1.02); background: #fef3c7; border-color: #f59e0b; }
      100% { transform: scale(1); background: #f0fdf4; border-left-color: #10b981; }
    }
    
    .reward-unlock-animation {
      animation: rewardUnlock 0.6s ease-out forwards;
    }
    
    .class-rank-card {
      background: white;
      border-radius: 12px;
      padding: 16px 20px;
      box-shadow: var(--shadow-sm);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      transition: transform 0.2s ease, box-shadow 0.2s ease;
      border-left: 4px solid var(--gray-light);
    }
    
    .class-rank-card:hover {
      transform: translateY(-2px);
      box-shadow: var(--shadow-md);
    }
    
    /* Top 3 celebration */
    .class-rank-card.rank-1 {
      background: rgba(255, 215, 0, 0.1);
      border-left-color: #FFD700;
    }
    .class-rank-card.rank-2 {
      background: rgba(192, 192, 192, 0.1);
      border-left-color: #C0C0C0;
    }
    .class-rank-card.rank-3 {
      background: rgba(205, 127, 50, 0.1);
      border-left-color: #CD7F32;
    }
    
    /* Rank badge */
    .class-rank-badge {
      width: 48px;
      height: 48px;
      border-radius: 50%;
      background: var(--gray-light);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      font-weight: 800;
      flex-shrink: 0;
    }
    
    .rank-1 .class-rank-badge {
      background: #FFD700;
      color: #1e293b;
    }
    .rank-2 .class-rank-badge {
      background: #C0C0C0;
      color: #1e293b;
    }
    .rank-3 .class-rank-badge {
      background: #CD7F32;
      color: white;
    }
    
    /* Class info */
    .class-info {
      flex: 1;
      min-width: 0;
    }
    .class-name {
      font-size: 18px;
      font-weight: 700;
      color: var(--dark-text);
      margin-bottom: 4px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .class-students {
      font-size: 13px;
      color: var(--gray);
    }
    
    /* Points */
    .class-points {
      font-size: 20px;
      font-weight: 800;
      color: var(--primary-blue);
      text-align: right;
      white-space: nowrap;
    }




/* Desktop: 4 cards per row */
@media (min-width: 1025px) {
      .rewards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
      }
    }
    
    /* Tablet (iPad): 4 cards per row, slightly smaller gap */
    @media (min-width: 768px) and (max-width: 1024px) {
      .rewards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
      }
      
      .reward-card {
        padding: 12px !important;
      }
      
      .reward-card h4 {
        font-size: 14px !important;
      }
      
      .reward-card p {
        font-size: 10px !important;
      }
      
      .reward-icon {
        font-size: 24px !important;
      }
    }
    
    /* Mobile: 2 cards per row */
    @media (max-width: 767px) {
      .rewards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
      }
      
      .reward-card {
        padding: 12px !important;
      }
      
      .reward-card h4 {
        font-size: 13px !important;
      }
      
      .reward-card p {
        font-size: 10px !important;
      }
      
      .reward-icon {
        font-size: 24px !important;
      }
      
      .reward-status {
        font-size: 9px !important;
        padding: 2px 8px !important;
      }
    }
    
    /* Reward Card Inner Styles */
    .reward-card {
      background: #f8fafc;
      border-radius: 16px;
      padding: 16px;
      border: 1px solid #e2e8f0;
      transition: all 0.3s ease;
      position: relative;
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }
    
    .reward-header {
      display: flex;
      align-items: flex-start;
      gap: 12px;
      margin-bottom: 12px;
    }
    
    .reward-icon {
      font-size: 32px;
      flex-shrink: 0;
    }
    
    .reward-info {
      flex: 1;
      min-width: 0;
    }
    
    .reward-title {
      font-weight: 800;
      font-size: 15px;
      color: #1e293b;
      margin: 0 0 4px 0;
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      flex-wrap: wrap;
      gap: 4px;
    }
    
    .reward-threshold {
      font-size: 10px;
      font-weight: 700;
      color: #64748b;
      white-space: nowrap;
    }
    
    .reward-description {
      font-size: 11px;
      color: #64748b;
      margin: 0;
      line-height: 1.4;
    }
    
    .reward-progress {
      margin: 12px 0 8px 0;
    }
    
    .reward-progress-bar {
      height: 6px;
      background: #e2e8f0;
      border-radius: 3px;
      overflow: hidden;
    }
    
    .reward-progress-fill {
      height: 100%;
      background: linear-gradient(90deg, #3b82f6, #22d3ee);
      border-radius: 3px;
      transition: width 0.5s ease;
    }
    
    .reward-card.unlocked .reward-progress-fill {
      background: linear-gradient(90deg, #10b981, #34d399);
    }
    
    .reward-stats {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 8px;
    }
    
    .reward-points-text {
      font-size: 10px;
      color: #64748b;
    }
    
    .reward-status {
      background: #f1f5f9;
      color: #475569;
      padding: 4px 12px;
      border-radius: 20px;
      font-size: 10px;
      font-weight: 700;
      white-space: nowrap;
    }
    
    .reward-card.unlocked .reward-status {
      background: #10b981;
      color: white;
    }
    
    .rewards-toggle-btn {
      background: none;
      border: 1px solid #e2e8f0;
      color: #3b82f6;
      padding: 10px;
      border-radius: 12px;
      width: 100%;
      font-weight: 600;
      cursor: pointer;
      margin-top: 16px;
      transition: all 0.2s ease;
    }
    
    .rewards-toggle-btn:hover {
      background: #f8fafc;
      border-color: #cbd5e1;
    }
    
    @keyframes rewardUnlock {
      0% { transform: scale(1); background: #f8fafc; }
      50% { transform: scale(1.02); background: #fef3c7; border-color: #f59e0b; }
      100% { transform: scale(1); background: #f0fdf4; border-left-color: #10b981; }
    }
    
    .reward-unlock-animation {
      animation: rewardUnlock 0.6s ease-out forwards;
    }


    
    /* Mobile adjustments */
    @media (max-width: 1370px) {
      .class-leaderboard-cards {
        padding: 12px 16px;
        gap: 10px;
      }
      .class-rank-card {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 12px;
      }
      .class-rank-badge {
        width: 40px;
        height: 40px;
        font-size: 16px;
      }
      .class-name {
        font-size: 17px;
      }
      .class-points {
        font-size: 18px;
        width: 100%;
        text-align: left;
      }
      .class-info {
        order: 2;
        width: calc(100% - 52px);
      }
      .class-points {
        order: 3;
        margin-left: auto;
      }
    }
    
    /* Mobile Award History: Premium App Card Style - FIXED */
    @media (max-width: 1370px) {
      
      /* 1. NUCLEAR HEADER REMOVAL - High Specificity */
      #awardHistoryModal #awardHistoryTable thead, 
      #awardHistoryModal #awardHistoryTable thead tr, 
      #awardHistoryModal #awardHistoryTable thead th { 
        display: none !important; 
        visibility: hidden !important;
        height: 0 !important;
        width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        position: absolute !important; /* Removes it from flow entirely */
        top: -9999px !important;
      }
      
      /* 2. RESET TABLE LAYOUT - Stop the jamming */
      #awardHistoryModal #awardHistoryTable, 
      #awardHistoryModal #awardHistoryTable tbody, 
      #awardHistoryModal #awardHistoryTable tr, 
      #awardHistoryModal #awardHistoryTable td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
      }
    
      /* Remove table background to let cards stand out */
      #awardHistoryModal #awardHistoryTable {
        background: transparent !important;
        border: none !important;
      }
    
      /* 3. CARD DESIGN FOR ROWS */
      #awardHistoryModal #awardHistoryTable tr.mobile-history-row {
        background: #ffffff !important;
        border-radius: 12px !important;
        margin-bottom: 16px !important; 
        box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important;
        /* Use the variable for dynamic color, default to blue */
        border-left: 6px solid var(--house-color, #1e40af) !important;
        overflow: hidden !important;
        padding: 0 !important;
        border-top: none !important;
        border-right: none !important;
        border-bottom: none !important;
        position: relative !important;
      }
    
      /* 4. RESET CELL STYLES */
      #awardHistoryModal #awardHistoryTable td {
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
      }
    
      /* 5. APP-LIKE CARD COMPONENTS */
      .history-card-header {
        padding: 16px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        background: white;
      }
    
      .history-card-info {
        display: flex;
        flex-direction: column;
        gap: 4px;
      }
    
      .history-card-date {
        font-size: 11px;
        color: var(--gray);
        font-weight: 700;
        text-transform: uppercase;
      }
    
      .history-card-house {
        font-size: 18px;
        font-weight: 800;
        color: var(--dark-text);
      }
    
      .history-card-points {
        font-size: 20px;
        font-weight: 900;
        padding: 6px 14px;
        border-radius: 50px;
        background: #f8fafc; /* Light pill background */
        min-width: 65px;
        text-align: center;
      }
    
      .history-card-details {
        display: none; /* Hidden by default */
        padding: 16px;
        background: #fcfdfe;
        border-top: 1px solid #f1f5f9;
      }
    
      /* Show details when the row has 'expanded' class */
      tr.expanded .history-card-details {
        display: block !important;
      }
    
      .detail-row {
        margin-bottom: 12px;
        font-size: 14px;
        color: #475569;
      }
    
      .detail-label {
        font-weight: 700;
        color: var(--gray);
        display: block; 
        font-size: 10px;
        text-transform: uppercase;
        margin-bottom: 2px;
      }
    
      /* Undo Button full width */
      .history-card-actions .btn-danger {
        width: 100% !important;
        padding: 12px !important;
        border-radius: 10px !important;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
      }
    }
    
    
    
    
        /* Mobile (under 780px) - 1 column */
        @media (max-width: 780px) {
      #systemSetupModal .grid-cols-1,
      #systemSetupModal .grid-cols-2,
      #systemSetupModal .setup-cards-container {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
      }
    }
    
    /* iPad/Tablet (781px to 1370px) - 2 columns */
    @media (min-width: 781px) and (max-width: 1370px) {
      #systemSetupModal .setup-cards-container {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
      }
      
      #systemSetupModal .import-section-container {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
      }
      
      #systemSetupModal .filters-stack {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
      }
      
      #systemSetupModal .filters-stack .form-group {
        margin-bottom: 0 !important;
      }
      
      #systemSetupModal .bulk-balance-buttons {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
      }
    }
    
    /* ==========================================
       DESKTOP SYSTEM SETUP
       Layout is controlled by the Settings Hub
       further below.
       Do not force setup/import sections visible here.
       ========================================== */
    
    
    
    
    /* --- MOBILE FILTER LAYOUT: 2x2 GRID --- */
    @media (max-width: 1370px) {
    
    
    
        /* Force modal content to full screen on mobile */
        .house-expanded-content,
    .modal-content,
    .toolkit-fullscreen-content {
      padding-top: 70px !important; 
      padding-bottom: 20px !important; /* Ensure bottom spacing is consistent */
    }

        /* 🔥 FIX: Teacher Toolkit should have reduced top padding */
    #teacherToolkitModal .toolkit-fullscreen-content {
      padding-top: 20px !important;
    }

        /* 🔥 FIX: Remove global padding from Ranking modals */
    #classLeaderboardModal .house-expanded-content,
    #classInsightModal .house-expanded-content {
      padding-top: 0 !important;
      padding-bottom: 0 !important;
    }
    
    /* 🔥 FIX: Award History Modal should NOT have the global padding */
    #awardHistoryModal .house-expanded-content {
      padding-top: 0 !important;
      padding-bottom: 0 !important;
    }


    /* ==========================================
       AWARD HISTORY FILTERS - MOBILE / IPAD
       ========================================== */

    #teacherAwardHistoryTab > div:first-child {
      grid-template-columns:
        repeat(2, minmax(0, 1fr)) !important;

      gap:
        10px !important;

      padding:
        12px 14px !important;
    }


    #teacherAwardHistoryTab > div:first-child
    select.form-control {

      width:
        100% !important;

      min-width:
        0 !important;

      max-width:
        100% !important;

      height:
        46px !important;

      padding:
        0 34px 0 12px !important;

      font-size:
        14px !important;

      font-weight:
        650 !important;

      line-height:
        46px !important;

      white-space:
        nowrap !important;

      overflow:
        hidden !important;

      text-overflow:
        ellipsis !important;

      border-radius:
        10px !important;

      box-sizing:
        border-box !important;
    }


    /* Phones */
    @media (max-width: 520px) {

      #teacherAwardHistoryTab > div:first-child {
        grid-template-columns:
          repeat(2, minmax(0, 1fr)) !important;

        gap:
          8px !important;

        padding:
          10px 12px !important;
      }


      #teacherAwardHistoryTab > div:first-child
      select.form-control {

        height:
          44px !important;

        font-size:
          13px !important;

        line-height:
          44px !important;

        padding:
          0 30px 0 10px !important;
      }

    }


    /* 🔥 FIX: Ensure X button is visible on mobile/iPad */
    #awardHistoryModal .house-expanded-close {
      top: 12px !important;
      right: 12px !important;
      width: 36px !important;
      height: 36px !important;
      background: #ef4444 !important;
      z-index: 9999 !important;
    }
    
    /* Fix for System Setup Modal - prevent horizontal overflow */
    #systemSetupModal .house-expanded-content {
      overflow-x: hidden !important;
      width: 100% !important;
      box-sizing: border-box !important;
    }
    
    
    
    /* Fix for Weekly Brain-Teaser, Student Voice Poll, House Engagement Poster */
    #weeklyQuizModal .house-expanded-content,
    #studentPollModal .house-expanded-content,
    #housePosterModal .house-expanded-content {
      overflow-x: hidden !important;
      width: 100% !important;
      box-sizing: border-box !important;
      padding: 60px 20px 20px 20px !important;
    }
    
    #weeklyQuizModal .card,
    #studentPollModal .card,
    #housePosterModal .card {
      width: 100% !important;
      max-width: 100% !important;
      margin: 0 0 20px 0 !important;
      box-sizing: border-box !important;
    }
    
    #weeklyQuizModal .form-control,
    #studentPollModal .form-control,
    #housePosterModal .form-control {
      width: 100% !important;
      box-sizing: border-box !important;
    }
    
      
    
      /* 1. Stack the Title and Filter Container vertically */
      #awardHistoryModal .modal-header {
        flex-direction: column !important;
        align-items: center !important;
        gap: 12px !important;
        padding: 12px !important;
        margin-bottom: 0 !important;
        border-bottom: 1px solid #f1f5f9;
        position: relative; /* For close button positioning */
      }
    
      /* 2. Target the filter container div - make all 3 dropdowns side by side */
      #awardHistoryModal .modal-header > div {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        width: 100% !important;
        margin-right: 0 !important;
        justify-content: space-between !important;
      }
    
      /* 3. Reset form groups to fit in a row */
      #awardHistoryModal .modal-header .form-group {
        min-width: 0 !important;
        width: auto !important;
        flex: 1 !important;
        margin: 0 !important;
      }
      
      /* 4. Make the select boxes full width within their containers */
      #awardHistoryModal .modal-header select.form-control {
        width: 100% !important;
        min-width: 0 !important;
        font-size: 12px !important;
        padding: 0 24px 0 8px !important;
        height: 38px !important;
      }
      
      /* 5. Adjust title to be smaller on mobile to fit */
      #awardHistoryModal .house-expanded-title {
        font-size: 16px !important;
        width: 100%;
        text-align: center;
        margin: 0 !important;
      }
    
      /* 4. Style the Select boxes to look like "App Buttons" */
      #awardHistoryModal .modal-header select.form-control {
        height: 42px !important; /* Touch-friendly height */
        font-size: 13px !important;
        font-weight: 600 !important;
        color: #334155 !important; /* Slate color */
        background-color: #f8fafc !important; /* Light background */
        border: 1px solid #cbd5e1 !important;
        border-radius: 12px !important; /* Modern rounded corners */
        padding: 0 12px !important;
        width: 100% !important;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
        appearance: none; /* Removes default ugly browser arrow */
        -webkit-appearance: none;
        /* Add a custom SVG arrow icon */
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
        background-repeat: no-repeat !important;
        background-position: right 10px center !important;
        background-size: 16px !important;
      }
    
      /* 5. Title Adjustments */
      #awardHistoryModal .house-expanded-title {
        font-size: 18px !important;
        width: 100%;
        text-align: center;
        margin: 0 !important;
      }
    
     
    }
    
    /* Color coding for audit clarity */
    .text-success { 
      color: #10b981 !important; /* Vibrant Green */
    }
    
    .text-danger { 
      color: #ef4444 !important; /* Vibrant Red */
    }
    
    
    
    /* UPDATED: Ensures dead-center positioning and top-layer priority */
    .fullscreen-loading-overlay {
      position: fixed;      /* Fixes it to the viewport, not the container */
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: rgba(15, 23, 42, 0.9); /* Darker, premium slate for better focus */
      backdrop-filter: blur(10px);      /* Modern glass effect */
      display: flex;
      justify-content: center;
      align-items: center;
      z-index: 20000;      /* Higher than the fullscreen container (10001) */
      pointer-events: all; /* Prevents clicking things behind it while loading */
    }
    
    .fullscreen-loading-overlay .loading-content {
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 24px;
    }
    
    
    /* Multi-select visual feedback */
    @media (max-width: 1370px) {
      .student-card.selected {
        border: 3px solid var(--success) !important;
        background-color: rgba(16, 185, 129, 0.1) !important;
        transform: scale(0.98);
      }
    
      
    }
    
    /* --- RESPONSIVE MODAL OVERRIDES (iPad Edge-to-Edge) --- */
    @media (max-width: 1370px) {
      #modal.house-expanded,
      #posterPreviewModal.house-expanded {
        padding: 0 !important; 
        align-items: flex-start !important;
      }
    
      #modal .house-expanded-content,
      #posterPreviewModal .house-expanded-content {
        width: 100vw !important;    
        height: 100vh !important;   
        max-width: none !important; 
        max-height: none !important;
        border-radius: 0 !important; 
        margin: 0 !important;
        padding: 20px !important;
        padding-top: 80px !important; /* Space for the X button */
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
      }
    
      /* Ensure the poster image scales within the full-width modal */
      #posterImagePreview img {
    width: 100% !important;
    height: auto !important;
    max-height: 75vh; /* Increased from 60vh to prevent cropping the tall poster */
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
    
    
      /* Make the house rows slightly larger for easier tapping on mobile */
      .class-breakdown-row {
        padding: 16px !important;
        font-size: 1.1rem;
      }
    
    }
      
    /* ==========================================
       MILESTONE EDITORS
       House + Student use distinct visual modes
       ========================================== */

    .milestone-editor-header {
      padding-bottom: 14px;
      margin-bottom: 10px;
      border-bottom: 1px solid #e2e8f0;
    }


    .milestone-editor-context {
      display: inline-flex;
      align-items: center;
      gap: 6px;

      margin-bottom: 7px;

      padding: 4px 9px;

      border-radius: 999px;

      background: #eff6ff;
      color: #1d4ed8;

      font-size: 9px;
      font-weight: 850;

      letter-spacing: 0.7px;
      text-transform: uppercase;
    }


    .milestone-editor-subtitle {
      font-size: 13px;
      line-height: 1.45;

      color: var(--gray);

      margin:
        5px
        0
        0;
    }


    /* Desktop Layout */
    .milestone-row-content {
      display: grid !important;

      grid-template-columns:
        80px
        150px
        60px
        80px
        1fr
        50px !important;

      gap: 12px !important;

      align-items: end !important; 

      padding: 12px !important;

      background: white;

      border:
        1px solid
        #e5e7eb;

      border-radius: 12px;
    }


    .mr-color input[type="color"] {
      width: 44px !important;
      height: 40px !important;

      padding: 2px !important;

      cursor: pointer;
    }


    .mr-delete .btn-danger {
      width: 40px !important;
      height: 40px !important;

      padding: 0 !important;

      display: flex !important;

      align-items: center;
      justify-content: center;
    }


    /* ==========================================
       STUDENT BADGE MODE
       Visually distinct from House Badges
       ========================================== */

    #milestoneEditorModal.student-badge-editor-mode {
      background:
        rgba(
          30,
          15,
          60,
          0.88
        ) !important;
    }


    #milestoneEditorModal.student-badge-editor-mode
    .milestone-editor-content {
      background:
        linear-gradient(
          180deg,
          #faf5ff 0%,
          #ffffff 18%
        ) !important;

      border-top:
        7px solid
        #7c3aed !important;
    }


    #milestoneEditorModal.student-badge-editor-mode
    .house-expanded-title {
      color:
        #6d28d9 !important;
    }


    #milestoneEditorModal.student-badge-editor-mode
    .milestone-editor-context {
      background:
        #ede9fe;

      color:
        #6d28d9;
    }


    #milestoneEditorModal.student-badge-editor-mode
    .milestone-editor-context::before {
      content:
        "👤";
    }


    #milestoneEditorModal.student-badge-editor-mode
    .milestone-editor-header {
      border-bottom-color:
        #ddd6fe;
    }


    #milestoneEditorModal.student-badge-editor-mode
    .milestone-row-content {
      background:
        linear-gradient(
          90deg,
          #faf5ff 0%,
          #ffffff 18%
        );

      border-color:
        #ddd6fe;

      border-left:
        5px solid
        #8b5cf6;
    }


    #milestoneEditorModal.student-badge-editor-mode
    .milestone-row-content:hover {
      border-color:
        #c4b5fd;

      box-shadow:
        0 4px 14px
        rgba(
          124,
          58,
          237,
          0.08
        );
    }


    #milestoneEditorModal.student-badge-editor-mode
    .form-control:focus {
      border-color:
        #8b5cf6 !important;

      box-shadow:
        0 0 0 2px
        rgba(
          139,
          92,
          246,
          0.15
        ) !important;
    }


    #milestoneEditorModal.student-badge-editor-mode
    #addMilestoneButton {
      color:
        #6d28d9 !important;

      border-color:
        #8b5cf6 !important;

      background:
        #faf5ff !important;
    }


    #milestoneEditorModal.student-badge-editor-mode
    #saveMilestonesButton {
      background:
        linear-gradient(
          135deg,
          #7c3aed,
          #8b5cf6
        ) !important;

      color:
        #ffffff !important;
    }


    /* ==========================================
       HOUSE BADGE MODE
       Keep existing blue identity
       ========================================== */

    #milestoneEditorModal.house-badge-editor-mode
    .milestone-editor-context::before {
      content:
        "🏠";
    }


    #milestoneEditorModal.house-badge-editor-mode
    .milestone-row-content {
      border-left:
        5px solid
        var(--primary-blue);
    }


    /* Mobile Layout */
    @media (max-width: 1370px) {

      .milestone-row-content {
        grid-template-columns:
          80px
          1fr
          60px !important; 

        grid-template-rows:
          auto
          auto !important;

        grid-template-areas: 
          "points name icon"
          "color desc delete" !important;

        align-items:
          start !important;
      }
      
      .mr-points {
        grid-area: points;
      }

      .mr-name {
        grid-area: name;
      }

      .mr-icon {
        grid-area: icon;
      }

      .mr-color {
        grid-area: color;
      }

      .mr-desc {
        grid-area: desc;
      }

      .mr-delete {
        grid-area: delete;
      }
    
      .mr-color input[type="color"],
      .mr-delete .btn-danger {
        width: 100% !important; 
      }
      
      .milestone-row-content label {
        display: none !important;
      }

    }
    

        /* Ensure proper modal stacking order - Enhanced for Quiz Results */
        .house-expanded {
      transition: z-index 0s;
    }
    
    /* Weekly Quiz modal - Base z-index */
    #weeklyQuizModal.show {
      z-index: 30000 !important;
    }
    
    /* When quiz results is open, ensure it's on top */
    #quizResultsModal.show {
      z-index: 999999 !important;
      background: rgba(0, 0, 0, 0.85) !important;
    }
    
    /* Ensure the overlay background of quiz results covers everything */
    #quizResultsModal.show .house-expanded-content {
      z-index: 999999 !important;
      position: relative;
    }
    
    /* When results modal is open, lower the weekly quiz modal */
    #weeklyQuizModal.results-open {
      z-index: 29999 !important;
    }
    
    /* Ensure results modal appears above all other modals */
    #quizResultsModal.show ~ .house-expanded,
    #quizResultsModal.show ~ .app-module-overlay {
      z-index: 29999 !important;
    }
    
    /* Desktop specific adjustments */
    @media (min-width: 1371px) {
      #quizResultsModal {
        align-items: center !important;
        justify-content: center !important;
      }
      
      #quizResultsModal .house-expanded-content {
        max-width: 500px !important;
        width: 90% !important;
        max-height: 85vh !important;
        border-radius: 24px !important;
        padding: 25px !important;
      }
    }
    
    /* Mobile specific adjustments - keep full screen */
    @media (max-width: 1370px) {
      #quizResultsModal {
        align-items: flex-start !important;
        justify-content: flex-start !important;
      }
      
      #quizResultsModal .house-expanded-content {
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 60px 20px 20px 20px !important;
      }
    }
    
    
    /* Force Bulk Import Modal to Full Screen on Mobile/iPad */
    @media (max-width: 1370px) {
      #importClassesModal {
        align-items: flex-start !important; /* Align to top */
      }
    
      /* FIX: Ensure Quiz Results appear on top of Mobile Config Modals */
      /* Quiz Results Modal - Higher z-index to appear above Weekly Brain-Teaser */
      #quizResultsModal {
      z-index: 999999 !important; /* Significantly higher than Weekly Quiz modal */
    }
    
    /* Ensure Weekly Quiz modal has lower z-index for proper stacking */
    #weeklyQuizModal {
      z-index: 30000 !important; /* Lower than quiz results */
    }
    
    /* Also ensure the modal overlay is properly layered */
    #quizResultsModal.show {
      display: flex !important;
      z-index: 999999 !important;
    }

        /* Ensure proper modal stacking order */
    .house-expanded {
      transition: z-index 0s;
    }
    
    /* When quiz results is open, ensure it's on top */
    #quizResultsModal.show {
      z-index: 999999 !important;
    }
    
    #quizResultsModal.show ~ .house-expanded {
      z-index: 29999 !important;
    }
    
    /* Weekly Quiz modal should be lower than quiz results */
    #weeklyQuizModal.show {
      z-index: 30000 !important;
    }
    
    /* Ensure the overlay background of quiz results covers everything */
    #quizResultsModal.show {
      background: rgba(0, 0, 0, 0.85) !important;
    }
    
    /* When quiz results is open, ensure it's above everything */
    #quizResultsModal .house-expanded-content {
      z-index: 999999 !important;
      position: relative;
    }
    
      #importClassesModal .house-expanded-content {
        width: 100vw !important;
        max-width: none !important;
        height: 100vh !important;       /* Full height */
        max-height: none !important;    /* Remove height limits */
        border-radius: 0 !important;    /* Remove rounded corners */
        margin: 0 !important;
        padding: 20px !important;       /* Ensure comfortable padding */
        box-sizing: border-box !important;
      }
    
      /* --- MODERN MOBILE ACTION GRID --- */
    .mobile-actions-grid {
      display: grid;
      grid-template-columns: 1fr 1fr; /* Two columns */
      gap: 12px;
      padding: 10px 5px;
    }
    
    .action-card {
      position: relative;
      border: none;
      border-radius: 20px; /* Softer rounded corners */
      padding: 16px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      text-align: center;
      cursor: pointer;
      transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
      box-shadow: 0 4px 15px rgba(0,0,0,0.05);
      min-height: 110px; /* Uniform height */
      overflow: hidden;
    }
    
    .action-card:active {
      transform: scale(0.96); /* Satisfying click press */
      box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    /* Internal Icon Wrapper */
    .action-icon-box {
      width: 45px;
      height: 45px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.2);
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 10px;
      font-size: 20px;
      backdrop-filter: blur(4px);
    }
    
    .action-label {
      font-size: 13px;
      font-weight: 700;
      line-height: 1.3;
      color: white;
      z-index: 2;
    }
    
    /* --- THEMES --- */
    
    /* 1. HERO (Award Points) - Full Width */
    /* 1. HERO (Award Points) - Full Width */
    .card-hero {
      grid-column: 1 / -1; /* Spans full width */
      flex-direction: row; /* Horizontal layout */
      justify-content: center; /* <-- CHANGED to center the icon and text group */
      gap: 15px;
      background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
      padding: 20px;
      min-height: auto;
    }
    .card-hero .action-icon-box { margin-bottom: 0; background: rgba(255,255,255,0.25); color: white; }
    .card-hero .action-label { font-size: 16px; text-align: center; /* <-- CHANGED to center the text */ }
    
    /* 2. CONFIG (Houses/Announcements) - Solid Gradients */
    .card-blue { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); color: white; }
    .card-teal { background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%); color: white; }
    .card-purple { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); color: white; }
    
    /* 3. LIGHT (Quiz/Poll) - Clean White with Borders */
    .card-light {
      background: white;
      border: 2px solid transparent;
      box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    }
    .card-light .action-icon-box { background: var(--bg-tint); color: var(--accent-color); }
    .card-light .action-label { color: #334155; }
    
    /* Specific Light Accents */
    .accent-blue { --bg-tint: #eff6ff; --accent-color: #3b82f6; border-color: #dbeafe; }
    .accent-pink { --bg-tint: #fdf2f8; --accent-color: #ec4899; border-color: #fce7f3; }
    } /* This closes the @media (max-width: 1370px) block */
    
     
    /* --- DASHBOARD HOUSE GRID RESPONSIVENESS --- */
    
    /* 1. Mobile Phones (Portrait): 1 Column */
    /* Covers all standard phones (iPhone, Samsung, Pixel) */
    @media (max-width: 780px) {
      .house-grid {
        grid-template-columns: 1fr !important; /* Force 1 column */
        gap: 12px !important;
      } 
    }
    
    /* ------------------------------------------
       HOUSE HIGHLIGHTS WRAPPERS

       Desktop + phone keep the normal layout.
       iPad gets:
       Rank 1 + Rank 2 side-by-side
       Rank 3 onwards in one horizontal scroller.
       ------------------------------------------ */

    /* Compact House Highlights: desktop only. */
    @media (min-width: 1371px) {
      #houseOverview.ted-house-leadership {
        display: grid !important;
        grid-template-columns: none !important;
        grid-auto-flow: column !important;
        grid-auto-columns: minmax(240px, calc((100% - 36px) / 4)) !important;

        align-items: stretch;
        gap: 12px !important;

        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin-top: 10px;
        padding: 2px 2px 10px !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        scroll-snap-type: x proximity;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
      }

      #houseOverview.ted-house-leadership > .ted-hl-card {
        scroll-snap-align: start;
      }

      #houseOverview.ted-house-leadership::-webkit-scrollbar {
        height: 5px;
      }

      #houseOverview.ted-house-leadership::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 10px;
      }

      #houseOverview .ted-hl-card {
        position: relative;
        display: flex;
        flex-direction: column;
        min-width: 0;
        gap: 9px;
        padding: 13px 15px 12px;
        border: 1px solid #e2e8f0;
        border-top: 3px solid var(--ted-hl-colour);
        border-radius: 12px;
        background: #fff;
        color: #0f172a;
        box-shadow: 0 2px 7px rgba(15,23,42,.035);
        cursor: pointer;
        transition: border-color .18s, box-shadow .18s, transform .18s;
      }

      #houseOverview .ted-hl-card:hover {
        border-color: var(--ted-hl-colour);
        box-shadow: 0 6px 16px rgba(15,23,42,.09);
        transform: translateY(-2px);
      }

      #houseOverview .ted-hl-card:focus-visible {
        outline: 3px solid #93c5fd;
        outline-offset: 2px;
      }

      #houseOverview .ted-hl-head {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
      }

      #houseOverview .ted-hl-logo {
        width: 38px;
        height: 38px;
        flex: 0 0 38px;
        border-radius: 50%;
        object-fit: cover;
      }

      #houseOverview .ted-hl-identity {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 1px;
      }

      #houseOverview .ted-hl-name {
        font-size: 15px;
        font-weight: 800;
        line-height: 1.3;
        overflow-wrap: anywhere;
      }

      #houseOverview .ted-hl-members {
        color: #64748b;
        font-size: 11px;
        font-weight: 600;
      }

      #houseOverview .ted-hl-arrow {
        color: #94a3b8;
        font-size: 11px;
        align-self: flex-start;
        margin-top: 4px;
      }

      #houseOverview .ted-hl-label {
        color: #64748b;
        font-size: 10px;
        font-weight: 800;
        letter-spacing: .06em;
        text-transform: uppercase;
      }

      #houseOverview .ted-hl-label i {
        margin-right: 4px;
        color: #ca8a04;
      }

      #houseOverview .ted-hl-captains {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px 12px;
      }

      #houseOverview .ted-hl-captain {
        font-size: 11px;
        font-weight: 700;
        color: #334155;
        line-height: 1.35;
        overflow-wrap: anywhere;
      }

      #houseOverview .ted-hl-empty,
      #houseOverview .ted-hl-more {
        color: #94a3b8;
        font-size: 11px;
      }

      #houseOverview .ted-hl-teacher {
        display: flex;
        align-items: baseline;
        gap: 7px;
        flex-wrap: wrap;
        margin-top: auto;
        padding-top: 8px;
        border-top: 1px solid #f1f5f9;
        font-size: 10px;
      }

      #houseOverview .ted-hl-teacher span {
        color: #64748b;
      }

      #houseOverview .ted-hl-teacher strong {
        color: #334155;
        font-size: 11px;
        overflow-wrap: anywhere;
      }

      /* Premium desktop House Highlights refinement */
      #houseOverview .ted-hl-card {
        gap: 9px;
        padding: 13px 15px;
      }

      #houseOverview .ted-hl-head {
        gap: 11px;
      }

      #houseOverview .ted-hl-logo,
      #houseOverview .ted-hl-initial {
        width: 42px;
        height: 42px;
        flex: 0 0 42px;
        border-radius: 12px;
        border: 1px solid color-mix(
          in srgb,
          var(--ted-hl-colour) 20%,
          white
        );
      }

      #houseOverview .ted-hl-logo {
        object-fit: contain;
        padding: 3px;
        background: #f8fafc;
      }

      #houseOverview .ted-hl-initial {
        display: flex;
        align-items: center;
        justify-content: center;
        background: color-mix(
          in srgb,
          var(--ted-hl-colour) 12%,
          white
        );
        color: var(--ted-hl-colour);
        font-size: 21px;
        font-weight: 900;
        line-height: 1;
      }

      #houseOverview .ted-hl-identity {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 5px 8px;
      }

      #houseOverview .ted-hl-name {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 16px;
        line-height: 1.25;
      }

      #houseOverview .ted-hl-members {
        flex: 0 0 auto;
        margin-left: auto;
        padding: 5px 9px;
        border: 1px solid #e2e8f0;
        border-radius: 999px;
        background: #f8fafc;
        color: #475569;
        font-size: 10px;
        font-weight: 750;
        line-height: 1;
        white-space: nowrap;
      }

      #houseOverview .ted-hl-arrow {
        align-self: center;
        margin-top: 0;
        font-size: 11px;
        color: #94a3b8;
      }

      #houseOverview .ted-hl-label {
        font-size: 10px;
        margin-top: 2px;
      }

      #houseOverview .ted-hl-captains {
        gap: 7px 14px;
      }

      #houseOverview .ted-hl-captain {
        font-size: 12.5px;
        font-weight: 750;
        line-height: 1.4;
        letter-spacing: -0.01em;
      }

      #houseOverview .ted-hl-empty {
        font-size: 12px;
        font-style: normal;
        line-height: 1.4;
      }

      #houseOverview .ted-hl-teacher {
        gap: 5px 8px;
        padding-top: 7px;
      }

      /* Dark-mode refinements */
      body.house-display-dark #houseOverview .ted-hl-initial {
        background: color-mix(
          in srgb,
          var(--ted-hl-colour) 20%,
          #1e293b
        );
      }

      body.house-display-dark #houseOverview .ted-hl-logo {
        background: #273449;
      }

      body.house-display-dark #houseOverview .ted-hl-members {
        background: #273449;
        border-color: #475569;
        color: #e2e8f0;
      }

      #dashboard-section .ted-hl-touch-hint {
        display: none !important;
      }

      #dashboard-section .ted-hl-desktop-hint {
        display: inline !important;
      }

      /* Dark mode */
      body.house-display-dark #houseOverview .ted-hl-card {
        background: #1e293b;
        color: #f8fafc;
        border-color: #334155;
        border-top-color: var(--ted-hl-colour);
      }

      body.house-display-dark #houseOverview .ted-hl-card:hover {
        border-color: var(--ted-hl-colour);
      }

      body.house-display-dark #houseOverview .ted-hl-name,
      body.house-display-dark #houseOverview .ted-hl-captain,
      body.house-display-dark #houseOverview .ted-hl-teacher strong {
        color: #f8fafc;
      }

      body.house-display-dark #houseOverview .ted-hl-members,
      body.house-display-dark #houseOverview .ted-hl-label,
      body.house-display-dark #houseOverview .ted-hl-teacher span {
        color: #cbd5e1;
      }

      body.house-display-dark #houseOverview .ted-hl-teacher {
        border-top-color: #334155;
      }
    }

    .house-highlight-top,
    .house-highlight-rest {
      display: contents;
    }


    @media (min-width: 780px) and (max-width: 1370px) {

      #houseOverview.house-grid,
      body.mobile #houseOverview.house-grid {
        display: flex !important;

        flex-direction: column !important;

        gap: 16px !important;

        width: 100% !important;
        max-width: 100% !important;

        overflow: visible !important;
      }


      /* Rank 1 + Rank 2 */
      #houseOverview
      .house-highlight-top {
        display: grid !important;

        grid-template-columns:
          repeat(
            2,
            minmax(0, 1fr)
          ) !important;

        gap: 16px !important;

        width: 100% !important;

        min-width: 0 !important;
      }


      #houseOverview
      .house-highlight-top
      > .house-card {
        width: 100% !important;

        min-width: 0 !important;

        height: 100% !important;

        grid-column: auto !important;
        grid-row: auto !important;
      }


      /* First place should feel special */
      #houseOverview
      .house-highlight-top
      > .house-card:first-child {
        border:
          2px solid
          rgba(245,158,11,.55) !important;

        box-shadow:
          0 10px 24px
          rgba(245,158,11,.13) !important;

        background:
          linear-gradient(
            145deg,
            #fffdf5 0%,
            #ffffff 55%,
            #fffbeb 100%
          ) !important;
      }


      #houseOverview
      .house-highlight-top
      > .house-card:first-child::after {
        content:
          "★ LEADER";

        position:
          absolute;

        top:
          13px;

        right:
          13px;

        z-index:
          5;

        padding:
          4px
          8px;

        border-radius:
          999px;

        background:
          #fef3c7;

        border:
          1px solid
          #fcd34d;

        color:
          #92400e;

        font-size:
          8px;

        font-weight:
          900;

        letter-spacing:
          .06em;

        line-height:
          1;

        pointer-events:
          none;
      }


      /* Rank 3 onwards */
      #houseOverview
      .house-highlight-rest {
        position:
          relative !important;

        display:
          flex !important;

        flex-direction:
          row !important;

        align-items:
          stretch !important;

        gap:
          16px !important;

        width:
          100% !important;

        max-width:
          100% !important;

        min-width:
          0 !important;

        overflow-x:
          auto !important;

        overflow-y:
          hidden !important;

        padding:
          28px
          24px
          10px
          0 !important;

        scroll-snap-type:
          x mandatory;

        scroll-behavior:
          smooth;

        overscroll-behavior-x:
          contain;

        -webkit-overflow-scrolling:
          touch;

        scrollbar-width:
          thin;
      }


      #houseOverview
      .house-highlight-rest::before {
        content:
          "Swipe to see more  →";

        position:
          absolute;

        top:
          3px;

        right:
          6px;

        color:
          #64748b;

        font-size:
          9px;

        font-weight:
          800;

        letter-spacing:
          .02em;

        pointer-events:
          none;
      }


      #houseOverview
      .house-highlight-rest
      > .house-card {
        flex:
          0 0
          44% !important;

        width:
          44% !important;

        min-width:
          44% !important;

        height:
          auto !important;

        grid-column:
          auto !important;

        grid-row:
          auto !important;

        scroll-snap-align:
          start;
      }

    }
    
    /* MOBILE: FIRST HOUSE ON TOP, OTHERS SCROLL */

    @media (max-width: 600px) {

      #houseOverview.house-grid,
      body.mobile #houseOverview.house-grid {
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;

        gap: 12px !important;
        width: 100% !important;
        max-width: 100% !important;

        overflow: hidden !important;
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
      }

      /* First-place House */
      #houseOverview .house-highlight-top {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
      }

      #houseOverview .house-highlight-top > .house-card {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        margin: 0 !important;
      }

      /* Remaining Houses: one horizontal row */
      #houseOverview .house-highlight-rest {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;

        gap: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        margin: 0 !important;
        padding: 2px 2px 6px !important;

        scroll-snap-type: x proximity;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
      }

      #houseOverview .house-highlight-rest::-webkit-scrollbar {
        display: none;
      }

      #houseOverview .house-highlight-rest > .house-card {
        flex: 0 0 86% !important;

        width: 86% !important;
        min-width: 86% !important;
        max-width: 86% !important;

        height: auto !important;
        margin: 0 !important;

        grid-column: auto !important;
        grid-row: auto !important;

        scroll-snap-align: start;
      }

      /* Remove the old scrolling label inside the cards */
      #houseOverview .house-highlight-rest::before {
        content: none !important;
      }

      /* Show swipe instruction in the heading */
      #dashboard-section .ted-hl-touch-hint {
        display: inline !important;
        font-size: 0 !important;
      }

      #dashboard-section .ted-hl-touch-hint::after {
        content: "Swipe to see more →";
        font-size: 10px;
        color: #64748b;
        font-weight: 600;
      }

    }

    /* MOBILE: COMPACT HOUSE HIGHLIGHTS */

    @media (max-width: 600px) {

      /* Reduce space inside every House card */
      #houseOverview .house-card > div:nth-child(2) {
        padding: 12px !important;
      }

      /* House name and mascot */
      #houseOverview .house-card > div:nth-child(2) > div:first-child {
        margin-bottom: 8px !important;
      }

      /* Points and members */
      #houseOverview .house-overview-stats-row {
        padding: 8px 10px !important;
        margin-bottom: 8px !important;
      }

      /* Progress bar section */
      #houseOverview .house-card > div:nth-child(2) > div:nth-child(3) {
        margin-bottom: 8px !important;
      }

      /* Captains section */
      #houseOverview .house-card > div:nth-child(2) > div:nth-child(4) {
        padding-top: 8px !important;
      }

      #houseOverview .house-card-captains,
      #houseOverview .house-card-no-captains {
        margin-top: 5px !important;
      }

      /* Small LEADER badge for first place */
      #houseOverview .house-highlight-top > .house-card:first-child::after {
        content: "★ LEADER";
        position: absolute;
        top: 13px;
        right: 12px;
        z-index: 5;

        padding: 4px 7px;
        border-radius: 999px;

        background: #fef3c7;
        border: 1px solid #fcd34d;
        color: #92400e;

        font-size: 9px;
        font-weight: 800;
        letter-spacing: 0.03em;
        pointer-events: none;
      }

      /* Move swipe instruction below the leading House */
      #houseOverview .house-highlight-top::after {
        content: "Swipe to see more →";
        display: block;
        margin: 8px 2px 0;
        text-align: right;
        color: #64748b;
        font-size: 10px;
        font-weight: 650;
      }

      /* Remove duplicate instruction beside heading */
      #dashboard-section .ted-hl-touch-hint {
        display: none !important;
      }

      /* Tighten spacing between rows */
      #houseOverview.house-grid,
      body.mobile #houseOverview.house-grid {
        gap: 6px !important;
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
      }

      /* Remove extra bottom space from scrolling row */
      #houseOverview .house-highlight-rest {
        margin-bottom: 0 !important;
        padding-bottom: 4px !important;
      }

    }

    /* IPAD: HOUSE HIGHLIGHTS IN ONE SCROLLING ROW */

    @media (min-width: 780px) and (max-width: 1370px) {

      #houseOverview.house-grid,
      body.mobile #houseOverview.house-grid {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;

        gap: 16px !important;
        width: 100% !important;
        max-width: 100% !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        padding: 8px 2px 14px !important;

        scroll-snap-type: x proximity;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
      }

      /* Keep all Houses in the same row */
      #houseOverview .house-highlight-top,
      #houseOverview .house-highlight-rest {
        display: contents !important;
      }

      /* Two full cards and a small preview of the next */
      #houseOverview .house-card {
        flex: 0 0 44% !important;
        width: 44% !important;
        min-width: 44% !important;
        max-width: 44% !important;

        height: auto !important;
        grid-column: auto !important;
        grid-row: auto !important;

        scroll-snap-align: start;
      }

      /* Remove old second-row swipe label */
      #houseOverview .house-highlight-rest::before {
        content: none !important;
      }

      /* Update the heading instruction on iPad */
      #dashboard-section .ted-hl-touch-hint {
        display: inline !important;
        font-size: 0 !important;
      }

      #dashboard-section .ted-hl-touch-hint::after {
        content: "Swipe to see more →";
        font-size: 10px;
        color: #64748b;
        font-weight: 600;
      }

      #dashboard-section .ted-hl-desktop-hint {
        display: none !important;
      }

      #houseOverview::-webkit-scrollbar {
        height: 5px;
      }

      #houseOverview::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 10px;
      }

    }

    /* --- APP MODULE OVERLAY SYSTEM --- */
    /* --- APP MODULE OVERLAY SYSTEM --- */
    .app-module-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: var(--bg);
      z-index: 15000 !important; /* Force to sit ABOVE the Teacher Toolkit */
      overflow-y: auto; 
      transform: translateX(100%); 
      transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
      display: flex;
      flex-direction: column;
    }
    
    /* Active State: Visible */
    .app-module-overlay.active {
      transform: translateX(0);
    }
    
    /* Back Button for the Overlay */
    .close-module-btn {
      background: transparent;
      border: none;
      font-size: 1rem;
      font-weight: 700;
      color: var(--primary);
      cursor: pointer;
      display: flex; align-items: center; gap: 8px;
    }
    
    
    
    
    
    /* --- EVENT BUILDER MODULE SPECIFIC STYLES --- */
    #eventBuilderModule .eb-layout {
      display: grid;
      grid-template-columns: 350px 1fr;
      gap: 20px;
      padding: 20px;
      height: calc(100% - 60px);
      overflow-y: auto;
      box-sizing: border-box;
    }
    
    /* Mode Cards */
    .eb-mode-card {
      border: 2px solid var(--gray-light);
      padding: 15px;
      border-radius: 10px;
      margin-bottom: 10px;
      cursor: pointer;
      background: white;
      transition: all 0.2s;
    }
    .eb-mode-card:hover { border-color: var(--gray); }
    .eb-mode-card.selected { 
      border-color: var(--primary-blue); 
      background: #eff6ff; 
      box-shadow: 0 2px 4px rgba(30, 64, 175, 0.1);
    }
    .eb-mode-title { font-weight: 700; display: block; margin-bottom: 4px; color: var(--dark-text); }
    .eb-mode-desc { font-size: 12px; color: var(--gray); }
    
    /* Result Cards (Collapsible) */
    .eb-group-card {
      background: white;
      border: 1px solid var(--gray-light);
      border-radius: 12px;
      margin-bottom: 15px;
      overflow: hidden;
      box-shadow: var(--shadow-sm);
      transition: box-shadow 0.2s;
    }
    .eb-group-header {
      padding: 12px 16px;
      color: white;
      font-weight: 700;
      display: flex;
      justify-content: space-between;
      align-items: center;
      cursor: pointer;
      user-select: none;
    }
    .eb-group-header:hover { opacity: 0.95; }
    .eb-toggle-icon { transition: transform 0.3s ease; font-size: 14px; }
    
    /* Collapsed State Logic */
    .eb-group-card.collapsed { border-bottom: 1px solid var(--gray-light); }
    .eb-group-card.collapsed .eb-student-list { display: none; }
    .eb-group-card.collapsed .eb-toggle-icon { transform: rotate(-90deg); }
    
    .eb-student-list { list-style: none; margin: 0; padding: 0; }
    .eb-student-row {
      padding: 10px 16px;
      border-bottom: 1px solid var(--bg-light);
      display: flex;
      justify-content: space-between;
      font-size: 14px;
    }
    .eb-student-row:last-child { border-bottom: none; }
    
    /* Loading Spinner */
    #eb_loadingOverlay {
      position: absolute; inset: 0; 
      background: rgba(255,255,255,0.95); 
      z-index: 50; 
      display: none; 
      justify-content: center; align-items: center;
      flex-direction: column;
      border-radius: 12px;
    }
    
    /* Mobile Close Button (Hidden on Desktop) */
    .eb-mobile-close-btn { display: none; }
    
    /* --- MOBILE / TABLET OPTIMIZATIONS --- */
    @media (max-width: 1370px) {
      
      #eventBuilderModule .eb-layout {
        display: flex; 
        flex-direction: column;
        padding: 15px;
        height: auto;
        overflow-y: auto;
        padding-bottom: 50px; 
      }
    
      /* PREVIEW CARD: Default State = Hidden (Off-screen) */
      #eb_previewCard {
        position: fixed !important;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100vw;
        height: 100%; 
        z-index: 6000;
        
        background: white;
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        
        /* Animation: Slide up from bottom */
        transform: translateY(120%); 
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        
        display: flex; 
        flex-direction: column;
      }
      
      /* PREVIEW CARD: Active State = Visible */
      #eb_previewCard.active {
        transform: translateY(0); 
      }
    
      /* --- FIX: CLOSE BUTTON STYLING --- */
      /* We use !important on display to override the inline style="display:none" */
      .eb-mobile-close-btn {
        display: flex !important; 
        align-items: center; 
        justify-content: center;
        
        width: 36px; height: 36px;
        background: #fee2e2 !important; /* Light Red background */
        color: #ef4444 !important;      /* Red Icon */
        border-radius: 50%;
        border: none;
        margin-right: 12px;
        cursor: pointer;
      }
      
      /* Ensure internal scrolling works */
      #eb_previewArea {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 20px;
        padding-bottom: 100px;
      }
    }
    
    
    /* --- CLEAN 2-ROW DESKTOP LAYOUT --- */
    @media (min-width: 1370px) {
      #houseSettingsList .house-config-item {
        display: grid !important;
        /* Columns: Emoji | Col 1 (Name/System) | Col 2 (Motto/Pass) | Col 3 (Msg/Email) | Delete */
        grid-template-columns: 70px 180px 1.2fr 1.5fr 60px;
        grid-template-rows: auto auto; /* Two Rows */
        gap: 10px 16px; /* Row Gap: 10px, Col Gap: 16px */
        align-items: center;
        padding: 16px 20px !important;
        margin-bottom: 12px;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        transition: all 0.2s ease;
      }
    
      #houseSettingsList .house-config-item:hover {
        border-color: var(--primary-blue);
        box-shadow: 0 4px 12px rgba(30, 64, 175, 0.1);
        transform: translateY(-1px);
      }
    
      /* --- LEFT: EMOJI (Spans 2 Rows) --- */
      .house-emoji-btn {
        grid-column: 1; grid-row: 1 / span 2;
        width: 60px !important; height: 60px !important;
        font-size: 32px !important;
        border-radius: 12px !important;
        border: 2px solid #f1f5f9 !important;
        display: flex; align-items: center; justify-content: center;
      }
    
      /* --- RIGHT: DELETE (Spans 2 Rows) --- */
      .house-delete-btn {
        grid-column: 5; grid-row: 1 / span 2;
        height: 40px; width: 40px;
        border-radius: 8px;
        display: flex; align-items: center; justify-content: center;
        opacity: 0.6;
        transition: opacity 0.2s;
      }
      .house-delete-btn:hover { opacity: 1; }
    
      /* --- COLUMN 1: NAME & SYSTEM --- */
      .house-name-input {
        grid-column: 2; grid-row: 1;
        font-weight: 800 !important;
        font-size: 15px !important;
        border: 1px solid #cbd5e1 !important;
      }
    
      .house-system-tools {
        grid-column: 2; grid-row: 2;
        display: flex; align-items: center; gap: 8px;
        background: #f8fafc;
        padding: 4px 8px;
        border-radius: 6px;
        border: 1px solid #e2e8f0;
      }
    
      /* --- COLUMN 2: MOTTO & PASSWORD --- */
      .house-motto-input {
        grid-column: 3; grid-row: 1;
      }
      
      .house-pass-input {
        grid-column: 3; grid-row: 2;
        font-size: 12px !important;
        border-style: dashed !important;
        opacity: 0.8;
      }
    
      /* --- COLUMN 3: MESSAGE & EMAIL --- */
      .house-msg-input {
        grid-column: 4; grid-row: 1;
      }
    
      .house-email-input {
        grid-column: 4; grid-row: 2;
        font-size: 12px !important;
        opacity: 0.8;
      }
    }
    
    /* --- RANDOM PICKER MODULE STYLES --- */
    #randomPickerModule {
      background: linear-gradient(135deg, #1e293b, #0f172a); /* Dark "Game Show" Stage */
      color: white;
    }
    
    #randomPickerModule .brand-header {
      background: transparent !important;
      border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    }
    #randomPickerModule .brand-header div { color: white !important; }
    #randomPickerModule .close-module-btn { color: white !important; }
    
    .rp-stage {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 20px;
      text-align: center;
    }
    
    /* The Big Name Box */
    .rp-display-box {
      font-family: 'Fredoka One', cursive, sans-serif; /* Uses your existing font */
      font-size: 4rem;
      font-weight: 700;
      color: #fbbf24; /* Gold */
      min-height: 120px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 30px 0;
      text-shadow: 0 4px 0px rgba(0,0,0,0.3);
      transition: transform 0.1s;
    }
    
    /* Animation State */
    .rp-display-box.spinning {
      color: rgba(255,255,255,0.5);
      transform: scale(0.95);
    }
    
    .rp-display-box.winner {
      color: #4ade80; /* Green */
      transform: scale(1.2);
      text-shadow: 0 0 30px rgba(74, 222, 128, 0.6);
      animation: winnerPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    @keyframes winnerPop {
      0% { transform: scale(0.5); opacity: 0; }
      60% { transform: scale(1.3); opacity: 1; }
      100% { transform: scale(1.2); }
    }
    
    .rp-controls {
      width: 100%;
      max-width: 400px;
      background: rgba(255,255,255,0.1);
      padding: 20px;
      border-radius: 20px;
      backdrop-filter: blur(10px);
      border: 1px solid rgba(255,255,255,0.1);
    }
    
    .rp-btn-main {
      background: linear-gradient(135deg, #fbbf24, #d97706);
      color: #1e293b;
      font-size: 20px;
      font-weight: 800;
      padding: 16px;
      width: 100%;
      border: none;
      border-radius: 12px;
      box-shadow: 0 6px 0 #b45309;
      transition: all 0.1s;
      cursor: pointer;
      text-transform: uppercase;
      letter-spacing: 1px;
    }
    
    .rp-btn-main:active {
      transform: translateY(6px);
      box-shadow: 0 0 0 #b45309;
    }
    .rp-btn-main:disabled {
      background: #475569;
      color: #94a3b8;
      box-shadow: none;
      transform: translateY(6px);
      cursor: not-allowed;
    }
    
    .rp-avatar-circle {
      width: 80px; height: 80px;
      border-radius: 50%;
      background: rgba(255,255,255,0.1);
      display: flex; align-items: center; justify-content: center;
      font-size: 30px; font-weight: 700;
      margin-bottom: 10px;
      border: 4px solid rgba(255,255,255,0.2);
    }
    
    
    
    
    
    
    /* =========================================================
       🗑️ UNIVERSAL MOBILE/IPAD DELETE BUTTON CENTERING FIX
       ========================================================= */
    @media (max-width: 1370px) {
      /* Targets ALL red/danger buttons (houses, announcements, students, modals) */
      .btn-danger,
      .house-delete-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        gap: 8px !important; /* Modern spacing between icon and text */
      }
      
      /* Strip away any rogue margins pushing the trash icons off-center */
      .btn-danger i,
      .house-delete-btn i {
        margin: 0 !important;
        display: inline-block !important;
        flex-shrink: 0 !important; /* Prevents the icon from getting squished */
      }
    }
    
    @media(max-width: 768px) {
      .rp-display-box { font-size: 2.5rem; }
    }
    
    
    
    /* --- TOOLKIT FAB (Mobile Left) --- */
    .toolkit-fab {
      position: fixed;
      /* Matches the height of the Save button (90px bottom) */
      bottom: calc(90px + env(safe-area-inset-bottom, 0px)); 
      left: 20px; /* Left side */
      width: 54px; 
      height: 54px;
      border-radius: 50%;
      border: none;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 4px 15px rgba(147, 51, 234, 0.4); 
      z-index: 1100;
      background: linear-gradient(135deg, #9333ea, #7e22ce); /* Purple Gradient */
      color: white;
      font-size: 22px;
      cursor: pointer;
      transition: transform 0.2s ease;
    }
    
    .toolkit-fab:active {
      transform: scale(0.95);
    }
    
    /* --- TOOLKIT MODAL GRID --- */
    .toolkit-card {
      background:
        var(--school-surface);

      border:
        1px solid
        var(--school-border);

      border-radius:
        12px;

      padding:
        20px;

      display:
        flex;

      flex-direction:
        column;

      align-items:
        center;

      text-align:
        center;

      cursor:
        pointer;

      transition:
        all 0.2s ease;

      box-shadow:
        0 2px 4px
        rgba(0,0,0,0.05);
    }
    
    .toolkit-card:not(.disabled):hover {
      transform:
        translateY(-4px);

      box-shadow:
        0 8px 16px
        color-mix(
          in srgb,
          var(--school-primary) 16%,
          transparent
        );

      border-color:
        var(--school-border-strong);
    }
    
    .toolkit-icon {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 24px;
      margin-bottom: 12px;
    }
    
    .toolkit-name {
      font-weight: 700;
      color: var(--dark-text);
      margin-bottom: 4px;
    }
    
    .toolkit-desc {
      font-size: 11px;
      color: var(--gray);
    }
    
    /* --- RESPONSIVE VISIBILITY --- */
    /* Keep standard desktop-only buttons hidden on iPads */
    @media (max-width: 1370px) {
      .btn.desktop-only { display: none !important; }
    }
    
    /* 1. Global: Hide FAB on Desktops */
    @media (min-width: 1371px) {
      .toolkit-fab.mobile-only { display: none !important; }
    }
    
    /* 2. Global: Hide ALL desktop buttons on iPad & Mobile */
    @media (max-width: 1370px) {
      .btn.desktop-only { display: none !important; }
    }
    
    /* 3. iPad Override (781px - 1370px): Bring back ONLY the Toolkit inline button, hide FAB */
    @media (min-width: 781px) and (max-width: 1370px) {
      #students-section .students-header-actions .btn.desktop-only {
        display: inline-flex !important; 
      }
      .toolkit-fab.mobile-only { 
        display: none !important; 
      }
    }
    
    /* 4. Mobile Override (780px and below): Hide inline Toolkit, show FAB */
    @media (max-width: 780px) {
      #students-section .students-header-actions .btn.desktop-only {
        display: none !important;
      }
      .toolkit-fab.mobile-only { 
        display: flex !important; 
      }
    }
    
    
    /* --- FIX: FULL SCREEN TOOLKIT (MOBILE/TABLET) --- */
    @media (max-width: 1370px) {
      
      #teacherToolkitModal {
        /* Ensure the wrapper covers the whole screen */
        z-index: 12000 !important; /* Higher than everything (Header is usually 1000) */
        align-items: flex-start !important; /* Start from top, not center */
      }
    
      #teacherToolkitModal .house-expanded-content {
        width: 100vw !important;
        height: 100vh !important;

        max-width: none !important;
        max-height: none !important;

        border-radius: 0 !important;

        margin: 0 !important;
        
        /* REDUCED PADDING: Pulls the branding bar closer to the notch */
        padding:
          60px 20px 24px 20px !important; 
        
        background:
          linear-gradient(
            135deg,
            var(--school-canvas) 0%,
            var(--school-surface-soft) 100%
          ) !important;

        display: flex;
        flex-direction: column;
        justify-content: flex-start;
      }
    
      /* Fix the Title Color/Size for Mobile */
      #teacherToolkitModal .house-expanded-title {
        font-size: 24px !important;
        margin-bottom: 8px !important;
        display: block !important;
      }
    
      
    }
    
    
    
    /* ==========================================
       🎨 MAGIC HAT & CORE STYLES
       ========================================== */
    
    /* The Action Bar (Hidden while spinning, visible on win) */
    .rp-action-bar {
      display: flex;
      gap: 12px;
      margin-top: 20px;
      opacity: 0;
      transform: translateY(10px);
      transition: all 0.3s ease;
    }
    
    .rp-action-bar.show {
      opacity: 1;
      transform: translateY(0);
    }
    
    /* Winner Mode: Tint the whole stage based on House Color */
    #randomPickerModule.house-win-mode .rp-stage {
      background: radial-gradient(circle at center, var(--winner-color-transparent, rgba(255,255,255,0.1)), transparent 70%);
    }
    
    #randomPickerModule.house-win-mode .rp-display-box {
      color: var(--winner-color, #fbbf24);
      text-shadow: 0 0 30px var(--winner-color-glow, rgba(251, 191, 36, 0.4));
    }
    
    #randomPickerModule.house-win-mode .rp-avatar-circle {
      border-color: var(--winner-color, #fbbf24);
      box-shadow: 0 0 20px var(--winner-color, #fbbf24);
    }
    
    /* Action Buttons */
    .rp-btn-action {
      flex: 1;
      padding: 14px;
      border-radius: 12px;
      border: none;
      font-weight: 700;
      font-size: 16px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      transition: transform 0.1s;
    }
    
    .rp-btn-action:active { transform: scale(0.96); }
    
    .rp-btn-reward {
      background: #047857;
      color: #ffffff;
      box-shadow: 0 4px 0 #065f46;
      border: 1px solid #059669;
    }

    .rp-btn-reward i {
      color: #ffffff;
    }
    
    .rp-btn-skip {
      background: #ffffff;
      color: #0f172a;
      box-shadow: 0 4px 0 #94a3b8;
      border: 2px solid #cbd5e1;
      font-weight: 800;
    }

    .rp-btn-skip:hover {
      background: #f8fafc;
      border-color: #94a3b8;
    }
    
    /* Hide the main Spin button when winner is shown */
    .rp-controls.winner-state #rp_spinBtn {
      display: none;
    }
    
    /* --- FIX: Random Picker Loading Spinner --- */
    .rp-btn-action.loading {
      opacity: 0.8;
      pointer-events: none; /* Prevent double clicks */
      cursor: wait;
    }
    
    .rp-btn-action.loading::after {
      content: '';
      display: inline-block;
      width: 18px; 
      height: 18px;
      margin-left: 10px;
      border: 3px solid rgba(255,255,255,0.3); /* Light track */
      border-top-color: #ffffff; /* White moving part */
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
      flex-shrink: 0;
    }
    
    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
    
    /* Ensure floating animation works */
.floating-plus-one {
  position: fixed !important;
  color: #ffd700 !important;
  font-family: 'Lexend', sans-serif !important;
  font-size: 3rem !important;
  font-weight: 900 !important;
  z-index: 99999 !important;
  pointer-events: none !important;
  text-shadow: 0 0 20px rgba(255,215,0,0.8), 2px 2px 0px rgba(0,0,0,0.3) !important;
  white-space: nowrap !important;
}

@keyframes floatUpAndFade {
  0% { 
    transform: translate(-50%, -50%) scale(0.3) rotate(-10deg); 
    opacity: 0; 
  }
  20% { 
    transform: translate(-50%, -60px) scale(1.3) rotate(0deg); 
    opacity: 1; 
  }
  100% { 
    transform: translate(-50%, -180px) scale(1) rotate(5deg); 
    opacity: 0; 
  }
}
    .rp-btn-action.success-pop {
      background: #059669 !important;
      transform: scale(1.1) !important;
      box-shadow: 0 0 20px #10b981 !important;
    }
    
    /* --- RANDOM PICKER INFO OVERLAY --- */
    .rp-info-btn {
      background: rgba(255,255,255,0.1);
      border: 1px solid rgba(255,255,255,0.2);
      color: white;
      width: 36px; height: 36px;
      border-radius: 50%;
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      font-size: 16px;
      transition: all 0.2s ease;
    }
    .rp-info-btn:hover { background: rgba(255,255,255,0.25); transform: scale(1.1); }
    
    .rp-info-overlay {
      position: absolute;
      inset: 0;
      background: rgba(15, 23, 42, 0.95);
      backdrop-filter: blur(10px);
      z-index: 40;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      opacity: 0;
      pointer-events: none;
      transform: scale(0.95);
      transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    .rp-info-overlay.show {
      opacity: 1;
      pointer-events: all;
      transform: scale(1);
    }
    
    /* --- PREMIUM SCALING FOR IPAD & DESKTOP INFO MODALS --- */
    .rp-info-content {
      width: 100%;
      max-width: 750px; /* Widened for tablet/desktop */
      text-align: center;
    }
    
    .rp-info-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 20px; /* Increased gap */
    }
    
    .rp-info-card {
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.1);
      padding: 24px; /* More breathing room */
      border-radius: 16px;
      text-align: left;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    
    .rp-info-card .icon { font-size: 36px; } /* Bigger Emoji */
    .rp-info-card strong { color: #fbbf24; display: block; font-size: 18px; margin-bottom: 4px; } /* Bigger Title */
    .rp-info-card p { color: #cbd5e1; font-size: 15px; line-height: 1.5; margin: 0; } /* Readable Body Text */
    
    /* --- FIX: PREVENT INFO MODALS FROM GETTING PUSHED UP OFF-SCREEN (780px) --- */
    /* --- MOBILE INFO MODALS (780px & Below) --- */
    @media (max-width: 780px) {
      /* Stack the grids */
      .rp-info-grid,
      .sb-info-grid { 
        grid-template-columns: 1fr !important; 
        gap: 10px !important;
      }
      
      /* Change centering logic to prevent top cutoff */
      /* Change centering logic to prevent top cutoff */
      .rp-info-overlay, 
      #sb_info_modal {
        flex-direction: column !important;
        justify-content: flex-start !important; /* Start from top */
        align-items: center !important;
        overflow-y: auto !important; /* Enable scrolling */
        
        /* THE FIX: 90px top padding forces content safely below the persistent header */
        padding: 90px 20px 30px 20px !important; 
        -webkit-overflow-scrolling: touch;
      }
    
      /* Auto margin centers it if there's space, but pushes to top if content is tall */
      .rp-info-content, 
      .sb-info-content {
        /* Changed from auto 0 to 0 auto so it respects the top padding strictly */
        margin: 0 auto !important; 
        width: 100% !important;
        padding-bottom: 20px !important;
      }
      
      /* Shrink text and spacing back down for mobile phones */
      .rp-info-content h3, .sb-info-title { font-size: 22px !important; margin-bottom: 15px !important; }
      .rp-info-card, .sb-info-card { padding: 16px !important; gap: 6px !important; }
      .rp-info-card .icon, .sb-info-card i { font-size: 24px !important; margin-bottom: 4px !important; }
      .rp-info-card strong, .sb-info-card h4 { font-size: 14px !important; }
      .rp-info-card p, .sb-info-card p { font-size: 12px !important; line-height: 1.4 !important; }
    }
    
    /* --- THEMES --- */
    #randomPickerModule {
      background: linear-gradient(135deg, #2e1065, #0f172a);
      color: white;
    }
    #randomPickerModule .rp-btn-main {
      background: linear-gradient(135deg, #fbbf24, #d97706);
      box-shadow: 0 6px 0 #b45309;
    }
    
    #housePickerModule {
      background: linear-gradient(135deg, #064e3b, #020617);
      color: white;
    }
    #housePickerModule .rp-stage {
      background: radial-gradient(circle at center, rgba(16, 185, 129, 0.1) 0%, transparent 80%);
    }
    #housePickerModule .rp-btn-main {
      background: linear-gradient(135deg, #10b981, #047857);
      box-shadow: 0 6px 0 #064e3b;
      border-radius: 50px;
    }
    #housePickerModule .rp-btn-reward {
      background: #ffffff;
      color: #064e3b;
      box-shadow: 0 4px 0 #cbd5e1;
      border-radius: 16px;
    }
    #housePickerModule .rp-btn-reward:hover { background: #ecfdf5; }
    #housePickerModule .rp-btn-skip {
      background: rgba(255,255,255,0.05);
      border: 1px dashed rgba(255,255,255,0.3);
      color: #a7f3d0;
      box-shadow: none;
    }
    #housePickerModule .rp-display-box {
      letter-spacing: -1px;
      text-transform: uppercase;
      font-family: 'Inter', sans-serif;
      font-weight: 900;
    }
    
    /* --- SHARED STRUCTURE --- */
    #randomPickerModule .brand-header,
    #housePickerModule .brand-header {
      background: transparent !important;
      border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    }
    #randomPickerModule .brand-header div,
    #housePickerModule .brand-header div { color: white !important; }
    #randomPickerModule .close-module-btn,
    #housePickerModule .close-module-btn { color: white !important; }
    
    .rp-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; text-align: center; }
    
    .rp-display-box {
      font-size: 4rem; min-height: 100px; display: flex; align-items: center; justify-content: center;
      margin: 20px 0 30px 0; text-shadow: 0 4px 0px rgba(0,0,0,0.3); transition: transform 0.1s; line-height: 1.1;
    }
    
    .rp-avatar-circle {
      width: 110px; height: 110px; border-radius: 50%; background: rgba(255,255,255,0.1);
      display: flex; align-items: center; justify-content: center; font-size: 48px;
      margin-bottom: 10px; border: 4px solid rgba(255,255,255,0.2); transition: all 0.3s ease;
    }
    
    .rp-controls {
      width: 100%; max-width: 400px; background: rgba(255,255,255,0.05);
      padding: 24px; border-radius: 24px; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1);
    }
    
    .rp-btn-main {
      font-size: 20px; font-weight: 800; padding: 16px; width: 100%; border: none;
      transition: all 0.1s; cursor: pointer; text-transform: uppercase; letter-spacing: 1px;
    }
    .rp-btn-main:active { transform: translateY(6px); box-shadow: none !important; }
    .rp-btn-main:disabled { background: #475569 !important; color: #94a3b8; box-shadow: none !important; transform: translateY(6px); cursor: not-allowed; }
    
    .rp-action-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 20px; opacity: 0; transform: translateY(10px); transition: all 0.3s ease; }
    .rp-action-grid.show { opacity: 1; transform: translateY(0); }
    .rp-btn-action { flex: 1; padding: 14px; border-radius: 12px; border: none; font-weight: 700; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
    
    .rp-controls.winner-state .rp-btn-main { display: none; }
    
    #housePickerModule.house-win-mode .rp-stage,
    #randomPickerModule.house-win-mode .rp-stage {
      background: radial-gradient(circle at center, var(--winner-color-transparent, rgba(255,255,255,0.1)), transparent 70%);
    }
    #housePickerModule.house-win-mode .rp-display-box {
      color: var(--winner-color, #ffffff);
      text-shadow: 0 0 30px var(--winner-color-glow, rgba(255,255,255,0.5));
    }


    
    
    
    
    /* ==========================================
       ⚡ DUO MODE STYLES
       ========================================== */
    #duoModeModule {
      background: linear-gradient(135deg, #0f172a, #1e1b4b);
    }
    .duo-container {
      display: flex; flex: 1; padding: 40px; gap: 20px; align-items: center;
    }
    .duo-pane {
      flex: 1; display: flex; justify-content: center; align-items: center;
    }
    .duo-card {
      background: rgba(255, 255, 255, 0.03);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 30px; padding: 40px; width: 100%; max-width: 450px;
      text-align: center; backdrop-filter: blur(10px);
      box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    }
    .duo-divider {
      width: 1px; height: 60%;
      background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.1), transparent);
    }
    
    @keyframes victoryPulse {
      0% { transform: scale(1); box-shadow: 0 0 20px var(--winner-color-glow); }
      50% { transform: scale(1.02); box-shadow: 0 0 50px var(--winner-color-glow); }
      100% { transform: scale(1); box-shadow: 0 0 20px var(--winner-color-glow); }
    }
    .victory-pulse { animation: victoryPulse 2s infinite ease-in-out; }
    
    
    /* ==========================================
       📱 DUO MODE COMPACT FIT (Mobile & iPad)
       ========================================== */
    @media (max-width: 1370px) {
      
      /* 1. Lock the Module to Viewport Height */
      #duoModeModule {
        height: 100vh !important;
        overflow: hidden !important; 
        display: flex !important;
        flex-direction: column;
      }
    
      /* 2. Shrink the Header */
      #duoModeModule .brand-header {
        padding: 8px 15px !important;
        flex: 0 0 auto; 
        background: #0f172a !important;
        z-index: 100;
      }
    
      /* 3. The Container: Stack & Share Space */
      .duo-container {
        flex-direction: column !important;
        flex: 1; 
        padding: 10px !important;
        gap: 8px !important; 
        justify-content: space-evenly; 
      }
    
      /* 4. The Panes: Share height equally */
      .duo-pane {
        width: 100% !important;
        flex: 1 !important; 
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 0; 
      }
    
      /* 5. The Cards: Compact Mode */
      .duo-card {
        width: 100% !important;
        max-width: 500px !important; 
        padding: 12px !important; 
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        height: 100%; 
        max-height: 98%; 
        border-radius: 20px !important;
      }
    
      /* 6. HIDE The Divider */
      .duo-divider { display: none !important; }
    
      /* --- SCALING ELEMENTS DOWN --- */
    
      /* Timer Display */
      #duoTimerDisplay {
        font-size: 3.5rem !important; 
        margin: 0 !important;
        line-height: 1.1;
      }
      
      /* Presets (Inside Duo Card Only) */
      .duo-card .timer-presets {
        margin: 8px 0 !important;
        gap: 6px !important;
        max-width: 320px !important; /* Slightly wider for ease */
      }
      
      /* FIX: Timer Preset Size on iPad/Mobile */
      .duo-card .timer-presets button {
        padding: 10px 14px !important; /* Increased padding */
        font-size: 1rem !important;
      }
      
      /* Progress Bar */
      .timer-progress-container {
        margin: 8px auto !important;
        height: 6px !important;
      }
    
      /* Magic Hat Avatar */
      #duo_rp_avatar {
        width: 60px !important;
        height: 60px !important;
        font-size: 28px !important;
        margin: 0 auto 5px auto !important;
        border-width: 3px !important;
      }
    
      /* Magic Hat Name */
      #duo_rp_nameDisplay {
        font-size: 1.6rem !important;
        min-height: 40px !important;
        margin: 2px 0 !important;
      }
      
      #duo_rp_subtext {
        font-size: 0.8rem !important;
        margin-bottom: 8px !important;
      }
    
      /* FIX: Prevent Massive Buttons on iPad */
      #duoTimerToggleBtn, #duo_rp_spinBtn {
        flex: 0 0 auto !important; /* Prevent Vertical Growth */
        padding: 12px !important;
        font-size: 1.1rem !important;
        height: auto !important;
        min-height: 50px !important;
        max-height: 70px !important; /* Cap the height */
        width: 90% !important;
        max-width: 300px !important; 
        margin: 0 auto !important;
      }
      
      /* Award Actions Grid */
      /* Award Actions Grid - BIGGER for Touch */
      #duo_rp_actions {
        margin-top: 15px !important; /* Give it space from the "Pick" button */
        gap: 10px !important;        /* Separate them so you don't miss-click */
      }
      
      .rp-btn-action {
        padding: 16px !important;     /* Double the padding for easy tapping */
        font-size: 1.2rem !important; /* Larger text */
        font-weight: 800 !important;  /* Bold text */
        border-radius: 12px !important;
        box-shadow: 0 4px 0 rgba(0,0,0,0.2) !important; /* Add depth */
      }
      
      /* Make the Skip button distinct */
      .rp-btn-skip {
        background: rgba(255,255,255,0.1) !important;
        border: 1px solid rgba(255,255,255,0.2) !important;
        margin-bottom: 10px !important;
      }
      
      /* General Scaling */
      .rp-display-box { font-size: 2.5rem; }
      .rp-avatar-circle { width: 90px; height: 90px; font-size: 40px; }
      .rp-action-grid .rp-btn-reward { flex-direction: column; font-size: 16px; }
    }
    
    
    
    
    /* Drawer Base */
      .smart-menu-drawer {
        position: fixed;
        bottom: -100%; /* Hidden off-screen */
        left: 0;
        width: 100%;
        background: white;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
        z-index: 2000;
        transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
      }
      .smart-menu-drawer.active {
        bottom: 0; /* Slide up */
      }
    
      /* Header */
      .smart-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px 20px;
        border-bottom: 1px solid #f1f5f9;
        font-weight: 800;
        color: #1e293b;
        font-size: 16px;
      }
      .smart-menu-close {
        background: none;
        border: none;
        font-size: 20px;
        color: #94a3b8;
        cursor: pointer;
      }
    
      /* Grid Layout - Responsive based on screen width */
.smart-menu-grid {
  display: grid;
  gap: 15px;
  padding: 20px;
}

/* Mobile and iPad: two compact menu rows */
@media (max-width: 1370px) {
  .smart-menu-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 12px !important;
    flex: none !important;
    overflow: visible !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .smart-menu-primary {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .smart-menu-secondary {
    display: flex !important;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    padding: 4px 0 10px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .smart-menu-primary .smart-menu-item,
  .smart-menu-secondary .smart-menu-item {
    min-width: 0;
    padding: 6px 3px !important;
  }

  .smart-menu-secondary .smart-menu-item {
    flex: 0 0 82px;
    scroll-snap-align: start;
  }

  .smart-menu-primary .icon-box,
  .smart-menu-secondary .icon-box {
    width: 48px !important;
    height: 48px !important;
    margin: 0 auto;
  }

  .smart-menu-primary .smart-menu-item span,
  .smart-menu-secondary .smart-menu-item span {
    font-size: 10px !important;
    line-height: 1.2 !important;
    text-align: center;
  }
}

/* Preserve the existing desktop menu layout */
@media (min-width: 1371px) {
  .smart-menu-primary,
  .smart-menu-secondary {
    display: contents !important;
  }
}

/* Mobile phones (≤480px) - 4 columns */
@media (max-width: 480px) {
  .smart-menu-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 12px;
  }
}

/* Small tablets (481px - 768px) - 4 columns */
@media (min-width: 481px) and (max-width: 768px) {
  .smart-menu-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 16px;
  }
}

/* iPads and Tablets (769px - 1024px) - 5 columns */
@media (min-width: 769px) and (max-width: 1024px) {
  .smart-menu-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    padding: 20px;
  }
}

/* Larger iPads Pro and Desktops (1025px - 1370px) - 6 columns */
@media (min-width: 1025px) and (max-width: 1370px) {
  .smart-menu-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    padding: 20px;
  }
}

/* =========================================================
   DESKTOP SMART MENU
   Compact centred app menu
   Desktop only: remove profile/licence/upgrade footer
   and place Log out inside the menu
   Mobile + iPad remain unchanged
   ========================================================= */
@media (min-width: 1371px) {

  .smart-menu-drawer {
    left: 50% !important;

    width:
      min(
        1180px,
        calc(100vw - 48px)
      ) !important;

    max-height:
      calc(100vh - 80px) !important;

    transform:
      translateX(-50%) !important;

    border-radius:
      22px !important;

    overflow-x:
      auto !important;

    overflow-y:
      hidden !important;

    padding-bottom:
      0 !important;

    box-shadow:
      0 24px 70px rgba(15, 23, 42, 0.22),
      0 4px 14px rgba(15, 23, 42, 0.08) !important;

    border:
      1px solid #e2e8f0 !important;

    background:
      #ffffff !important;

    scrollbar-width:
      thin;
  }

  .smart-menu-drawer.active {
    bottom: 24px !important;
  }


  /* ---------------------------------------------------------
     HEADER
     --------------------------------------------------------- */

  .smart-menu-header {
    min-height: 66px !important;
    padding: 12px 18px !important;

    background: #ffffff !important;
    border-bottom: 1px solid #eef2f7 !important;
  }

  .smart-menu-brand {
    display: inline-block !important;
    font-size: 18px !important;
    line-height: 1 !important;
    letter-spacing: -0.4px !important;
  }

  .smart-menu-header > div:first-child > div {
    gap: 2px !important;
  }

  .smart-menu-header > div:first-child > div > div {
    margin-top: 3px !important;
  }

  .smart-menu-header > div:first-child > div > div span {
    font-size: 10px !important;
    color: #94a3b8 !important;
    font-weight: 700 !important;
  }

  .smart-menu-header button {
    width: 34px !important;
    height: 34px !important;
    font-size: 14px !important;

    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;

    transition:
      background 0.18s ease,
      color 0.18s ease,
      transform 0.18s ease !important;
  }

  .smart-menu-header button:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    transform: scale(1.05);
  }


  /* ---------------------------------------------------------
     MAIN TOOL GRID
     --------------------------------------------------------- */

  .smart-menu-grid {
    grid-template-columns: repeat(8, 104px) !important;
    justify-content: center !important;
    align-items: start !important;

    gap: 14px !important;

    padding: 22px 24px 20px !important;

    flex: none !important;
    overflow-y: visible !important;

    background: #ffffff;
  }

  .smart-menu-grid .smart-menu-item {
    gap: 7px !important;
    min-width: 0;

    padding: 8px 4px !important;

    border-radius: 14px;

    transition:
      background 0.18s ease,
      transform 0.18s ease !important;
  }

  .smart-menu-grid .smart-menu-item:hover {
    background: #f8fafc;
    transform: translateY(-2px);
  }

  .smart-menu-grid .smart-menu-item .icon-box {
    width: 50px !important;
    height: 50px !important;

    border-radius: 14px !important;

    font-size: 21px !important;

    box-shadow: none !important;
  }

  .smart-menu-grid .smart-menu-item span {
    max-width: 100px !important;

    font-size: 10.5px !important;
    line-height: 1.25 !important;
    font-weight: 700 !important;

    color: #475569 !important;

    white-space: normal;
  }

  .desktop-menu-duplicate,
  .projector-menu-item {
    display: none !important;
  }


  /* ---------------------------------------------------------
     DESKTOP ONLY:
     HIDE EXISTING PROFILE / LICENCE / UPGRADE CONTENT
     --------------------------------------------------------- */

  #smartMenuUserName,
  #smartMenuLicenseContainer,
  #smartMenuUpgradeBtn {
    display: none !important;
  }

  /*
    Hide the avatar + user information wrapper.
    In the current HTML this is the first child inside
    the profile row.
  */
  .smart-menu-drawer > div:last-child
  > div:first-child
  > div:first-child {
    display: none !important;
  }


  /* ---------------------------------------------------------
     TURN EXISTING LOGOUT BUTTON INTO A MENU ITEM
     --------------------------------------------------------- */

  /*
    Current HTML logout button:
    <button onclick="logoutTeacherAndReload()">...</button>

    Keep that exact button and exact function.
  */
  .smart-menu-drawer > div:last-child {
    padding: 0 !important;
    margin: 0 !important;

    background: #ffffff !important;
    border-top: 0 !important;
  }

  .smart-menu-drawer > div:last-child > div:first-child {
    position: absolute !important;

    top: 88px !important;
    right: 36px !important;

    width: 104px !important;
    min-height: 0 !important;

    display: block !important;
  }

  .smart-menu-drawer > div:last-child
  > div:first-child
  > button {
    width: 104px !important;
    height: auto !important;

    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;

    gap: 7px !important;

    padding: 8px 4px !important;

    background: transparent !important;
    color: #dc2626 !important;

    border: none !important;
    border-radius: 14px !important;
    box-shadow: none !important;

    cursor: pointer;

    transition:
      background 0.18s ease,
      transform 0.18s ease !important;
  }

  .smart-menu-drawer > div:last-child
  > div:first-child
  > button:hover {
    background: #fff1f2 !important;
    transform: translateY(-2px);
  }

  .smart-menu-drawer > div:last-child
  > div:first-child
  > button i {
    width: 50px !important;
    height: 50px !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    border-radius: 14px !important;

    background: #fee2e2 !important;
    color: #dc2626 !important;

    font-size: 21px !important;
  }

  .smart-menu-drawer > div:last-child
  > div:first-child
  > button::after {
    content: "Log out";

    display: block;

    font-size: 10.5px;
    line-height: 1.25;
    font-weight: 700;

    color: #dc2626;
    text-align: center;
  }
}



/* Mobile specific item adjustments for 4-column grid */
@media (max-width: 480px) {
  .smart-menu-item .icon-box {
    width: 44px;
    height: 44px;
    font-size: 18px;
    border-radius: 14px;
  }
  
  .smart-menu-item span {
    font-size: 9px;
    max-width: 65px;
  }
  
  .smart-menu-item {
    gap: 5px;
  }
}
    
      /* Items - Responsive sizing */
.smart-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.smart-menu-item .icon-box {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  transition: transform 0.1s;
}

.smart-menu-item:active .icon-box {
  transform: scale(0.95);
}

.smart-menu-item span {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-align: center;
  max-width: 80px;
  word-break: keep-all;
}

/* iPad specific adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .smart-menu-item .icon-box {
    width: 55px;
    height: 55px;
    font-size: 24px;
  }
  .smart-menu-item span {
    font-size: 11px;
    max-width: 90px;
  }
}

/* Desktop adjustments */
@media (min-width: 1025px) {
  .smart-menu-item .icon-box {
    width: 60px;
    height: 60px;
    font-size: 26px;
  }
  .smart-menu-item span {
    font-size: 12px;
    max-width: 100px;
  }
}
    
      /* Overlay Backdrop */
      #smartMenuBackdrop {
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.3); z-index: 1999;
        display: none; opacity: 0; transition: opacity 0.3s;
      }
      #smartMenuBackdrop.active {
        display: block; opacity: 1;
      }
    
    
    
      @media (max-width: 1370px) {
      .toolkit-branding {
        display: flex;
        align-items: center;
        gap: 15px;
        margin-bottom: 25px;
        padding: 10px;
        background: #faf5ff; /* Soft purple tint to match toolkit theme */
        border-radius: 16px;
        border: 1px solid #f3e8ff;
      }
    
      .toolkit-logo-circle {
        width: 85px;
        height: 85px;
        background: white;
        border-radius: 50%;
        padding: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 8px 20px rgba(147, 51, 234, 0.15);
        flex-shrink: 0;
        border: 3px solid #ffffff;
        
        /* NEW: Pulsing Animation Trigger */
        animation: logoPulse 2.5s ease-in-out infinite;
      }
    
      /* --- PREMIUM PULSE ANIMATION --- */
      @keyframes logoPulse {
        0% {
          transform: scale(1);
          box-shadow: 0 8px 20px rgba(147, 51, 234, 0.15);
        }
        50% {
          transform: scale(1.08); /* Gentle grow */
          box-shadow: 0 12px 30px rgba(147, 51, 234, 0.3); /* Stronger glow */
        }
        100% {
          transform: scale(1);
          box-shadow: 0 8px 20px rgba(147, 51, 234, 0.15);
        }
      }
    
      .toolkit-logo-circle img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
        /* The mascot head tilts slightly as it breathes */
        animation: headTilt 5s ease-in-out infinite;
      }
    
      @keyframes headTilt {
        0%, 100% { transform: rotate(0deg); }
        25% { transform: rotate(5deg); }
        75% { transform: rotate(-5deg); }
      }
    
      .toolkit-brand-content {
        display: flex;
        flex-direction: column;
        justify-content: center;
      }
    
      .toolkit-main-title {
        font-family: 'Lexend', sans-serif !important;
        font-size: 22px;
        color: #9333ea; /* Purple theme */
        margin: 0;
        line-height: 1;
      }
    
      .toolkit-tagline {
        font-size: 10px;
        font-weight: 600;
        color: #a78bfa;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin: 4px 0 0 0;
      }
      
      /* Ensure the sub-header "Quick utilities..." is moved down or styled better */
      #teacherToolkitModal p[style*="margin-bottom: 20px"] {
        font-weight: 600;
        color: #64748b;
        margin-top: 10px;
        padding-left: 5px;
      }
    }
    
    
    /* Add this new part to your CSS */
    
    /* Default: Hide the mobile-only icons on desktop */
    .mobile-only-icon {
      display: none !important;
    }
    
    @media (max-width: 1370px) {
      .mobile-only-icon {
        display: flex !important;
      }
    
      .toolkit-branding-mobile {
        display: flex;
        align-items: center;
        gap: 15px;
        margin-bottom: 25px;
        padding: 15px 20px;
        /* Clean gradient to make the green mascot pop */
        background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
        border-radius: 20px;
        border: 1px solid #e9d5ff;
      }
    
      .toolkit-mascot-free {
        width: 80px; 
        height: 80px;
        object-fit: contain;
        flex-shrink: 0;
        /* Deep shadow gives the head physical depth on the page */
        filter: drop-shadow(0 10px 15px rgba(147, 51, 234, 0.2));
        
        /* Animations: Breathing and Tilting */
        animation: mascotFloat 3s ease-in-out infinite;
      }
    
      /* --- MASCOT FLOATING ANIMATION --- */
      @keyframes mascotFloat {
        0%, 100% { 
          transform: translateY(0) rotate(0deg); 
          filter: drop-shadow(0 10px 15px rgba(147, 51, 234, 0.2));
        }
        50% { 
          transform: translateY(-5px) rotate(3deg); 
          /* Shadow stretches when it floats up */
          filter: drop-shadow(0 15px 20px rgba(147, 51, 234, 0.3));
        }
      }
    
      .toolkit-brand-content {
        display: flex;
        flex-direction: column;
        justify-content: center;
      }
    
      .toolkit-tagline {
        font-size: 13px;
        font-weight: 800;
        color: #7e22ce; /* Matching your purple brand color */
        text-transform: uppercase;
        letter-spacing: 1px;
        margin: 0;
        line-height: 1.2;
      }
    }
    
    /* Branding text inside the Smart Menu */
    .smart-menu-brand {
      font-family: 'Inter', sans-serif; /* Clean font to match your header */
      font-weight: 800;
      font-size: 16px;
      letter-spacing: -0.5px;
    }
    
    .brand-track {
      color: #000000; /* Pure Black */
    }
    
    .brand-edu {
      color: #00e676; /* TrackEDU Green */
    }
    
    /* Optional: Ensure the branding only shows on mobile/tablet if preferred */
    @media (min-width: 1371px) {
      .smart-menu-brand {
        display: none;
      }
    }
    
    
    /* Multi-Select Tick Box Styles */
    .select-tick-box {
      display: none; /* Hidden by default */
      position: absolute;
      top: 10px;
      left: 10px;
      width: 24px;
      height: 24px;
      background: white;
      border: 2px solid #000; /* Black border for the "untouched" state */
      border-radius: 50%;
      z-index: 5;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      color: #000; /* Black tick */
    }
    
    /* When Selection Mode is ON, show the boxes */
    body.selection-mode-active .select-tick-box {
      display: flex;
    }
    
    /* When a card is SELECTED */
    .student-card.selected .select-tick-box {
      background: #10b981; /* Green background */
      border-color: #10b981;
      color: white; /* White tick */
    }
    
    /* Update Student Card to provide room for the tick */
    @media (max-width: 1370px) {
      body.selection-mode-active .student-card {
        /* Slightly less padding to save vertical space in the grid */
        padding-top: 30px !important; 
      }
      
      /* Make the tick circle slightly smaller to fit the 3-column card */
      body.selection-mode-active .select-tick-box {
        width: 18px;
        height: 18px;
        font-size: 10px;
        top: 6px;
        left: 6px;
      }
    }
    
    /* Button Active State */
    #mobileSelectToggle.active {
      background: var(--primary-blue) !important;
      color: white !important;
    }
    
    
    @media (max-width: 1370px) {
        /* Prevent the class Info container from stretching the button */
        #classInfoContainer {
            display: flex !important;
            flex-direction: row !important;
            flex-wrap: nowrap !important; /* THE FIX: Forces items to stay on one line */
            align-items: center !important;
            gap: 8px !important;
            width: auto !important; /* THE FIX: Stops it from hogging 100% width */
            justify-content: flex-start !important;
        }
    
        /* Target the select button specifically */
        #mobileSelectToggle {
            flex: 0 0 auto !important;
            height: 30px !important; /* Slightly taller for a better touch target */
            width: 70px !important;
            border-radius: 8px !important;
            padding: 0 !important;
            font-size: 11px !important;
            font-weight: 700 !important;
            
            /* THE FIX: Professional Border & Styling */
            background-color: #ffffff !important;
            color: var(--brand-primary, #3b82f6) !important;
            border: 2px solid var(--brand-primary, #3b82f6) !important;
            
            /* Added Depth */
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
            display: flex !important;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
            margin-left: auto;
        }
    
        /* Modern 'Cancel' state when selection is active */
        #mobileSelectToggle.active {
            background-color: #fee2e2 !important; /* Very light red */
            border-color: #ef4444 !important;    /* Bright red border */
            color: #ef4444 !important;           /* Bright red text */
            width: 75px !important;              /* Accommodate the word 'Cancel' */
        }
        
        /* Ensure the role dropdown filter next to it has enough space */
        .filter-group select {
            width: 100% !important;
            min-width: 100px;
        }
    }
    
    
    /* Sidebar Search Button Styling */
    .sidebar .nav-item .fa-search {
      color: var(--primary-blue); /* Give the magnifying glass a distinct color */
    }
    
    /* Optional: Slight hover effect to make it feel "Premium" */
    .nav-item[onclick*="openStudentSearchModal"]:hover {
      background: rgba(30, 58, 138, 0.08);
      transform: translateX(4px);
      transition: all 0.2s ease;
    }
    
    
    .highlighted {
      animation: searchHighlight 2s ease-out;
      background-color: #fff9c4 !important; /* Soft yellow pulse */
    }
    
    @keyframes searchHighlight {
      0% { transform: scale(1); box-shadow: 0 0 0px var(--primary-blue); }
      50% { transform: scale(1.02); box-shadow: 0 0 20px var(--primary-blue); }
      100% { transform: scale(1); box-shadow: 0 0 0px transparent; }
    }
    
    @keyframes badgeClickPulse {
      0% { transform: scale(1); }
      50% { transform: scale(1.1); }
      100% { transform: scale(1); }
    }
    
    .copy-pulse {
      animation: badgeClickPulse 0.3s ease-out;
      transition: background-color 0.3s ease;
    }
    
    
    
    
    
    .preset-reason-input {
      height: 38px;
      font-size: 14px;
    }
    
    #reasonsInputsContainerMobile {
      padding-right: 5px; /* Space for the scrollbar */
    }
    
    
    
    /* App-style Scrolling Chips */
    .mobile-reason-chips {
      display: flex;
      gap: 10px;
      overflow-x: auto;
      padding: 5px 0 15px 0;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none; /* Hide scrollbar for clean app look */
    }
    
    .mobile-reason-chips::-webkit-scrollbar {
      display: none;
    }
    
    .reason-chip {
      flex: 0 0 auto;
      background: #f1f5f9;
      border: 1.5px solid #e2e8f0;
      padding: 10px 18px;
      border-radius: 25px;
      font-size: 14px;
      font-weight: 600;
      color: #475569;
      white-space: nowrap;
      transition: all 0.2s ease;
      cursor: pointer;
    }
    
    .reason-chip:active {
      transform: scale(0.95);
      background: #e2e8f0;
    }
    
    .reason-chip.selected {
      background: var(--primary-blue);
      color: white;
      border-color: var(--primary-blue);
      box-shadow: 0 4px 10px rgba(30, 58, 138, 0.2);
    }
    
    
    
    /* Ensure chips in the modal look like buttons and wrap properly */
    #modalReasonChips .reason-chip {
      flex: 0 0 auto;
      background: #f1f5f9;
      border: 1.5px solid #e2e8f0;
      padding: 8px 16px;
      border-radius: 20px;
      font-size: 13px;
      font-weight: 600;
      color: #475569;
      cursor: pointer;
      transition: all 0.2s ease;
    }
    
    #modalReasonChips .reason-chip.selected {
      background: var(--primary-blue);
      color: white;
      border-color: var(--primary-blue);
    }
    
    /* Animations for the mini-modal */
    #reasonSelectorModal.show {
      display: flex !important;
      opacity: 1;
    }
    
    
    
    
    #selectionToolbar .btn-custom i.fa-comment-dots {
      color: #fff;
    }
    
    #selectionToolbar .btn-custom:active {
      background: #d97706 !important; /* Darker amber on tap */
    }
    
    
    
    
    /* Styles the student count in the History Table */
    #awardHistoryContent td {
      line-height: 1.4;
    }
    
    /* This targets the text we added in JS */
    .history-reason-count {
      display: inline-block;
      font-size: 10px;
      background: #f1f5f9;
      color: #64748b;
      padding: 2px 6px;
      border-radius: 4px;
      font-weight: 700;
      margin-left: 5px;
      border: 1px solid #e2e8f0;
      text-transform: uppercase;
    }
    
    
    
    /* --- FLOATING SAVE BUTTON (DESKTOP) --- */
    @media (min-width: 1371px) {
      /* Container for the desktop floating button */
      .save-toolbar-desktop {
        position: fixed;
        bottom: 30px;
        right: 40px;
        z-index: 1100;
        pointer-events: none; /* Allow clicks to pass through to items behind if button isn't there */
      }
    
      #save-changes-btn.floating-save-btn {
        pointer-events: auto; /* Re-enable clicking for the button itself */
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 28px;
        height: 56px;
        font-size: 15px;
        font-weight: 700;
        border-radius: 50px; /* Modern pill shape */
        background: linear-gradient(135deg, #10b981, #059669); /* High-visibility Success Green */
        box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
        border: 2px solid rgba(255, 255, 255, 0.2);
        transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        color: white !important;
      }
    
      #save-changes-btn.floating-save-btn:hover {
        transform: translateY(-5px) scale(1.05);
        box-shadow: 0 15px 30px rgba(16, 185, 129, 0.5);
        background: linear-gradient(135deg, #059669, #047857);
      }
    
      /* Style for the text inside the button */
      #save-changes-btn.floating-save-btn .save-text {
        display: inline-block;
        letter-spacing: 0.5px;
      }
    
      /* Style for the Red Unsaved Dot Badge */
      #unsavedBadge.unsaved-badge {
        position: static; /* Reset from mobile absolute positioning */
        background: #ffffff;
        color: #ef4444;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: flex; /* Changed from inline to flex for centering */
        align-items: center;
        justify-content: center;
        font-size: 12px;
        font-weight: 900;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        margin-left: 5px;
      }
    }
    
    /* Visibility Logic: Only show the floating container when the students section is active */
    body:not(.active-section-students) .save-toolbar-desktop {
      display: none !important;
    }
    
    /* Animation for when changes are detected */
    @keyframes savePulse {
      0% { transform: scale(1); box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4); }
      50% { transform: scale(1.05); box-shadow: 0 10px 35px rgba(16, 185, 129, 0.7); }
      100% { transform: scale(1); box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4); }
    }
    
    .save-pulse-active {
      animation: savePulse 2s infinite ease-in-out;
    }
    
    
    /* --- TEACHER APP BRANDING COLORS --- */
    /* Light Mode */
    .smart-menu-brand .brand-track {
      color: #1e293b;
    }
    
    .smart-menu-brand .brand-edu {
      color: #10b981;
    }

    /* Dark Mode: ensure Teacher App branding is readable */
    body.house-display-dark
    #smartMenuDrawer
    .smart-menu-brand .brand-track {
      color: #f8fafc !important;
    }

    body.house-display-dark
    #smartMenuDrawer
    .smart-menu-brand .brand-edu {
      color: #34d399 !important;
    }
    
    /* Ensure the drawer background is white for Teacher App */
    #smartMenuDrawer {
      background: #ffffff; 
      border-top: 1px solid #e2e8f0;
    }
    
    
    @media (max-width: 1370px) {
      /* Hide the toggle header button */
      .award-toggle-header {
        display: none !important;
      }
    
      /* Hide the actual award form and the container */
      .award-class-house-container, 
      #awardForm {
        display: none !important;
      }
    
      /* Hide the house points pills overview as well if they are visible */
      .house-points-container {
        display: none !important;
      }
    }
    
    
    
    /* --- MASCOT: DESKTOP NAVIGATION BUTTON --- */
    .toolkit-icon-mascot {
      width: 42px; /* Prominent size for the nav bar */
      height: 42px;
      object-fit: contain;
      margin-left: -8px;
      /* Soft shadow for premium depth against light buttons */
      filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
      transition: transform 0.2s ease;
      
      /* Shared Desktop Floating Animation */
      animation: mascotFloatDesktop 3s ease-in-out infinite;
    }
    
    /* Hover lift for the Nav button - provides interactive feedback */
    .btn:hover .toolkit-icon-mascot {
      transform: translateY(-3px) rotate(5deg) scale(1.1);
    }
    
    /* --- MASCOT: MOBILE/IPAD FLOATING ACTION BUTTON (FAB) --- */
    .toolkit-fab {
      position: fixed;
      /* Mirror the placement of other key floating UI elements */
      bottom: calc(90px + env(safe-area-inset-bottom, 0px)); 
      left: 20px; 
      width: 65px !important; 
      height: 65px !important;
      border: none !important;
      background: transparent !important; /* Borderless/Transparent feel */
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1100;
      cursor: pointer;
      box-shadow: none !important; 
      outline: none;
      -webkit-tap-highlight-color: transparent;
    }
    
    .toolkit-fab-mascot {
      width: 100%;
      height: 100%;
      object-fit: contain;
      /* Deep shadow provides 3D depth against student management cards */
      filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.3));
      transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
      
      /* Shared Mobile Floating Animation */
      animation: mascotFloatMain 3s ease-in-out infinite;
    }
    
    /* --- INTERNAL TOOLKIT BRANDING (DESKTOP & MOBILE) --- */
    .toolkit-mascot-free {
      width: 90px; /* Hero scale for branding headers */
      height: 90px;
      object-fit: contain;
      flex-shrink: 0;
      filter: drop-shadow(0 10px 15px rgba(147, 51, 234, 0.25));
      
      /* Apply shared branding animation */
      animation: mascotFloatDesktop 3s ease-in-out infinite;
    }
    
    /* --- KEYFRAME ANIMATIONS: WORLD CLASS "STICKER" FEEL --- */
    
    /* Mobile/iPad Floating Logic: Slightly higher lift for smaller screens */
    @keyframes mascotFloatMain {
      0%, 100% { 
        transform: translateY(0) rotate(0deg); 
        filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.3));
      }
      50% { 
        transform: translateY(-8px) rotate(3deg); 
        /* Shadow softens and expands as the mascot "lifts" closer to the user */
        filter: drop-shadow(0 18px 20px rgba(0, 0, 0, 0.2));
      }
    }
    
    /* Desktop Floating Logic: Subtle, professional breathing effect */
    @keyframes mascotFloatDesktop {
      0%, 100% { 
        transform: translateY(0) rotate(0deg); 
        filter: drop-shadow(0 10px 15px rgba(147, 51, 234, 0.25));
      }
      50% { 
        transform: translateY(-6px) rotate(2deg); 
        filter: drop-shadow(0 16px 22px rgba(147, 51, 234, 0.2));
      }
    }
    
    /* --- INTERACTIVE FEEDBACK --- */
    
    /* Satisfying "Squish" when tapped - overrides the float temporarily */
    .toolkit-fab:active .toolkit-fab-mascot {
      transform: scale(0.85) translateY(4px) !important;
      filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
      animation: none; 
    }
    
    
    
    .toolkit-mascot-sticker {
      width: 90px; /* Increased size significantly */
      height: 90px;
      object-fit: contain;
      flex-shrink: 0;
      /* Deepened the shadow slightly to match the larger scale */
      filter: drop-shadow(0 10px 15px rgba(147, 51, 234, 0.25));
      animation: mascotFloat 3s ease-in-out infinite;
    }
    
    .toolkit-text-group {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    
    .toolkit-branding-refined {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
  padding: 20px 25px;
  background: #faf5ff; 
  border-radius: 20px;
  border: 1px solid #f3e8ff;
  flex-wrap: wrap;
}

.toolkit-sub-brand {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.toolkit-sub-brand .track-part {
  color: #1e293b;
}

.toolkit-sub-brand .edu-part {
  color: #00e676;
}

.toolkit-main-brand {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: #7e22ce;
  margin: 0;
  line-height: 1.1;
}
    
    @keyframes mascotFloat {
      0%, 100% { transform: translateY(0) rotate(0deg); }
      50% { transform: translateY(-6px) rotate(3deg); } /* More dynamic float for larger size */
    }
    
    
    /* --- DEFAULT MOBILE LAYOUT (2 Columns) --- */
    .toolkit-fullscreen-content {
      width: 90%;
      max-width: 500px;
      max-height: 80vh;
      overflow-y: auto;
      border-radius: 20px;
    }
    
    /* 🔥 FIX: Teacher Toolkit Modal - Remove top padding that pushes title down */
    #teacherToolkitModal .toolkit-fullscreen-content {
      padding-top: 20px !important;

      background:
        linear-gradient(
          135deg,
          var(--school-canvas) 0%,
          var(--school-surface-soft) 100%
        ) !important;
    }
    
    /* 🔥 FIX: Ensure header section has proper spacing from X button */
    #teacherToolkitModal .toolkit-header-section {
      margin-top: 0 !important;
      padding-top: 0 !important;
    }
    
    /* 🔥 FIX: Position X button correctly in Toolkit modal */
    #teacherToolkitModal .house-expanded-close {
      position: absolute !important;
      top: 12px !important;
      right: 12px !important;
      width: 32px !important;
      height: 32px !important;
      background: #ef4444 !important;
      color: white !important;
      border: none !important;
      border-radius: 50% !important;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      cursor: pointer !important;
      z-index: 100 !important;
    }
    
    /* 🔥 PREMIUM TOOLKIT CARD STYLES */
    .toolkit-card {
      background:
        var(--school-surface) !important;

      border-radius: 20px !important;
      padding: 20px 16px !important;
      text-align: center !important;
      cursor: pointer !important;

      transition:
        all
        0.3s
        cubic-bezier(
          0.4,
          0,
          0.2,
          1
        ) !important;

      border:
        1px solid
        var(--school-border) !important;

      box-shadow:
        0 4px 12px
        rgba(
          0,
          0,
          0,
          0.03
        ) !important;

      position:
        relative !important;
      overflow: hidden !important;
    }
    
    /* Premium gradient overlay on hover */
    .toolkit-card::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 3px;
      background: linear-gradient(90deg, #10b981, #22d3ee, #8b5cf6);
      transform: scaleX(0);
      transition: transform 0.3s ease;
    }
    
    .toolkit-card:hover::before {
      transform: scaleX(1);
    }
    
    .toolkit-card:hover {
      transform: translateY(-6px) !important;
      box-shadow: 0 20px 30px -12px rgba(0, 0, 0, 0.15) !important;
      border-color: #cbd5e1 !important;
    }
    
    .toolkit-card:active {
      transform: translateY(-2px) !important;
    }
    
    /* Icon styling */
    .toolkit-icon {
      width: 56px !important;
      height: 56px !important;
      border-radius: 16px !important;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      margin: 0 auto 12px auto !important;
      font-size: 24px !important;
      transition: all 0.3s ease !important;
    }
    
    .toolkit-card:hover .toolkit-icon {
      transform: scale(1.05) rotate(2deg) !important;
    }

    .toolkit-new-badge {
      position: absolute;
      top: 10px;
      right: 10px;

      display: inline-flex;
      align-items: center;
      justify-content: center;

      min-height: 22px;
      padding: 0 8px;

      border-radius: 999px;

      background: linear-gradient(135deg, #1d4ed8, #2563eb);
      border: 1px solid rgba(255,255,255,0.35);

      color: #ffffff;

      font-size: 8px;
      font-weight: 900;
      letter-spacing: 0.8px;
      line-height: 1;

      box-shadow:
        0 4px 10px
        rgba(37, 99, 235, 0.22);

      z-index: 2;
    }
    
    /* Toolkit name */
    .toolkit-name {
      font-size: 15px !important;
      font-weight: 800 !important;
      color: #1e293b !important;
      margin-bottom: 6px !important;
      letter-spacing: -0.2px !important;
    }
    
    /* Toolkit description */
    .toolkit-desc {
      font-size: 11px !important;
      color: #64748b !important;
      line-height: 1.4 !important;
      font-weight: 500 !important;
    }
    
    /* Color variants for icons */
    .toolkit-card[data-tool="magic-hat"] .toolkit-icon { background: #faf5ff; color: #9333ea; }
    .toolkit-card[data-tool="timer"] .toolkit-icon { background: #e0f2fe; color: #0284c7; }
    .toolkit-card[data-tool="house"] .toolkit-icon { background: #ecfdf5; color: #10b981; }
    .toolkit-card[data-tool="quiz"] .toolkit-icon { background: #fef3c7; color: #d97706; }
    
    .toolkit-grid-layout {
      display: grid; 
      grid-template-columns: 1fr 1fr; /* 2 Columns on Mobile */
      gap: 16px; 
      padding-bottom: 50px;
    }


    /* Mobile: Stack mascot+text and ? button vertically, centered */
@media (max-width: 550px) {
  .toolkit-branding-refined {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
  }
  
  .toolkit-branding-left {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .toolkit-branding-left img {
    margin: 0 auto;
  }
  
  .toolkit-branding-left div {
    justify-content: center;
  }
  
  .teachertoolkit-help-btn {
    margin-top: 8px;
  }
}
    
    /* --- DESKTOP FULLSCREEN OVERRIDE --- */
    @media (min-width: 1024px) {
      
      /* Target specific ID to affect only this modal */
      #teacherToolkitModal .toolkit-fullscreen-content {
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        padding: 30px 50px !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
      }
    
      /* Make the header section look grander */
      #teacherToolkitModal .toolkit-header-section {
        width: 100%;
        max-width: 1200px;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 30px;
      }
      
      /* Branding refinement for desktop */
      .toolkit-branding-refined {
        background: white !important;
        border-radius: 24px !important;
        padding: 20px 32px !important;
        margin-bottom: 30px !important;
        box-shadow: 0 8px 20px rgba(0,0,0,0.04) !important;
      }
    
      /* Switch to 4 columns on desktop */
      #teacherToolkitModal .toolkit-grid-layout {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 24px !important;
        width: 100%;
        max-width: 1200px;
      }
    
      /* Larger cards on desktop */
      #teacherToolkitModal .toolkit-card {
        padding: 28px 20px !important;
      }
      
      #teacherToolkitModal .toolkit-card:hover {
        transform: translateY(-8px) !important;
      }
    
      /* Scale up icons slightly */
      #teacherToolkitModal .toolkit-icon {
        width: 70px !important;
        height: 70px !important;
        font-size: 32px !important;
        margin-bottom: 18px !important;
      }
    
      #teacherToolkitModal .toolkit-name {
        font-size: 17px !important;
        margin-bottom: 8px !important;
      }
      
      #teacherToolkitModal .toolkit-desc {
        font-size: 12px !important;
      }
    }
    
    /* iPad specific adjustments */
    @media (min-width: 768px) and (max-width: 1024px) {
      #teacherToolkitModal .toolkit-grid-layout {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 20px !important;
      }

      toolkit-branding-refined {
    flex-direction: column;
    text-align: center;
  }
      
      .toolkit-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 26px !important;
      }
    }
    
    
    
    
    /* Fix Input Group Layout */
    /* --- MANAGE CLASS MODAL STYLES --- */
    
    /* Fix the Input Group Layout (Prevents Squashing) */
    .manage-input-group {
      display: flex !important;
      flex-direction: row !important;
      align-items: center !important; /* Centers vertically, fixes stretched icons */
      gap: 10px !important;
      width: 100% !important;
    }
    
    /* Ensure Wrappers take full available width */
    .manage-input-group #catSelectWrapper,
    .manage-input-group #catInputWrapper,
    .manage-input-group #classSelectWrapper,
    .manage-input-group #classInputWrapper {
      flex: 1 1 auto !important; /* Grow and Shrink allowed */
      min-width: 0 !important;   /* Critical fix for flexbox overflow */
      width: 100% !important;
    }
    
    /* Force Height on Inputs & Selects */
    .manage-input-group .form-control {
      height: 46px !important;
      width: 100% !important;
      box-sizing: border-box !important;
      font-size: 16px !important; /* Prevents iOS Zoom */
    }
    
    /* Fix the Square Toggle Buttons */
    .manage-input-group .toggle-btn {
      height: 46px !important;   /* Match input height */
      width: 46px !important;    /* Square */
      flex: 0 0 46px !important; /* Fixed width, never shrink */
      padding: 0 !important;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      border-radius: 8px !important;
    }
    
    /* --- MOBILE / IPAD FULL SCREEN OVERRIDES (Max 1370px) --- */
    @media (max-width: 1370px) {
      /* 1. Force Modal Wrapper to Full Screen */
      #addEditTeacherModal.house-expanded {
        align-items: flex-start !important; /* Align to top */
        padding: 0 !important;
      }
    
      /* 2. Force Content to Full Width/Height */
      .manage-class-content {
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        padding: 20px !important;
        padding-top: 60px !important; /* Space for Close Button if needed */
        box-sizing: border-box !important;
        overflow-y: auto !important;
      }
      
      
    
      /* 4. Action Buttons Stack */
      .modal-actions {
        flex-direction: column-reverse !important; /* Cancel below Save */
        width: 100% !important;
      }
      
      .modal-actions button {
        width: 100% !important;
        height: 50px !important;
      }
    
      /* 5. Header Layout */
      .manage-class-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding-right: 0 !important; /* Reset padding since X is fixed top-right */
        margin-top: 10px !important;
      }
    }
    
    
    
    @keyframes pillPop {
        0% { transform: scale(1); }
        50% { transform: scale(1.4); background-color: #10b981; color: white; }
        100% { transform: scale(1); }
      }
    
      /* New Red Pulse for point removal */
      @keyframes pillPopRed {
        0% { transform: scale(1); }
        50% { transform: scale(1.4); background-color: #ef4444; color: white; }
        100% { transform: scale(1); }
      }
      
      .points-removed-pulse {
        animation: pillPopRed 0.6s ease-out !important;
      }
    
    
    
    @media (max-width: 1370px) {
      /* 1. Force the wrapper to the top edges */
      #resetConfirmationModal {
        align-items: flex-start !important; 
        padding: 0 !important;
      }
    
      /* 2. Make the content box fill the entire screen */
      #resetConfirmationModal .house-expanded-content {
        width: 100vw !important;
        max-width: none !important;
        height: 100vh !important;
        max-height: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 20px !important;
        padding-top: 60px !important; /* Space for the Close (X) button */
        box-sizing: border-box !important;
        display: flex;
        flex-direction: column;
      }
    
      /* 3. Stack the buttons vertically for easier tapping (Cancel at the bottom) */
      #resetConfirmationModal .house-expanded-content > div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 12px !important;
        margin-top: auto !important; /* Pushes buttons slightly further down */
      }
    
      /* 4. Make the buttons tall and touch-friendly */
      #resetConfirmationModal .btn {
        width: 100% !important;
        height: 54px !important;
        font-size: 16px !important;
      }
    }
    
    
    /* =========================================================
       🍎 UNIVERSAL "X" BUTTON (Reduced Size & Native Touch)
       ========================================================= */
    .house-expanded-close, 
    .btn-close, 
    .leaderboard-fullscreen-close {
      position: absolute !important; 
      top: 12px !important;
      right: 12px !important;
      
      /* Reduced universal size for a cleaner, modern look */
      width: 28px !important;
      height: 28px !important;
      min-width: 28px !important;
      min-height: 28px !important;
      padding: 0 !important;
      margin: 0 !important;
      
      background: #ef4444 !important; 
      color: #ffffff !important;
      border: 1.5px solid #ffffff !important; 
      border-radius: 50% !important;
      
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      z-index: 999999 !important; 
      box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
      cursor: pointer !important;
      
      /* Essential touch optimization */
      touch-action: manipulation !important;
      -webkit-tap-highlight-color: transparent !important;
    }
    
    /* Scaled icon to fit the 28px button */
    .house-expanded-close i, 
    .btn-close i, 
    .leaderboard-fullscreen-close i {
      font-size: 14px !important; 
      margin: 0 !important;
      padding: 0 !important;
      line-height: 1 !important;
      display: block !important;
      pointer-events: none !important; 
    }
    
    /* Updated tactile shrink effect for smaller dimensions */
    .house-expanded-close:active, 
    .btn-close:active, 
    .leaderboard-fullscreen-close:active {
      transform: scale(0.9) !important;
      background: #b91c1c !important;
      box-shadow: 0 1px 4px rgba(0,0,0,0.2) !important;
      transition: transform 0.1s ease !important;
    }
    
    @media (max-width: 1370px) {
      /* Reduced top padding since the button is now smaller */
      .house-expanded-content,
      .modal-content,
      .toolkit-fullscreen-content {
        padding-top: 50px !important; 
      }
    }
    
    /* UNIFIED COMPACT CARD (Mobile up to iPad 1370px) - REFINED HEIGHT & ICON */
    @media (max-width: 1370px) {
      #students-section .student-card {
        position: relative;
        margin: 0;
        border-radius: 20px !important; 
        /* Dynamic House Gradient */
        background: linear-gradient(to bottom, #ffffff 82%, var(--house-color) 175%) !important;
        box-shadow: 0 3px 8px rgba(0,0,0,0.08);
        border: 1px solid rgba(0,0,0,0.05);
        display: block !important; 
        /* Increased height for more breathing room */
        min-height: 138px !important; 
        max-height: 138px !important; 
        padding: 0 !important;
        overflow: hidden !important;
        transition: all 0.3s ease;
      }
      
      /* Ensure the card itself doesn't clip the border-radius */
      #students-section .student-card,
      #students-section .student-card.collapsed {
        border-radius: 20px !important;
        overflow: hidden !important;
      }
      
      /* Also ensure the inner header doesn't override the card's border-radius */
      #students-section .student-card .student-card-header {
        border-radius: inherit;
      }
    
      /* THE FIX: Scaled down Tap Target with Dynamic House Border */
      .student-card.collapsed .hero-shield {
          width: 66px !important;     
          height: 66px !important; 
          font-size: 34px !important; 
          margin: 0 auto 5px auto !important;
          box-shadow: 0 4px 10px rgba(0,0,0,0.1);
          background: white !important;
          display: flex !important;
          align-items: center !important;
          justify-content: center !important;
          border: 4px solid var(--house-color) !important; 
          box-sizing: border-box !important;
      }
    
      #students-section .student-card.expanded {
        max-height: 1000px !important; 
        display: flex !important;
        flex-direction: column;
        overflow: visible !important;
      }
    }
    
    /* 📱 SMALLER MOBILE ADJUSTMENTS FOR AVATAR ICON (780px and below) */
    @media (max-width: 780px) {
      #students-section .student-card.collapsed .hero-shield {
          width: 58px !important;     
          height: 58px !important; 
          font-size: 30px !important; 
          border-width: 3px !important; 
      }
    }
    
      /* 3. ULTRA-COMPACT MOBILE HEADER - SECURE CLICKING */
      @media (max-width: 1370px) {
        #students-section .student-card.collapsed .student-card-header {
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          padding: 0 !important;       
          height: 100%;
          box-sizing: border-box;
          pointer-events: none; /* Block accidental clicks when small */
        }
    
        /* Keep the card-header clickable when expanded so the teacher can tap anywhere on the top to close */
        #students-section .student-card.expanded .student-card-header {
          pointer-events: auto; 
          cursor: pointer;
        }
    
        /* Always allow clicks on these specific elements */
        .student-card .hero-shield,
        .student-card .expansion-indicator {
          pointer-events: auto;
          cursor: pointer;
        }
      }





      .expansion-indicator { 
  display: flex !important; 
  position: absolute !important;
  bottom: 2px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #000000 !important;  /* ← changed from var(--house-color) */
  font-size: 14px !important;
  opacity: 0.4 !important; 
  z-index: 15;
  transition: all 0.2s ease !important;
}
    
    
    @media (max-width: 1370px) {
        /* The Floating Points Pill */
        .collapsed-points-pill {
          position: absolute !important;
          top: 8px !important;
          right: 8px !important;
          background: rgba(255, 255, 255, 0.95) !important; 
          color: #0f172a !important; 
          font-size: 11px !important;
          font-weight: 900 !important;
          padding: 2px 8px !important;
          border-radius: 6px !important;
          border: 1px solid rgba(0,0,0,0.1) !important;
          z-index: 15;
          box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
        }
        
        
        /* Subtle interaction feedback */
        .expansion-indicator:active {
          opacity: 0.8 !important; /* Lights up slightly when tapped */
          transform: translateX(-50%) translateY(2px) !important;
        }
        
        /* Centered Header (Avatar + Name) */
        #students-section .student-card.collapsed .student-card-header {
          padding-top: 15px !important;
          display: flex !important;
          flex-direction: column !important;
          align-items: center !important;
          justify-content: center !important;
          height: 100%;
        }
      }
    
    
    /* 1. Default: Hide the text labels on small mobile screens (0px to 780px) */
    .btn-text.show-tablet-up {
      display: none !important;
    }
    
    /* 2. Show the full text on iPads and Desktops (781px and up) */
    @media (min-width: 781px) {
      .btn-text.show-tablet-up {
        display: inline !important;
        margin-left: 5px;
        font-weight: 700;
      }
    
      /* Optional: Adjust button padding to look better with text */
      .header-actions .btn {
        padding: 8px 12px !important;
        width: auto !important; /* Allow button to grow for text */
        min-height: 36px;
      }
    }
    
    /* 3. Refinement: Ensure buttons don't get too cramped on mid-size tablets */
    @media (min-width: 781px) and (max-width: 1100px) {
      .btn-text.show-tablet-up {
        font-size: 11px !important; /* Slightly smaller text for 10-inch iPads */
      }
    }
    
    
    /* GESTURE HINT STRIP */
    .quick-gesture-hint {
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: #f0fdf4; /* Light Green */
      border: 1px solid #bbf7d0;
      padding: 12px 16px;
      border-radius: 12px;
      margin: 10px 16px 15px 16px; /* Spacing from edges */
      animation: hintSlideIn 0.5s ease-out;
      transition: all 0.3s ease;
      position: relative;
      z-index: 10;
    }
    
    .hint-content {
      display: flex;
      gap: 15px;
      font-size: 11px;
      font-weight: 700;
      color: #166534;
      flex-wrap: wrap; /* Allow items to wrap on small phones */
    }
    
    .hint-item {
      display: flex;
      align-items: center;
      gap: 6px;
    }
    
    .hint-item i {
      font-size: 14px;
      color: #10b981;
    }
    
    .close-hint {
      color: #166534;
      opacity: 0.6;
      font-size: 18px;
      cursor: pointer;
      padding: 5px;
      margin-left: 10px;
      transition: opacity 0.2s;
    }
    
    .close-hint:hover {
      opacity: 1;
    }
    
    @keyframes hintSlideIn {
      from { opacity: 0; transform: translateY(-10px); }
      to { opacity: 1; transform: translateY(0); }
    }
    
    
    /* =========================================================
       🖥️ DESKTOP: IMMERSIVE STUDENT MANAGEMENT MODE
       ========================================================= */
    @media (min-width: 1371px) {
      /* 1. Hide the top header and announcement bar ONLY when in the Students section */
      body.active-section-students .header,
      body.active-section-students .announcement-bar {
        display: none !important;
      }
    
      /* 2. Remove the top padding from the main container so the content moves up to the ceiling */
      body.active-section-students .app-container {
        padding-top: 0 !important;
        min-height: 100vh !important;
      }
    
      /* 3. Stretch the sidebar so it fills the gap left by the missing header */
      body.active-section-students .sidebar {
        top: 0 !important;
        height: 100vh !important;
      }
    }
    
    
    
    
    
    
    /* ==========================================
       🔒 VAULT CSS (PRO SCALING & CLEAN)
       ========================================== */
    .app-container, .header { display: none; } 
    
    #vaultLockScreen {
      position: fixed;
      inset: 0;
      background: linear-gradient(135deg, #f0fdf4 0%, #f8fafc 100%);
      z-index: 999999;
      display: none; 
      align-items: center;
      justify-content: center;
      flex-direction: column;
    }
    
    /* Fluid container that scales on smaller screens */
    .modern-vault-card {
      background: #ffffff;
      padding: 24px 16px; /* ⬅️ REDUCED for better mobile fit */
      border-radius: 24px;
      text-align: center;
      max-width: 420px; /* Default for mobile */
      width: 90%; 
      max-height: 95vh; /* ⬅️ FAILSAFE: Prevents cut-off on tiny screens */
      overflow-y: auto; /* ⬅️ FAILSAFE: Allows scrolling if screen is too short */
      box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
      border: 1px solid #e2e8f0;
      animation: vaultPop 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
      box-sizing: border-box;
    }
    
    /* Scalable Logo Circle (Reduced by 10%) */
    .vault-logo-circle {
      /* Dynamic size: 142px on phone, up to 252px on iPad/Desktop */
      width: clamp(142px, 36vw, 252px); 
      height: clamp(142px, 36vw, 252px);
      margin: 0 auto;
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative; 
      background: #ffffff;
      border-radius: 50%;
      box-shadow: 0 4px 20px rgba(0,0,0,0.04); 
    }
    
    .vault-logo-img {
      width: 65%; 
      height: 65%;
      object-fit: contain;
    }
    
    #vaultSchoolName {
      color: #1e3a8a;
      font-family: 'Inter', sans-serif;
      font-weight: 700;
      line-height: 1.2;
    }
    
    .vault-subtitle {
      color: #475569;
      font-size: 16px;
      margin-top: 10px; /* ⬅️ ADDED: Tighter spacing */
      margin-bottom: 15px; /* ⬅️ REDUCED: Tighter spacing */
      font-weight: 700;
      font-family: 'Inter', sans-serif;
    }
    
    .vault-input-wrapper {
      position: relative;
      margin-bottom: 20px;
    }
    
    .vault-input-icon {
      position: absolute;
      left: 18px;
      top: 50%;
      transform: translateY(-50%);
      color: #94a3b8;
      font-size: 18px;
      transition: color 0.3s ease;
      z-index: 2;
    }
    
    .modern-vault-input {
      width: 100%;
      padding: 16px 16px 16px 52px;
      border-radius: 14px; 
      border: 2px solid #e2e8f0;
      background: #f8fafc;
      color: #1e293b;
      font-size: 16px; 
      font-weight: 700;
      letter-spacing: 1px;
      transition: all 0.3s ease;
      box-sizing: border-box;
    }
    
    .modern-vault-input:focus {
      border-color: #10b981; 
      background: #ffffff;
      outline: none;
      box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
    }
    
    .modern-vault-input:focus ~ .vault-input-icon {
      color: #10b981;
    }
    
    .modern-vault-input::placeholder {
      color: #94a3b8;
      font-weight: 600;
      letter-spacing: normal;
    }
    
    .btn-vault {
      width: 100%;
      padding: 18px;
      background: #10b981; 
      color: white;
      border: none;
      border-radius: 14px;
      font-size: 16px;
      font-weight: 800;
      cursor: pointer;
      box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
    }
    
    .btn-vault:hover {
      background: #059669;
      transform: translateY(-2px);
      box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
    }
    
    #vaultError {
      color: #ef4444;
      margin-top: 15px;
      display: none;
      font-size: 14px;
      font-weight: 700;
      background: #fef2f2;
      padding: 12px;
      border-radius: 8px;
      border: 1px solid #fecaca;
    }
    
    @keyframes vaultPop {
      0% { transform: scale(0.95) translateY(15px); opacity: 0; }
      100% { transform: scale(1) translateY(0); opacity: 1; }
    }
    
    /* ==========================================
       📱 IPAD & TABLET (768px to 1370px)
       ========================================== */
    @media (min-width: 768px) and (max-width: 1370px) {
      .modern-vault-card {
        padding: 50px 40px;
        max-width: 550px; /* Increased from 450px for iPad Pro */
      }
    
      #vaultSchoolName {
        font-size: 26px !important;
        margin-bottom: 35px !important;
      }
    
      .vault-subtitle {
        font-size: 18px;
        margin-top: 30px !important;
        margin-bottom: 35px;
      }
    
      .modern-vault-input {
        height: 60px;
        font-size: 18px;
      }
    
      .btn-vault {
        height: 60px;
        font-size: 18px;
      }
      
      #vaultHelpContact {
        margin-top: 40px !important;
        font-size: 15px !important;
      }
    }
    
    
    /* SHAKE ANIMATION FOR LOGIN ERROR */
    .shake-error {
      animation: vaultShake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    }
    
    @keyframes vaultShake {
      10%, 90% { transform: translate3d(-1px, 0, 0); }
      20%, 80% { transform: translate3d(2px, 0, 0); }
      30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
      40%, 60% { transform: translate3d(4px, 0, 0); }
    }
    
    /* MOBILE GPU SAVER: Disable expensive blurs on mobile/tablets */
    @media (max-width: 1370px) {
      #selectionToolbar,
      .fullscreen-loading-overlay,
      .rp-info-overlay,
      .duo-card,
      div[style*="backdrop-filter"] {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background-color: rgba(15, 23, 42, 0.98) !important; /* Fallback to solid dark */
      }
    
      /* Fix the main loading screen so it stays clean and white on iPads */
      .loading-overlay {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background-color: rgba(255, 255, 255, 0.98) !important; /* Solid White */
      }
    }
    
    
    
    
    
    
    /* 🎁 LOOT DROP MODULE THEME - CLEAN LIGHT MODE */
    #lootDropModule {
      background: #ffffff; /* Pure white background */
      color: #1e293b; /* Dark slate text for high contrast */
      z-index: 99999 !important;
    }
    
    #lootDropModule .brand-header {
      background: #ffffff !important; /* Pure white to match the body */
      border-bottom: 1px solid #e2e8f0 !important;
    }
    
    /* Ensure buttons don't have accidental boxes/shadows */
    #lootDropModule .close-module-btn, 
    #lootDropModule .rp-info-btn {
      box-shadow: none !important;
      outline: none !important;
    }
    
    #lootDropModule .rp-info-btn:hover {
      opacity: 0.7; /* Simple hover effect without a box */
    }
    .loot-main-container {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 100%;
      max-width: 900px;
      margin: 0 auto;
      padding: 20px;
    }
    
    .loot-grid-layout {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 20px;
      width: 100%;
      margin-top: 20px;
    }
    
    .loot-panel {
      background: #f1f5f9; /* Soft gray panels */
      border: 1px solid #cbd5e1;
      border-radius: 16px;
      padding: 20px;
      box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
      display: flex;
      flex-direction: column;
    }
    
    /* Avatar Circle */
    .loot-avatar-circle {
      width: 80px; height: 80px; font-size: 35px;
      border: 3px solid #10b981;
      border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      background: #ecfdf5;
      margin: 0 auto 15px auto;
      animation: floatLoot 3s ease-in-out infinite;
    }
    
    @keyframes floatLoot {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-10px); }
    }
    
    /* Input Fields - Clean light theme */
    #lootDropModule .form-control {
      background: #ffffff !important;
      border: 1px solid #cbd5e1 !important;
      color: #1e293b !important;
    }
    
    #lootDropModule label {
      color: #475569 !important; /* Darker labels */
    }
    
    #loot_codeInput:focus {
      outline: none;
      border-color: #10b981 !important;
      box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
    }
    
    .loot-pulse {
      animation: lootCodePulse 0.4s ease-out;
    }
    
    @keyframes lootCodePulse {
      0% { transform: scale(1); }
      50% { transform: scale(1.02); border-color: #10b981; }
      100% { transform: scale(1); }
    }
    
    @media (max-width: 768px) {
      .loot-grid-layout {
        grid-template-columns: 1fr;
      }
    }
    
    
    /* Force text to show on Student/Teacher App buttons on Mobile */
@media (max-width: 780px) {
  .header-actions .btn.always-show-text:not(.desktop-smart-menu-button) {
    width: auto !important;
    height: auto !important;
    padding: 6px 10px !important;
    text-indent: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 5px;
    overflow: visible !important;
  }
  
  .header-actions .btn.always-show-text:not(.desktop-smart-menu-button) .btn-text {
    display: inline !important;
    font-size: 11px;
    font-weight: 700;
  }

  /* Keep desktop Menu hidden on phones */
  .header-actions .btn.desktop-smart-menu-button {
    display: none !important;
  }
}
    
    
    
    
    /* Modern Captain Chips - Two per line on Desktop */
    .captain-chip-container {
      display: grid;
      grid-template-columns: repeat(2, 1fr); /* Forces exactly 2 columns */
      gap: 8px;
      margin-top: 8px;
    }
    
    .captain-chip {
      display: flex;
      align-items: center;
      justify-content: center; /* Centers content inside the chip */
      gap: 5px;
      background: rgba(255, 255, 255, 0.6);
      border: 1px solid rgba(0, 0, 0, 0.05);
      padding: 5px 8px;
      border-radius: 20px;
      font-size: 10px; /* Slightly smaller to ensure fit */
      font-weight: 700;
      color: #1e293b;
      box-shadow: 0 1px 2px rgba(0,0,0,0.05);
      white-space: nowrap; /* Prevents text from breaking into two lines */
      overflow: hidden;
    }
    
    .captain-chip span {
      overflow: hidden;
      text-overflow: ellipsis; /* Adds ... if the name is too long for the half-width */
    }
    
    .captain-chip i {
      color: #fbbf24;
      font-size: 9px;
      flex-shrink: 0;
    }
    
    .captain-class-tag {
      opacity: 0.6;
      font-weight: 500;
      font-size: 9px;
      margin-left: 2px;
      flex-shrink: 0;
    }
    
    /* Make the title look like a proper label */
    .house-leaders-label {
      font-size: 10px;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      color: var(--house-color);
      opacity: 0.8;
      margin-bottom: 4px;
    }
    
    
    /* Mobile Optimized Captain Chips */
    @media (max-width: 1370px) {
      .captain-chip-container {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        margin-top: 10px;
        justify-content: flex-start;
      }
    
      .captain-chip {
        padding: 5px 12px; /* Slightly larger for touch */
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        font-size: 10.5px; /* Perfect balance for iPad/Phone */
      }
    
      /* Force the leaders section to take full width of the card */
      body.mobile .house-leaders {
        display: block !important;
        width: 100%;
        margin-top: 10px;
        border-top: 1px solid rgba(0,0,0,0.05);
        padding-top: 10px;
      }
    }
    
    /* ⚡ THE FIX: Hide scrollbar in modals but keep scrolling active */
    .house-expanded-content {
      -ms-overflow-style: none;  /* IE and Edge */
      scrollbar-width: none;  /* Firefox */
    }
    
    .house-expanded-content::-webkit-scrollbar {
      display: none; /* Chrome, Safari and Opera */
    }
    
    /* ⚡ 3D BADGE FLIP ANIMATION */
    .badge-flip-container {
      perspective: 1000px;
      cursor: pointer;
      background: transparent !important;
      border: none !important;
      box-shadow: none !important;
    }
    .badge-flip-inner {
      position: relative;
      width: 100%;
      height: 100%;
      text-align: center;
      transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Bouncy flip */
      transform-style: preserve-3d;
    }
    .badge-flip-container.flipped .badge-flip-inner {
      transform: rotateY(180deg);
    }
    .badge-front, .badge-back {
      position: absolute;
      width: 100%;
      height: 100%;
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
      border-radius: 50%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      box-sizing: border-box;
      border: 5px solid var(--house-color);
      box-shadow: 0 18px 36px rgba(0,0,0,0.15), 0 0 36px rgba(var(--house-color-rgb), 0.3);
    }
    .badge-front {
      background: rgba(255, 255, 255, 0.95);
    }
    .badge-back {
      background: var(--house-color); /* Fills with the house's color */
      color: white;
      transform: rotateY(180deg);
      padding: 20px;
    }
    
    
    
    /* --- 3D BADGE FLIP TEXT SIZING --- */
    
    /* 1. Default (Desktop) */
    .flip-back-label { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; opacity: 0.9; font-weight: 700; }
    .flip-back-icon { font-size: 42px; margin-bottom: 5px; }
    .flip-back-name { font-size: 20px; font-weight: 800; line-height: 1.2; }
    .flip-back-pts { font-size: 13px; font-weight: 600; margin-top: 5px; opacity: 0.9; }
    
    /* 2. iPads & Tablets (781px to 1370px) - Much Larger */
    @media (min-width: 781px) and (max-width: 1370px) {
      .flip-back-label { font-size: 16px; margin-bottom: 8px; }
      .flip-back-icon { font-size: 65px; margin-bottom: 10px; }
      .flip-back-name { font-size: 28px; }
      .flip-back-pts { font-size: 18px; margin-top: 8px; }
    }
    
    /* 3. Mobile Phones (780px and below) - Compact Fit */
    @media (max-width: 780px) {
      .flip-back-label { font-size: 11px; margin-bottom: 4px; }
      .flip-back-icon { font-size: 40px; margin-bottom: 4px; }
      .flip-back-name { font-size: 18px; }
      .flip-back-pts { font-size: 13px; margin-top: 4px; }
    }
    
    
    /* --- EXECUTIVE PULSE MODAL --- */
    .pulse-overlay {
      position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px);
      z-index: 99999; display: none; opacity: 0; transition: opacity 0.3s ease;
    }
    .pulse-overlay.show { display: block; opacity: 1; }
    
    .pulse-panel {
      position: fixed; top: 0; right: -400px; width: 100%; max-width: 380px; height: 100%;
      background: #ffffff; box-shadow: -10px 0 30px rgba(0,0,0,0.1); z-index: 100000;
      transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
      display: flex; flex-direction: column; overflow-y: auto;
    }
    .pulse-panel.open { right: 0; }
    
    .pulse-header {
      padding: 24px; background: #0f172a; color: white;
      display: flex; justify-content: space-between; align-items: center;
    }
    .pulse-header h2 { margin: 0; font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 8px;}
    .close-pulse { background: rgba(255,255,255,0.1); border: none; color: white; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
    
    .pulse-body { padding: 24px; display: flex; flex-direction: column; gap: 24px; }
    
    /* Dashboard Cards */
    .pulse-card { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 16px; padding: 20px; }
    .pulse-card-title { font-size: 11px; font-weight: 800; color: #64748b; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }
    
    /* Big Stat Row */
    .stat-row { display: flex; gap: 12px; }
    .stat-box { flex: 1; background: white; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.02);}
    .stat-value { font-size: 24px; font-weight: 900; color: #1e40af; }
    .stat-label { font-size: 10px; font-weight: 700; color: #94a3b8; text-transform: uppercase; margin-top: 4px; }
    
    /* CSS Bar Charts */
    .bar-chart-row { margin-bottom: 12px; }
    .bar-chart-row:last-child { margin-bottom: 0; }
    .bar-header { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: #334155; margin-bottom: 6px; }
    .bar-count { color: #10b981; }
    .bar-track { width: 100%; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
    .bar-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #60a5fa); border-radius: 4px; width: 0%; transition: width 1s ease-out; }
    
    /* Skeleton Loader */
    .pulse-skeleton { display: none; flex-direction: column; gap: 20px; }
    .skel-box { height: 80px; background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite; border-radius: 12px; }
    
    
    
    .poster-btn-container {
      display: flex !important;
      justify-content: center !important; /* This centers the button */
      width: 100% !important;
      margin: 20px 0 !important;
      box-sizing: border-box !important;
    }
    
    .poster-btn-container .btn-primary {
      width: auto !important; /* Prevents the stretch seen in your screenshot */
      min-width: 250px !important;
      padding: 14px 30px !important;
      border-radius: 50px !important; /* Makes it a pill shape */
      justify-content: center !important;
    }
    
    
    /* 1. Default State: Hide the mobile "All" text on desktop/iPad */
    .text-mobile {
      display: none !important;
    }
    
    /* 2. Mobile Logic: Under 780px */
    @media (max-width: 780px) {
      /* Hide the long text */
      .text-desktop {
        display: none !important;
      }
      
      /* Show the short "All" text */
      .text-mobile {
        display: inline !important;
        font-weight: 800;
      }
    
      /* Shrink the button width to fit perfectly on small phones */
      .students-header-actions .btn-premium-orange {
        min-width: 60px !important;
        padding: 6px 10px !important;
      }
    }
    
    /* 3. iPad/Desktop Logic: Over 780px */
    @media (min-width: 781px) {
      .text-desktop {
        display: inline !important;
      }
    }
    
    
    /* AppDialog Styles */
.app-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.app-dialog-box {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.app-dialog-box h3 {
  margin: 0 0 8px 0;
  color: #1e293b;
  font-size: 20px;
}

.app-dialog-box p {
  margin: 0 0 24px 0;
  color: #64748b;
  font-size: 14px;
  line-height: 1.5;
}

.app-dialog-box .btn {
  min-height: 40px;
  font-size: 14px;
}



/* --- MODERN TABLE TYPOGRAPHY & ID BADGE --- */
#students-section table {
  font-variant-numeric: tabular-nums; /* Ensures numbers align perfectly in columns */
}

#students-section td {
  font-size: 14px;
  color: #334155;
  font-weight: 500;
  vertical-align: middle;
}

/* Modern ID Badge Style */
.student-id-badge {
  display: inline-block;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #1e40af;
  background: #eff6ff;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #dbeafe;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.2s ease;
}

tr:hover .student-id-badge {
  background: #1e40af;
  color: #ffffff;
  border-color: #1e40af;
  transform: scale(1.05);
}

.student-name-cell {
  font-weight: 700 !important;
  color: #0f172a !important;
  font-size: 15px !important;
}

/* Refined Mini badge for desktop table */
.student-badge-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: transform 0.2s ease;
  white-space: nowrap;
}

.student-badge-mini:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Adjust table column widths */
@media (min-width: 769px) {
  #students-section .table-container table th:nth-child(7) {
    width: 15%; /* Student Badges column */
  }
  #students-section .table-container table th:nth-child(8) {
    width: 12%; /* Actions column - slightly smaller */
  }
}

/* ==========================================
   QUICK ALL HOUSES AWARD BUTTON
   Dashboard + Student Management only
   ========================================== */

#quickAllHousesAwardBtn {
  position: fixed;

  right: 24px;
  bottom: 24px;

  width: 54px;
  height: 54px;

  display: none;

  align-items: center;
  justify-content: center;

  padding: 0;

  border: none;
  border-radius: 50%;

  background: #2563eb;

  color: #ffffff;

  font-size: 19px;

  cursor: pointer;

  box-shadow:
    0 10px 24px
    rgba(37, 99, 235, 0.28);

  z-index: 1200;

  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}


body.active-section-dashboard
#quickAllHousesAwardBtn,
body.active-section-students
#quickAllHousesAwardBtn {
  display: flex;
}


#quickAllHousesAwardBtn:hover {
  background: #1d4ed8;

  transform: translateY(-2px) scale(1.04);

  box-shadow:
    0 14px 30px
    rgba(37, 99, 235, 0.36);
}


#quickAllHousesAwardBtn:active {
  background: #1d4ed8;

  transform: scale(0.96);
}


/* Hide floating + while House Details is open */
body:has(#expandedHouseView.show)
#quickAllHousesAwardBtn {
  display: none !important;
}


.quick-award-plus-only {
  display: flex;

  align-items: center;
  justify-content: center;

  width: 100%;
  height: 100%;

  color: #ffffff;

  font-size: 30px;
  font-weight: 400;

  line-height: 1;

  transform: translateY(-1px);

  pointer-events: none;
}


/* iPad + mobile */
@media (max-width: 1370px) {

  #quickAllHousesAwardBtn {
    right: 16px;

    bottom:
      calc(
        92px +
        env(safe-area-inset-bottom)
      );

    width: 50px;
    height: 50px;

    font-size: 17px;
  }

}


/* =========================================================
       🌐 UNIVERSAL LAYOUT: HEADER & ANNOUNCEMENT BAR VISIBILITY
       ========================================================= */
       
    /* 1. Hide Header Everywhere EXCEPT Dashboard */
    body:not(.active-section-dashboard) .header {
      display: none !important;
    }

    /* 2. Hide Announcement Bar in Student Management */
    body.active-section-students .announcement-bar {
      display: none !important;
    }

    /* 3. Default Announcement Bar Behavior */
    .announcement-bar {
      display: flex;
      transition: top 0.3s ease;
      z-index: 998;
    }

    /* 🖥️ DESKTOP LAYOUT ( > 1370px ) */
    @media (min-width: 1371px) {
      .header { height: 60px !important; }
      
      /* --- State A: Dashboard Mode --- */
      body.active-section-dashboard .announcement-bar { top: 60px !important; }
      body.active-section-dashboard .app-container { padding-top: 104px !important; }
      body.active-section-dashboard .sidebar { top: 104px !important; height: calc(100vh - 104px) !important; transition: top 0.3s, height 0.3s; }

      /* --- State B: Students Mode (Immersive Full Screen) --- */
      body.active-section-students .app-container { padding-top: 0 !important; min-height: 100vh !important; }
      body.active-section-students .sidebar { top: 0 !important; height: 100vh !important; }

      /* --- State C: Other Pages (Houses, etc.) --- */
      body:not(.active-section-dashboard):not(.active-section-students) .announcement-bar { top: 0 !important; }
      body:not(.active-section-dashboard):not(.active-section-students) .app-container { padding-top: 60px !important; }
      body:not(.active-section-dashboard):not(.active-section-students) .sidebar { top: 60px !important; height: calc(100vh - 60px) !important; }
    }

    /* 📱 MOBILE & IPAD LAYOUT ( <= 1370px ) */
    @media (max-width: 1370px) {
      .header { height: 48px !important; padding: 6px 12px !important; }
      
      /* --- State A: Dashboard Mode --- */
      body.active-section-dashboard .announcement-bar { top: 48px !important; }
      body.active-section-dashboard .app-container { padding-top: 92px !important; }
      
      /* --- State B: Students Mode (Immersive Full Screen) --- */
      body.active-section-students .app-container { padding-top: 0 !important; }
      body.active-section-students #students-section { top: 0 !important; height: 100vh !important; }

      /* --- State C: Other Pages (Houses, etc.) --- */
      body:not(.active-section-dashboard):not(.active-section-students) .announcement-bar { top: 0 !important; }
      body:not(.active-section-dashboard):not(.active-section-students) .app-container { padding-top: 44px !important; }
      
      /* Reset main content margins to prevent empty gaps */
      .main-content { margin-top: 0 !important; }
    }



    
    

/* --- PREMIUM SYSTEM CONTROL STYLES --- */
.system-card-btn {
  width: 100%;
  background: #ffffff !important;
  border: 2px solid #e2e8f0 !important;
  border-radius: 16px !important;
  padding: 20px !important;
  display: flex !important;
  align-items: center !important;
  gap: 20px !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  cursor: pointer !important;
  text-align: left !important;
  margin-bottom: 12px;
}

.system-card-btn:hover {
  border-color: var(--accent-color, #3b82f6) !important;
  background: var(--bg-tint, #f8fafc) !important;
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

.system-icon-wrapper {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  background: var(--bg-tint);
  color: var(--accent-color);
}

.system-card-content {
  flex: 1;
}

.system-card-title {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 4px;
}

.system-card-desc {
  display: block;
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
  line-height: 1.4;
}

/* Specific Card Themes */
.sys-blue { --accent-color: #3b82f6; --bg-tint: #eff6ff; }
.sys-orange { --accent-color: #f59e0b; --bg-tint: #fffbeb; }
.sys-red { --accent-color: #ef4444; --bg-tint: #fef2f2; }
.sys-green { --accent-color: #10b981; --bg-tint: #ecfdf5; }




/* =========================================================
   🛡️ MASTER Z-INDEX STACKING ORDER (The "No-Guess" Fix)
   ========================================================= */

/* LAYER 1: Main Page Modals (House Manager, Start Here) */
#houseManagerModal, 
#importPanel, 
#systemControlModal {
    z-index: 15000 !important;
}

/* LAYER 2: Sub-Modals (Badge Editors, Awarding Points, Quiz) 
   Must be higher to open ON TOP of Layer 1 */
#milestoneEditorModal, 
#awardHousePointsModal, 
#quizResultsModal, 
#reasonManagerModal,
#resetConfirmationModal {
    z-index: 25000 !important; 
}

/* LAYER 3: Essential Utilities (Emoji Pickers, Search) */
#emojiPickerContainer, 
#studentSearchModal {
    z-index: 40000 !important;
}

/* LAYER 4: Global Notifications (Toasts) */
#toast-container {
    z-index: 50000 !important;
}

/* Specific styling for the Milestone Modal to ensure it blacks out the one behind it */
#milestoneEditorModal {
    background: rgba(0, 0, 0, 0.85) !important;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
#milestoneEditorModal.show {
    display: flex !important;
    opacity: 1 !important;
}





/* ==========================================
   🎬 CINEMATIC PROJECTOR STYLES (MATCHED)
   ========================================== */

#fullscreenLeaderboard {
    background: #0f172a !important; /* Deep dark slate */
    color: white;
}

/* Achievement Milestone Cards */
.achievements-house-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 360px));
    justify-content: center;
    gap: 20px;
    padding: 20px;
    width: 100%;
    margin: 20px auto 0;
    box-sizing: border-box;
}

.achievements-house-card {
    border-radius: 20px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255,255,255,0.1);
}

.achievements-house-card .house-pts-pill {
    background: rgba(0,0,0,0.3);
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 22px;
    font-weight: 800;
    margin: 15px 0;
}

/* Next Milestone Teaser Box */
.milestone-next-teaser {
    background: rgba(0,0,0,0.4);
    border-radius: 12px;
    padding: 12px;
    width: 100%;
    margin-top: auto;
    border-top: 2px solid var(--milestone-color);
}

/* Bottom Milestone Index (Timeline) */
.achievement-timeline-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 20px 40px;
    background: rgba(0,0,0,0.2);
    width: 100%;
}

.timeline-milestone-bar {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
}

/* Marquee Bar */
.leaderboard-announcement-bar {
    background: #facc15 !important;
    color: #1e293b !important;
    height: 60px;
    font-weight: 900;
    text-transform: uppercase;

    border-top: 1px solid rgba(15, 23, 42, 0.08);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.leaderboard-announcement-bar .announcement-content {
    color: #1e293b !important;
}

.leaderboard-announcement-bar .announcement-icon {
    color: #d97706 !important;
}

.leaderboard-announcement-bar .announcement-title {
    color: #92400e !important;
}

.leaderboard-announcement-bar .announcement-points {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53) !important;
    color: #ffffff !important;
}

/* Dark mode override */
body.house-display-dark .leaderboard-announcement-bar {
    background: #1c1917 !important;
    color: #f8fafc !important;

    border-top: 1px solid rgba(245, 158, 11, 0.22);
    border-bottom: 1px solid rgba(245, 158, 11, 0.22);
}

body.house-display-dark .leaderboard-announcement-bar .announcement-content {
    color: #f8fafc !important;
}

body.house-display-dark .leaderboard-announcement-bar .announcement-icon {
    color: #f59e0b !important;
}

body.house-display-dark .leaderboard-announcement-bar .announcement-title {
    color: #fbbf24 !important;
}

body.house-display-dark .leaderboard-announcement-bar .announcement-points {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53) !important;
    color: #ffffff !important;
}



/* ==========================================
   📱 MOBILE/IPAD BOTTOM PADDING FIX
   ========================================== */
   @media (max-width: 1370px) {
  /* Add bottom padding to main content areas to clear the nav bar */
  #dashboard-section,
  #students-section,
  #houses-section,
  #challenges-section {
    padding-bottom: 90px !important;
    min-height: 100vh !important;
    box-sizing: border-box !important;
  }
  
  /* Ensure the main content area itself has bottom padding */
  .main-content {
    padding-bottom: 20px !important;
  }
  
  /* Fix for students section which is positioned fixed */
  #students-section {
    padding-bottom: 90px !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: auto !important;
  }
  
  /* Add padding to the students list specifically */
  #studentsList {
    padding-bottom: 100px !important;
  }
  
  /* Fix for any modals that might be affected */
  .house-expanded-content,
  .modal-content {
    padding-bottom: 90px !important;
  }
  
  /* Ensure the last card in any list isn't cut off */
  .card:last-child,
  .house-grid:last-child,
  .student-card:last-child {
    margin-bottom: 0 !important;
  }
  
  /* Fix for fullscreen leaderboard on mobile */
  #fullscreenLeaderboard {
    padding-bottom: 0 !important;
  }
  
  #fullscreenLeaderboardContent {
    padding-bottom: 20px !important;
  }
}

/* Extra small devices (phones) */
@media (max-width: 780px) {
  #dashboard-section,
  #students-section,
  #houses-section,
  #challenges-section {
    padding-bottom: 100px !important;
  }
  
  #studentsList {
    padding-bottom: 120px !important;
  }
}









/* ==========================================
   DYNAMIC GRID LAYOUTS FOR STUDENT MANAGEMENT
   ========================================== */

/* Mobile (≤780px) - 3 columns */
@media (max-width: 780px) {
  .house-group-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
  }
}

/* Tablet (781px-1370px) - 5 columns */
@media (min-width: 781px) and (max-width: 1370px) {
  .house-group-grid {
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 10px !important;
  }
}

/* Desktop - Updated to 5 columns */
@media (min-width: 1371px) {
  .house-group-grid {
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 12px !important;
  }
}

/* ==========================================
   STUDENT MANAGEMENT - DARK MODE
   ========================================== */

body.house-display-dark #students-section {
  background: #0f172a !important;
  color: #e2e8f0 !important;
}

/* Main containers and toolbar */
body.house-display-dark #students-section .card,
body.house-display-dark #students-section .card-header,
body.house-display-dark #students-section .table-container,
body.house-display-dark #students-section .table-responsive {
  background: #111c2e !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

/* House sections */
body.house-display-dark #studentsList .house-group-section,
body.house-display-dark #studentsList .house-group-grid {
  background: #111827 !important;
  border-color: #334155 !important;
}

/* House headers */
body.house-display-dark #studentsList .house-group-header,
body.house-display-dark #studentsList .house-group-header.active {
  background: #1e293b !important;
  border-bottom-color: var(--group-color, #475569) !important;
}

body.house-display-dark #studentsList .house-group-title {
  color: #f8fafc !important;
}

body.house-display-dark #studentsList .house-group-count {
  background: #334155 !important;
  color: #e2e8f0 !important;
  border-color: #475569 !important;
}

body.house-display-dark #studentsList .house-group-pts {
  background: #263449 !important;
  color: #f8fafc !important;
  border: 1px solid #475569 !important;
}

body.house-display-dark #studentsList .house-chevron {
  color: #cbd5e1 !important;
}

/* Student cards */
body.house-display-dark #studentsList .student-card,
body.house-display-dark #studentsList .student-card.collapsed,
body.house-display-dark #studentsList .student-card.expanded {
  background: #1e293b !important;
  background-image: none !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

body.house-display-dark #studentsList .student-card-header {
  background: transparent !important;
}

body.house-display-dark #studentsList .student-card-name {
  color: #f8fafc !important;
}

body.house-display-dark #studentsList .student-card-class,
body.house-display-dark #studentsList .student-card-house,
body.house-display-dark #studentsList .xp-stats {
  color: #cbd5e1 !important;
}

body.house-display-dark #studentsList .expansion-indicator {
  color: #94a3b8 !important;
}

/* Student card hover */
body.house-display-dark #studentsList .student-card:hover {
  background: #263449 !important;
  border-color: #64748b !important;
}

/* Keep selected cards distinct */
body.house-display-dark #studentsList .student-card.selected {
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 2px rgba(96,165,250,.18) !important;
}

/* Preserve the colours of mascot badges */
body.house-display-dark #studentsList .hero-shield {
  color: inherit;
}

/* Filters, dropdowns and search */
body.house-display-dark #students-section select,
body.house-display-dark #students-section input[type="text"],
body.house-display-dark #students-section input[type="search"] {
  background: #1e293b !important;
  border-color: #475569 !important;
  color: #f8fafc !important;
}

body.house-display-dark #students-section input::placeholder {
  color: #94a3b8 !important;
}

body.house-display-dark #students-section select option {
  background: #1e293b;
  color: #f8fafc;
}

/* Field labels */
body.house-display-dark #students-section label {
  color: #cbd5e1;
}

/* Neutral unassigned area */
body.house-display-dark #studentsList
.house-group-section[data-house="Unassigned"],
body.house-display-dark #studentsList
.house-group-section[data-house="Unassigned"] .house-group-grid,
body.house-display-dark #studentsList
.house-group-section[data-house="Unassigned"] .house-group-header {
  background: #172033 !important;
  border-color: #475569 !important;
}

body.house-display-dark #studentsList
.house-group-section[data-house="Unassigned"] .student-card {
  background: #1e293b !important;
  border-color: #475569 !important;
}

body.house-display-dark #studentsList
.house-group-section[data-house="Unassigned"] .student-card-name,
body.house-display-dark #studentsList
.house-group-section[data-house="Unassigned"] .house-group-title {
  color: #e2e8f0 !important;
}

/* ==========================================
   STUDENT MANAGEMENT - DARK MODE CORRECTIONS
   ========================================== */

/* Student names: override desktop's forced dark text */
body.house-display-dark
#students-section #studentsList
.student-card.collapsed .student-card-name,
body.house-display-dark
#students-section #studentsList
.student-card.expanded .student-card-name,
body.house-display-dark
#students-section #studentsList
.house-group-section[data-house="Unassigned"]
.student-card.collapsed .student-card-name {
  color: #f8fafc !important;
}

/* Keep names readable while hovering or selecting */
body.house-display-dark
#students-section #studentsList
.student-card:hover .student-card-name,
body.house-display-dark
#students-section #studentsList
.student-card.selected .student-card-name {
  color: #ffffff !important;
}

/* Student management toolbar */
body.house-display-dark
#students-section #studentsList
.house-group-section {
  color: #e2e8f0 !important;
}

/* Toolbar and surrounding panel */
body.house-display-dark
#students-section
#studentsList {
  background: #0f172a !important;
}

/* Collapsed card labels and arrows */
body.house-display-dark
#students-section #studentsList
.student-card .expansion-indicator,
body.house-display-dark
#students-section #studentsList
.student-card .student-card-class,
body.house-display-dark
#students-section #studentsList
.student-card .student-card-house {
  color: #cbd5e1 !important;
}

/* House header text and totals */
body.house-display-dark
#students-section #studentsList
.house-group-title {
  color: #f8fafc !important;
}

body.house-display-dark
#students-section #studentsList
.house-group-count,
body.house-display-dark
#students-section #studentsList
.house-group-pts {
  color: #e2e8f0 !important;
}

/* Keep student cards dark on hover */
body.house-display-dark
#students-section #studentsList
.student-card.collapsed:hover,
body.house-display-dark
#students-section #studentsList
.student-card.expanded:hover {
  background: #263449 !important;
  background-image: none !important;
}

/* ==========================================
   STUDENT MANAGEMENT - DARK HEADER & TOOLBAR
   ========================================== */

/* Class header */
body.house-display-dark
#students-section .students-page-header {
  background: #111827 !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

body.house-display-dark
#students-section .students-header-row1,
body.house-display-dark
#students-section .students-header-title {
  background: transparent !important;
  color: #f8fafc !important;
}

body.house-display-dark
#students-section #headerClassName {
  color: #93c5fd !important;
}

/* Main student-management toolbar */
body.house-display-dark
#students-section > .card > .card-header {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

body.house-display-dark
#students-section .top-row-container,
body.house-display-dark
#students-section #classInfoContainer,
body.house-display-dark
#students-section .search-select-container {
  background: transparent !important;
  color: #e2e8f0 !important;
}

/* Teacher and class information badge */
body.house-display-dark
#students-section #classInfoBadge {
  background: #263449 !important;
  border-color: #475569 !important;
  color: #f8fafc !important;
}

/* Class passcode badge */
body.house-display-dark
#students-section #desktopHeaderClassPasscode {
  background: #1e3a5f !important;
  border-color: #3b82f6 !important;
  color: #bfdbfe !important;
}

/* Preserve the existing action button colours */
body.house-display-dark
#students-section #globalSelectToggle,
body.house-display-dark
#students-section #studentAccessMenuBtn,
body.house-display-dark
#students-section .students-header-actions .btn {
  filter: none;
}

/* Keep the toolbar dark during interactions */
body.house-display-dark
#students-section > .card > .card-header:hover {
  background: #1e293b !important;
}

/* House group swimlanes styling */
.house-group-section {
  margin-bottom: 20px;
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  border: 1px solid #e2e8f0;
}

.house-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-bottom: 2px solid var(--group-color, #64748b);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.house-group-header:active {
  transform: scale(0.98);
}

.house-group-header.active {
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
  border-bottom-width: 4px;
}

.house-group-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 800;
  color: #1e293b;
}

.house-group-checkbox {
  width: 22px !important;
  height: 22px !important;
  cursor: pointer;
  accent-color: #10b981;
  border-radius: 6px;
  margin: 0;
}

.house-group-count {
  background: #ffffff;
  padding: 4px 12px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.house-group-pts {
  font-weight: 800;
  font-size: 14px;
  color: var(--group-color);
  background: rgba(255,255,255,0.9);
  padding: 4px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.house-chevron {
  font-size: 16px;
  color: #64748b;
  transition: transform 0.3s ease;
}

.house-group-header.active .house-chevron {
  transform: rotate(180deg);
}

.house-group-grid {
  display: none;
  padding: 16px;
  background: #ffffff;
}

.house-group-grid.show {
  display: grid;
}


/* ==========================================
   UNASSIGNED
   Neutral holding area, not a real House
   ========================================== */

.house-group-section[data-house="Unassigned"] {
  background: #f8fafc !important;
  border-color: #dbe2ea !important;
  box-shadow: 0 2px 8px rgba(15,23,42,0.035) !important;
}

.house-group-section[data-house="Unassigned"] .house-group-header {
  background: #f1f5f9 !important;
  border-color: #dbe2ea !important;
  border-bottom-color: #cbd5e1 !important;
  border-left-color: #94a3b8 !important;
  box-shadow: none !important;
}

.house-group-section[data-house="Unassigned"] .house-group-title {
  color: #64748b !important;
}

.house-group-section[data-house="Unassigned"] .house-group-count {
  background: #e2e8f0 !important;
  border: 1px solid #cbd5e1 !important;
  color: #64748b !important;
}

.house-group-section[data-house="Unassigned"] .house-group-pts {
  color: #94a3b8 !important;
  background: #f8fafc !important;
}

.house-group-section[data-house="Unassigned"] .house-chevron {
  color: #94a3b8 !important;
}

.house-group-section[data-house="Unassigned"] .house-group-grid {
  background: #f8fafc !important;
}

/* STUDENT CARDS */
.house-group-section[data-house="Unassigned"] .student-card,
.house-group-section[data-house="Unassigned"] .student-card.collapsed,
.house-group-section[data-house="Unassigned"] .student-card.expanded {
  background: #f8fafc !important;
  background-image: none !important;
  border: 1px solid #dbe2ea !important;
  box-shadow: 0 2px 6px rgba(15,23,42,0.04) !important;
}

/* Remove stronger colour accents from the card chrome */
.house-group-section[data-house="Unassigned"] .student-card-header {
  background: transparent !important;
}

.house-group-section[data-house="Unassigned"] .student-card-name {
  color: #475569 !important;
}

.house-group-section[data-house="Unassigned"] .student-card-house,
.house-group-section[data-house="Unassigned"] .student-card-class,
.house-group-section[data-house="Unassigned"] .xp-stats,
.house-group-section[data-house="Unassigned"] .hero-id-tag,
.house-group-section[data-house="Unassigned"] .student-id-badge {
  color: #94a3b8 !important;
}

.house-group-section[data-house="Unassigned"] .hero-shield {
  background: #eef2f6 !important;
  border-color: #94a3b8 !important;
  box-shadow: 0 4px 10px rgba(15,23,42,0.06) !important;
}

.house-group-section[data-house="Unassigned"] .collapsed-points-pill {
  background: #f1f5f9 !important;
  color: #64748b !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: none !important;
}

.house-group-section[data-house="Unassigned"] .expansion-indicator,
.house-group-section[data-house="Unassigned"] .student-card i.fa-chevron-down,
.house-group-section[data-house="Unassigned"] .student-card i.fa-chevron-up {
  color: #94a3b8 !important;
}

.house-group-section[data-house="Unassigned"] .xp-bar-container {
  background: #e2e8f0 !important;
  border-color: #cbd5e1 !important;
}

.house-group-section[data-house="Unassigned"] .xp-bar-fill {
  background: linear-gradient(90deg, #cbd5e1, #94a3b8) !important;
}

/* Dojo-style toggle button */
.dojo-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  height: 36px;
  padding: 0 16px;
  border-radius: 30px;
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 2px solid transparent;
  cursor: pointer;
}

.dojo-toggle.inactive {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.dojo-toggle.active {
  background: #10b981;
  color: white;
  border-color: #059669;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transform: scale(1.05);
}

.dojo-toggle i {
  margin-right: 6px;
  font-size: 14px;
}

/* Highlight animation for searched students */
@keyframes searchHighlight {
  0% { transform: scale(1); box-shadow: 0 0 0 0 #3b82f6; }
  50% { transform: scale(1.02); box-shadow: 0 0 20px #3b82f6; background-color: #eff6ff; }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}

.student-card.highlighted {
  animation: searchHighlight 1.5s ease-out;
  border: 2px solid #3b82f6 !important;
  z-index: 5;
}

/* Copy ID feedback */
.copy-pulse {
  animation: copyPulse 0.3s ease-out;
}

@keyframes copyPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); background-color: #10b981 !important; color: white !important; }
  100% { transform: scale(1); }
}





/* Student details: preserve existing tablet and desktop layout */
.responsive-details-row {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      width: 100%;
    }
    
    .rd-dropdown {
      flex: 1 1 calc(50% - 6px);
      min-width: 0;
    }
    
    .rd-points {
      flex: 1 1 100%;
      min-width: 0;
      margin-top: 2px;
      margin-bottom: 4px;
    }

/* Phone: House and Role together, Points and Correct below */
@media (max-width: 780px) {
  #studentsList .student-card.expanded .responsive-details-row {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px !important;
    align-items: stretch;
    width: 100%;
  }

  #studentsList .student-card.expanded .responsive-details-row > .rd-dropdown:first-child {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  #studentsList .student-card.expanded .responsive-details-row > .rd-dropdown:last-child {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  #studentsList .student-card.expanded .responsive-details-row > .rd-points {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    margin: 0;
  }

  #studentsList .student-card.expanded .rd-points input {
    min-width: 0;
    width: 100%;
  }

  #studentsList .student-card.expanded .rd-points button {
    min-width: 0 !important;
  }
}

    /* iPad/Tablet Only: Inline all 3 elements side-by-side */
    @media (min-width: 781px) and (max-width: 1370px) {
      .responsive-details-row {
        flex-wrap: nowrap;
        align-items: center;
      }
      
      .rd-dropdown {
        flex: 1; /* Both dropdowns take equal remaining space on the sides */
      }
      
      .rd-points {
        flex: 0 0 150px;
        margin: 0 6px;
      }

      #students-section .student-card.expanded .rd-points {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        align-items: stretch !important;
      }

      #students-section .student-card.expanded .rd-points input {
        width: 100% !important;
        height: 52px !important;
      }

      #students-section .student-card.expanded .rd-points button {
        width: 100% !important;
        height: 38px !important;
        min-width: 0 !important;
        padding: 0 10px !important;
      }
    }



    /* Hide the top-corner points pill when the student card is expanded */
    /* My Classboard: attendance actions */
    .classboard-attendance-actions {
      display:flex;
      align-items:center;
      gap:10px;
      min-width:0;
    }

    .classboard-attendance-toggle {
      display:none;
    }

    .classboard-take-attendance-btn[hidden] {
      display:none !important;
    }

    .classboard-take-attendance-btn {
      display:inline-flex;
      align-items:center;
      justify-content:center;
      gap:7px;
      min-height:36px;
      padding:7px 12px;
      border:1px solid #bfdbfe;
      border-radius:9px;
      background:#eff6ff;
      color:#1d4ed8;
      font-family:inherit;
      font-size:11px;
      font-weight:750;
      white-space:nowrap;
      cursor:pointer;
    }

    .classboard-take-attendance-btn:hover {
      background:#dbeafe;
      border-color:#93c5fd;
    }

    @media (min-width:1371px) {
      #students-section .filters > .classboard-attendance-actions {
        margin-left:auto;
        flex:0 0 auto;
        align-self:flex-end;
      }
    }

    @media (max-width:1370px) {
      .classboard-attendance-actions {
        margin-left:auto;
      }

      .classboard-take-attendance-btn {
        min-height:38px;
      }
    }

    @media (max-width:600px) {
      .classboard-take-attendance-btn span {
        display:none;
      }

      .classboard-take-attendance-btn {
        width:38px;
        padding:0;
        font-size:14px;
      }
    }

    .classboard-today-attendance[hidden] {
      display:none !important;
    }

    .classboard-attendance-actions .classboard-today-attendance:not([hidden]) {
      display:inline-flex;
      margin-left:0;
      flex:0 0 auto;
    }

    .classboard-today-attendance {
      display:none;
      align-items:center;
      padding:5px 11px;
      border-radius:999px;
      background:#ecfdf5;
      border:1px solid #bbf7d0;
      color:#047857;
      font-size:11px;
      font-weight:800;
      white-space:nowrap;
      margin-left:8px;
    }

    @media (min-width:1371px) {
      .classboard-attendance-toggle {
        display:inline-flex;
        align-items:center;
        gap:7px;
        padding:7px 11px;
        border:1px solid #cbd5e1;
        border-radius:9px;
        background:#ffffff;
        color:#334155;
        font-size:11px;
        font-weight:750;
        white-space:nowrap;
        cursor:pointer;
      }

      .classboard-attendance-toggle input {
        appearance:none;
        -webkit-appearance:none;
        width:36px;
        height:20px;
        margin:0;
        border:1px solid #cbd5e1;
        border-radius:999px;
        background:#cbd5e1;
        position:relative;
        flex-shrink:0;
        cursor:pointer;
        transition:background .2s ease, border-color .2s ease;
      }

      .classboard-attendance-toggle input::before {
        content:"";
        position:absolute;
        top:2px;
        left:2px;
        width:14px;
        height:14px;
        border-radius:50%;
        background:#ffffff;
        box-shadow:0 1px 3px rgba(0,0,0,.15);
        transition:transform .2s ease;
      }

      .classboard-attendance-toggle input:checked {
        background:#2563eb;
        border-color:#2563eb;
      }

      .classboard-attendance-toggle input:checked::before {
        transform:translateX(16px);
      }

      .classboard-attendance-toggle input:focus-visible {
        outline:2px solid #2563eb;
        outline-offset:3px;
      }

      .classboard-today-attendance:not([hidden]) {
        display:inline-flex;
      }
    }

    .student-card .classboard-absent-icon {
      position:absolute;
      top:8px;
      left:8px;
      z-index:5;
      display:inline-flex;
      width:22px;
      height:22px;
      align-items:center;
      justify-content:center;
      gap:5px;
      border-radius:50%;
      background:#fef2f2;
      border:1px solid #fecaca;
      color:#dc2626;
      font-size:11px;
      pointer-events:auto;
    }

    @media (min-width:1371px) {
      .student-card .classboard-absent-icon {
        width:auto;
        height:22px;
        padding:0 7px;
        border-radius:6px;
        font-size:10px;
        font-weight:700;
      }

      .student-card .classboard-absent-icon::after {
        content:"Absent";
        font-size:10px;
      }
    }

    .student-card .classboard-absent-icon[hidden] {
      display:none !important;
    }

    .student-card.expanded .collapsed-points-pill {
      display: none !important;
    }


    /* Search Students: full-screen modal with working mobile scrolling */
    @media (max-width: 1370px) {
      #globalStudentSearchModal {
        align-items: flex-start !important;
        height: 100dvh !important;
        overflow: hidden !important;
      }

      #searchModalInner {
        width: 100vw !important;
        height: 100dvh !important;
        max-width: none !important;
        max-height: 100dvh !important;
        min-height: 0 !important;
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
      }

      #globalSearchResults {
        flex: 1 1 0% !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y;
      }
    }




/* Force Class Rankings & Insight Modals to Full Screen on iPad & Mobile */
@media (max-width: 1370px) {
      #classLeaderboardModal, 
      #classInsightModal {
        align-items: flex-start !important;
        padding: 0 !important;
      }
      
      #classLeaderboardModal .house-expanded-content,
      #classInsightModal .house-expanded-content {
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        position: relative !important;
      }
      
      /* 🔥 FIX: Header styling for Class Leaderboard */
      #classLeaderboardModal .house-expanded-content > div:first-child {
        padding: 15px 50px 15px 20px !important;
        margin: 0 !important;
        background: #1e40af !important;
        flex-shrink: 0 !important;
      }
      
      /* 🔥 FIX: Make X button visible in Class Leaderboard */
      #classLeaderboardModal .house-expanded-close {
  position: absolute !important;
  top: 12px !important;
  right: 12px !important;
  width: 32px !important;
  height: 32px !important;
  background: #ef4444 !important;
  color: white !important;
  border: none !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  z-index: 100 !important;
}


/* Desktop Official Standings:
   keep House Boards and close button neatly separated */

@media (min-width: 1371px) {

  #classLeaderboardModal .house-expanded-close {
    position: static !important;

    top: auto !important;
    right: auto !important;

    width: 36px !important;
    height: 36px !important;

    flex-shrink: 0 !important;
  }

}
      
      /* 🔥 FIX: Content area scrollable */
      #classLeaderboardModal #classLeaderboardGrid {
        flex: 1 !important;
        overflow-y: auto !important;
        padding: 16px !important;
        margin: 0 !important;
      }
      
      /* 🔥 FIX: Class Insight Modal header */
      #classInsightModal .house-expanded-content > div:first-child {
        padding: 15px 50px 15px 20px !important;
        margin: 0 !important;
        background: #1e40af !important;
        flex-shrink: 0 !important;
        position: relative !important;
      }
      
      /* 🔥 FIX: Make X button visible in Class Insight */
      #classInsightModal .house-expanded-close {
        position: absolute !important;
        top: 12px !important;
        right: 12px !important;
        width: 32px !important;
        height: 32px !important;
        background: #ef4444 !important;
        color: white !important;
        border: none !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        z-index: 100 !important;
      }
      
      /* 🔥 FIX: Class Insight content area */
      #classInsightModal #classInsightContent {
        flex: 1 !important;
        overflow-y: auto !important;
        padding: 16px !important;
        margin: 0 !important;
      }
    }


/* Force Class Rankings & Insight Modals to Full Screen on ALL Devices */
#classLeaderboardModal, 
    #classInsightModal {
      align-items: flex-start !important;
      padding: 0 !important;
    }
    
    #classLeaderboardModal .house-expanded-content,
    #classInsightModal .house-expanded-content {
      width: 100vw !important;
      height: 100vh !important;
      max-width: none !important;
      max-height: none !important;
      border-radius: 0 !important;
      margin: 0 !important;
      padding: 0 !important;
      position: relative !important;
    }
    
    /* 🔥 FIX: Remove extra padding for Class Insight */
    #classInsightModal .house-expanded-content {
      padding-top: 0 !important;
    }




    @media (max-width: 1370px) {
      .desktop-only {
        display: none !important;
      }
    }





    /* 📱 SMARTPHONE SPECIFIC: Fix House Config Squashing */
@media (max-width: 780px) {
  #houseSettingsList > div {
    /* Switch from 4-column grid to a single column stack */
    grid-template-columns: 1fr !important; 
    gap: 15px !important;
    padding: 20px !important;
    position: relative;
  }

  /* Position the Trash can in the top right corner so it doesn't take up a whole row */
  #houseSettingsList .btn-danger, 
  #houseSettingsList button[onclick^="deleteHouse"] {
    position: absolute !important;
    top: 15px;
    right: 15px;
    width: 36px !important;
    height: 36px !important;
  }

  /* Center the Emoji and Color Picker at the top */
  #houseSettingsList div[style*="flex-direction: column; gap: 10px"] {
    flex-direction: row !important;
    justify-content: center;
    width: 100%;
    margin-bottom: 5px;
  }

  /* Make inputs full width on phone */
  #houseSettingsList input.form-control {
    width: 100% !important;
    height: 44px !important; /* Easier to tap */
  }

  /* Fix the Top Header Button Grid for Phone */
  .house-expanded-content > div[style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
    padding: 15px !important;
  }
}




/* 📱 SMARTPHONE TOOLBAR: Fit 3 buttons side-by-side */
@media (max-width: 780px) {
  /* Target the container that holds the 3 header buttons */
  .house-expanded-content > div[style*="background: #fafafa"] {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important; /* Force 3 columns */
    gap: 6px !important; /* Tight gap */
    padding: 10px !important; /* Less outer padding */
  }

  /* Style the buttons to be compact */
  .house-expanded-content > div[style*="background: #fafafa"] .btn {
    padding: 8px 4px !important; /* Minimal side padding */
    font-size: 11px !important; /* Shorter text needs smaller font */
    height: 40px !important;
    white-space: nowrap;
  }
  
  /* Hide the long text and show short text on mobile */
  .btn-long-text { display: none !important; }
  .btn-short-text { display: inline !important; }
}

/* Default state: Show long text on iPad/Desktop */
@media (min-width: 781px) {
  .btn-long-text { display: inline !important; }
  .btn-short-text { display: none !important; }
}




/* 📱 SMARTPHONE SPECIFIC: Master House Config Polish */
@media (max-width: 780px) {
  /* 1. Force the Modal to fill the height and remove the bottom gap */
  #houseManagerModal .house-expanded-content {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important; /* Reset padding to allow full-width internal sections */
  }

  /* 2. Internal House List - Full Width Gutter */
  #houseSettingsList {
    padding: 12px !important; /* This creates a small app-like gap from the glass */
    display: flex;
    flex-direction: column;
    gap: 12px !important;
  }

  /* 3. House Cards - Fill available width */
  #houseSettingsList > div {
    grid-template-columns: 1fr !important; 
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 16px !important;
    border-radius: 16px !important;
  }

  /* 4. Footer - Pin to bottom, remove gap */
  #houseManagerModal .house-expanded-content > div:last-child {
    margin-top: auto !important; /* Pushes footer to the absolute bottom */
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom)) 20px !important;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  }

  /* Compact the header buttons further to ensure they stay on one line */
  .house-expanded-content > div[style*="background: #fafafa"] {
    padding: 10px 12px !important;
    gap: 8px !important;
  }
}



/* 📱 & 💻 TABLET & SMARTPHONE: Clean Column Stack */
@media (max-width: 1370px) {
  .announcement-item {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 20px !important; /* Slightly more breathing room for iPad */
    background: #ffffff;
    border-radius: 16px !important;
  }

  /* Title Input */
  .announcement-title-input {
    width: 100% !important;
    font-weight: 800 !important;
    font-size: 16px !important;
    height: 48px !important;
  }

  /* Main Message Text Area */
  .announcement-text {
    width: 100% !important;
    font-size: 15px !important;
    height: 48px !important;
  }

  /* Bottom Row: Points and Delete button */
  .announcement-actions-row {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
  }

  /* Make the delete button a consistent square on the side */
  .announcement-item .btn-danger {
    flex: 0 0 48px !important;
    height: 48px !important;
    border-radius: 12px !important;
  }
}


/* 📱 Smartphone Override: Let points fill the row if screen is tiny */
@media (max-width: 480px) {
    .points-input-wrapper {
      flex: 1 !important;
    }
  }










    /* --- AWARD HISTORY FULLSCREEN & DESKTOP FIXES --- */
    #awardHistoryModal {
      align-items: flex-start !important;
      padding: 0 !important;
    }
    #awardHistoryModal .house-expanded-content {
      width: 100vw !important;
      height: 100vh !important;
      max-width: none !important;
      max-height: none !important;
      border-radius: 0 !important;
      margin: 0 !important;
      padding: 0 !important;
      display: flex !important;
      flex-direction: column !important;
      position: relative !important;
    }
    
    /* 🔥 FIX: Ensure modal header has proper padding and no gap under X button */
    #awardHistoryModal .modal-header {
      padding: 15px 50px 15px 20px !important;
      margin: 0 !important;
      position: relative !important;
      flex-shrink: 0 !important;
      background: white !important;
      z-index: 5 !important;
    }
    
    /* 🔥 FIX: Position close button correctly - MAKE IT VISIBLE */
    #awardHistoryModal .house-expanded-close {
      position: absolute !important;
      top: 12px !important;
      right: 12px !important;
      width: 32px !important;
      height: 32px !important;
      background: #ef4444 !important;
      color: white !important;
      border: none !important;
      border-radius: 50% !important;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      cursor: pointer !important;
      z-index: 100 !important;
      font-size: 18px !important;
      box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
    }
    
    /* 🔥 FIX: Ensure close button icon is visible */
    #awardHistoryModal .house-expanded-close i {
      font-size: 16px !important;
      color: white !important;
    }
    
    /* 🔥 FIX: Remove any existing close button styles that might conflict */
    #awardHistoryModal .house-expanded-close:hover {
      background: #dc2626 !important;
      transform: scale(1.05) !important;
    }
    
    /* 🔥 FIX: Content area - scrollable, no extra padding */
    #awardHistoryModal .table-container {
      flex: 1 !important;
      overflow-y: auto !important;
      padding: 0 !important;
      margin: 0 !important;
    }
    
    /* 🔥 FIX: Remove any extra padding from the history content */
    #awardHistoryContent {
      padding: 0 !important;
    }
    
    /* Force dropdowns into a single row on Desktop */
    @media (min-width: 1371px) {
      #awardHistoryModal .modal-header > div:last-child {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 12px !important;
      }
      #awardHistoryModal .modal-header select.form-control {
        width: auto !important;
        min-width: 140px;
      }
    }



    /* --- REWARDS MODAL MILESTONE GRID --- */
#milestoneExplanationGrid.milestone-timeline {
  display: grid !important;
  width: 100% !important;
  box-sizing: border-box !important;
  gap: 12px !important;
  padding: 12px !important;
  height: auto !important;
  align-items: stretch !important;
  justify-items: stretch !important;
}

/* Desktop */
@media (min-width: 1101px) {
  #milestoneExplanationGrid.milestone-timeline {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 12px !important;
    padding: 12px !important;
  }

  #milestoneExplanationGrid .milestone-step {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    min-height: 118px !important;
    margin: 0 !important;
    padding: 16px !important;
    box-sizing: border-box !important;

    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
  }

  #milestoneExplanationGrid .milestone-label {
    flex: 1 !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  #milestoneExplanationGrid .milestone-title {
    font-size: 14px !important;
    line-height: 1.25 !important;
    margin-bottom: 4px !important;
  }

  #milestoneExplanationGrid .milestone-caption {
    font-size: 12px !important;
    line-height: 1.4 !important;
  }

  #milestoneExplanationGrid .milestone-icon {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    font-size: 18px !important;
  }
}

    /* iPad / Tablet */
    @media (min-width: 651px) and (max-width: 1100px) {
      #milestoneExplanationGrid.milestone-timeline {
        grid-template-columns: repeat(3, 1fr) !important;
      }
    }

    /* Smartphone */
    @media (max-width: 650px) {
      #milestoneExplanationGrid.milestone-timeline {
        grid-template-columns: repeat(2, 1fr) !important; /* 2 per row on phones */
        gap: 10px !important;
        padding: 10px !important;
      }
      
      /* Stack icon above text to fit the narrower 2-column layout gracefully */
      #milestoneExplanationGrid .milestone-step {
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 12px 8px !important;
        min-height: auto !important;
        display: flex !important;
        flex-direction: column !important; /* Stacks icon on top */
        align-items: center !important;
        text-align: center !important;
      }
      
      #milestoneExplanationGrid .milestone-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 16px !important;
        margin-bottom: 8px !important;
      }
      
      #milestoneExplanationGrid .milestone-title {
        font-size: 13px !important;
        margin-bottom: 4px !important;
        line-height: 1.2 !important;
      }
      
      #milestoneExplanationGrid .milestone-caption {
        font-size: 11px !important;
        line-height: 1.3 !important;
      }
    }




    /* --- FIX: REWARDS MODAL BOTTOM SPACING --- */
    @media (max-width: 1370px) {
      /* Removes the global 90px padding that pushes modal content up */
      #badgesInfoModal .house-expanded-content {
        padding-bottom: 0 !important;
      }
      
      /* Tightens the space above and below the button on mobile */
      #rewardsFooterBtn {
        margin-top: 20px !important;
        padding-bottom: 30px !important; /* Leaves just enough room for the iPhone home bar */
      }
    }




    /* --- FORCE IPAD CARD STYLES ONTO DESKTOP (UNIVERSAL CARDS) --- */
    @media (min-width: 1371px) {
      #students-section .student-card {
        position: relative;
        margin: 0;
        border-radius: 16px; 
        background: linear-gradient(to bottom, #ffffff 82%, var(--house-color) 175%) !important;
        box-shadow: 0 3px 8px rgba(0,0,0,0.08);
        border: 1px solid rgba(0,0,0,0.05);
        display: block !important; 
        min-height: 138px !important; 
        padding: 0 !important;
        overflow: hidden !important;
        transition: all 0.3s ease;
      }
      
      #students-section .student-card.collapsed .student-card-header {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 15px 2px 8px 2px !important;
        height: 100%;
        text-align: center;
        width: 100%;
        box-sizing: border-box;
        cursor: pointer;
      }
      
      .student-card.collapsed .hero-shield {
        width: 66px !important;     
        height: 66px !important; 
        font-size: 34px !important; 
        margin: 0 auto 5px auto !important;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        background: white !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border: 4px solid var(--house-color) !important; 
        box-sizing: border-box !important;
      }

      #students-section .student-card.collapsed .student-card-name {
        font-size: 14px !important;
        font-weight: 800 !important;
        color: #0f172a !important;
        text-align: center;
        margin-top: 4px;
        width: 100%;
      }


      /* ==========================================
         DESKTOP UNASSIGNED COLLAPSED STUDENT CARDS
         ========================================== */

      #students-section .house-group-section[data-house="Unassigned"] .student-card.collapsed {
        background: #eef2f6 !important;
        background-image: none !important;

        border: 1px solid #cbd5e1 !important;

        box-shadow:
          0 2px 5px rgba(15,23,42,0.035) !important;
      }

      #students-section .house-group-section[data-house="Unassigned"] .student-card.collapsed .student-card-header {
        background: transparent !important;
      }

      #students-section .house-group-section[data-house="Unassigned"] .student-card.collapsed .student-card-name {
        color: #94a3b8 !important;
      }

      #students-section .house-group-section[data-house="Unassigned"] .student-card.collapsed .hero-shield {
        background: #cbd5e1 !important;
        border-color: #94a3b8 !important;

        box-shadow:
          0 3px 8px rgba(15,23,42,0.06) !important;
      }

      #students-section .house-group-section[data-house="Unassigned"] .student-card.collapsed .collapsed-points-pill {
        background: #e2e8f0 !important;
        color: #94a3b8 !important;

        border-color: #cbd5e1 !important;

        box-shadow: none !important;
      }

      #students-section .house-group-section[data-house="Unassigned"] .student-card.collapsed .expansion-indicator {
        color: #94a3b8 !important;
        opacity: .45 !important;
      }
      
      /* Make the expanded card pop out of the grid beautifully */
      #students-section .student-card.expanded {
        max-height: 1000px !important; 
        display: flex !important;
        flex-direction: column;
        overflow: visible !important;
        padding: 16px !important;
        grid-column: 1 / -1 !important; /* Forces it to span all 4 columns */
        transform: scale(1.01) !important; 
        background: linear-gradient(to bottom, #ffffff 45%, var(--house-color) 150%) !important;
        box-shadow: 0 20px 40px rgba(0,0,0,0.2) !important; 
        border: 3px solid var(--house-color) !important; 
        z-index: 10 !important; 
        margin: 12px 0 !important; 
      }

      .collapsed-points-pill {
        position: absolute !important;
        top: 8px !important;
        right: 8px !important;
        background: rgba(255, 255, 255, 0.95) !important; 
        color: #0f172a !important; 
        font-size: 12px !important;
        font-weight: 900 !important;
        padding: 2px 8px !important;
        border-radius: 6px !important;
        border: 1px solid rgba(0,0,0,0.1) !important;
        z-index: 15;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
      }
      

      /* Hide extra text that clutters desktop cards */
      #students-section .student-card.collapsed .hero-id-tag,
      #students-section .student-card.collapsed .student-id-badge {
        display: none !important;
      }
      
      .student-card.collapsed .student-card-details, 
      .student-card.collapsed .student-card-actions, 
      .student-card.collapsed .expanded-badge-name { 
        display: none !important; 
      }
      
      .student-card.expanded .student-card-details, 
      .student-card.expanded .student-card-actions, 
      .student-card.expanded .expanded-badge-name { 
        display: block !important; 
      }
      
      /* Make sure the Delete button isn't squashed */
      .student-card.expanded .student-card-actions {
        display: flex !important;
        justify-content: space-between;
        margin-top: 10px;
      }

    }

/* Student card points tabs: phones only */
@media (max-width: 780px) {

  /* Hidden until the school Store setting is confirmed ON. */
  #studentsList .student-card .mobile-student-points-tabs {
    display: none !important;
  }

  #studentsList .student-card.expanded[data-store-points-enabled="true"]
  .mobile-student-points-tabs {
    display: grid !important;
  }

  #studentsList .student-card.collapsed .mobile-student-points-tabs,
  #studentsList .student-card.collapsed .mobile-student-store-panel {
    display: none !important;
  }

  /* House controls must not appear in the Store view. */
  #studentsList .student-card.expanded.mobile-store-selected .student-card-details,
  #studentsList .student-card.expanded.mobile-store-selected .student-card-actions {
    display: none !important;
  }

  #studentsList .student-card.expanded .mobile-student-store-panel[hidden] {
    display: none !important;
  }

  #studentsList .student-card.expanded.mobile-store-selected {
    max-height: 1600px !important;
  }
}




    /* ==========================================
       COMPACT EXPANDED STUDENT HEADER - PHONES
       ========================================== */
    @media (max-width: 780px) {
      #studentsList .student-card.expanded .student-card-header {
        display: grid !important;
        grid-template-columns: 74px minmax(0, 1fr) !important;
        align-items: center !important;
        justify-content: start !important;
        column-gap: 12px !important;
        width: 100%;
        min-width: 0;
        padding: 12px 8px !important;
        margin: 0 0 8px !important;
        text-align: left !important;
      }

      #studentsList .student-card.expanded .student-card-header > .hero-shield {
        display: flex !important;
        width: 72px !important;
        height: 72px !important;
        min-width: 72px !important;
        min-height: 72px !important;
        margin: 0 !important;
        align-self: center;
        border-radius: 50% !important;
      }

      #studentsList .student-card.expanded .student-card-header > .name-id-stack {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        gap: 6px !important;
        width: 100%;
        min-width: 0;
        margin: 0 !important;
        text-align: left !important;
      }

      #studentsList .student-card.expanded .student-card-name {
        width: 100%;
        min-width: 0;
        font-size: clamp(17px, 4.5vw, 21px) !important;
        line-height: 1.2 !important;
        margin: 0 !important;
        text-align: left !important;
        overflow-wrap: anywhere;
      }

      #studentsList .student-card.expanded .expanded-badge-name {
        max-width: 100%;
        min-width: 0;
        margin: 0 !important;
        text-align: left !important;
      }

      #studentsList .student-card.expanded .expanded-badge-name > div {
        max-width: 100%;
        padding: 4px 9px !important;
        font-size: 10px !important;
        line-height: 1.3;
        white-space: normal;
      }

      #studentsList .student-card.expanded .student-id-badge {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 42px !important;
        align-items: center !important;
        justify-content: start !important;
        gap: 8px !important;
        width: 100%;
        min-width: 0;
        margin: 0 !important;
        padding: 0 !important;
      }

      #studentsList .student-card.expanded .student-id-badge > div {
        display: flex !important;
        align-items: center;
        justify-content: center;
        min-width: 0;
        width: 100%;
        max-width: 100%;
        min-height: 42px;
        padding: 6px 5px !important;
        font-size: 10px !important;
        letter-spacing: 0.3px !important;
        overflow-wrap: anywhere;
        text-align: center;
      }

      #studentsList .student-card.expanded .student-id-badge > button {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 42px !important;
        min-width: 42px !important;
        max-width: 42px !important;
        height: 42px !important;
        min-height: 42px !important;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 9px !important;
        font-size: 14px !important;
      }
    }

    /* ==========================================
       TRACKEDU ANT CHARACTERS - DESKTOP SIZE
       Only applies when Ant Characters are ON
       ========================================== */
    @media (min-width: 1371px) {

      #students-section .student-card.collapsed.trackedu-ant-student-card {
        min-height: 160px !important;
      }

      #students-section .student-card.collapsed.trackedu-ant-student-card .hero-shield {
        width: 90px !important;
        height: 90px !important;
        min-width: 90px !important;
        min-height: 90px !important;
        border-width: 3px !important;
        border-radius: 50% !important;
        margin: 0 auto 6px auto !important;
        flex-shrink: 0 !important;
      }

    }

    /* --- FIX: PERFECT CIRCLE AVATARS FOR DESKTOP CARDS --- */
    @media (min-width: 1371px) {
      /* Force circular shape and prevent flexbox from stretching it */
      #students-section .student-card .hero-shield {
        border-radius: 50% !important;
        flex-shrink: 0 !important; 
      }
      
      /* Set strict dimensions for the expanded state */
      #students-section .student-card.expanded .hero-shield {
        width: 80px !important;
        height: 80px !important;
        min-height: 80px !important;
        font-size: 40px !important;
        margin: 0 auto 15px auto !important;
      }
      
      /* Ensure the header stacks vertically so the avatar sits on top */
      #students-section .student-card.expanded .student-card-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
      }
    }









     /* Additional styles for student management */
     .students-page-header {
      display: flex;
      flex-direction: column;
      gap: 8px;

      padding: 4px 18px 6px;

      position: sticky;
      top: 0;
      z-index: 900;

      margin:
        0
        -16px
        8px;

      width:
        calc(100% + 32px);

      box-sizing:
        border-box;

      background:
        var(--section-students);

      backdrop-filter:
        blur(12px);

      -webkit-backdrop-filter:
        blur(12px);

      border-bottom:
        1px solid #e2e8f0;

      box-shadow:
        none;
    }


    /* Desktop Student Management:
       remove outer page gutter so sticky header is truly edge-to-edge */
    @media (min-width: 1371px) {

      body.active-section-students .main-content {
        padding:
          0 !important;
      }

      body.active-section-students #students-section {
        padding:
          0 16px 16px !important;

        border-radius:
          0 !important;
      }

    }


    @media (max-width: 1370px) {
      .students-page-header {
        padding:
          4px 12px 6px;

        margin:
          0
          -12px
          8px;

        width:
          calc(100% + 24px);
      }
    }

    .students-header-row1 {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;
      flex-wrap: wrap;
      gap: 12px;
    }
    
    
    .premium-search-input {
      width: 100% !important;
      height: 48px !important;
      border-radius: 12px !important;
      padding-left: 44px !important;
      padding-right: 16px !important;
      font-size: 15px !important;
      background-color: #fff !important;
      border: 1px solid #cbd5e1 !important;
      box-shadow: 0 4px 10px rgba(0,0,0,0.03) !important;
      transition: all 0.2s ease !important;
    }
    .premium-search-input:focus {
      border-color: #3b82f6 !important;
      box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15) !important;
      outline: none !important;
    }
    .search-icon-inside {
      position: absolute;
      left: 16px;
      top: 50%;
      transform: translateY(-50%);
      color: #94a3b8;
      font-size: 16px;
      pointer-events: none;
    }
    @media (max-width: 600px) {
      .students-header-actions .compact-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
        border-radius: 8px !important;
      }
      .students-header-actions .compact-btn i {
        font-size: 12px !important;
      }
      
    }
    .btn-premium-orange {
      background: linear-gradient(135deg, #f97316, #fb923c) !important;
      border-color: #ea580c !important;
      color: white !important;
      font-weight: 700 !important;
      box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.3) !important;
      transition: all 0.2s ease !important;
      display: inline-flex !important;
      align-items: center;
      gap: 8px;
    }
    .btn-premium-orange:hover {
      background: linear-gradient(135deg, #ea580c, #f97316) !important;
      transform: translateY(-1px);
      box-shadow: 0 10px 15px -3px rgba(249, 115, 22, 0.4) !important;
    }
    .btn-premium-orange i {
      color: white !important;
    }
    
    /* Quick gesture hint */
    .quick-gesture-hint {
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: #f0fdf4;
      border: 1px solid #bbf7d0;
      padding: 12px 16px;
      border-radius: 12px;
      margin: 10px 16px 15px 16px;
      animation: hintSlideIn 0.5s ease-out;
      transition: all 0.3s ease;
      position: relative;
      z-index: 10;
    }
    .hint-content {
      display: flex;
      gap: 15px;
      font-size: 11px;
      font-weight: 700;
      color: #166534;
      flex-wrap: wrap;
    }
    .hint-item {
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .hint-item i {
      font-size: 14px;
      color: #10b981;
    }
    .close-hint {
      color: #166534;
      opacity: 0.6;
      font-size: 18px;
      cursor: pointer;
      padding: 5px;
      margin-left: 10px;
      transition: opacity 0.2s;
    }
    .close-hint:hover {
      opacity: 1;
    }
    @keyframes hintSlideIn {
      from { opacity: 0; transform: translateY(-10px); }
      to { opacity: 1; transform: translateY(0); }
    }
    
    /* Multi-select tick box */
    .select-tick-box {
      display: none;
      position: absolute;
      top: 10px;
      left: 10px;
      width: 24px;
      height: 24px;
      background: white;
      border: 2px solid #000;
      border-radius: 50%;
      z-index: 5;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      color: #000;
    }
    body.selection-mode-active .select-tick-box {
      display: flex;
    }
    .student-card.selected .select-tick-box {
      background: #10b981;
      border-color: #10b981;
      color: white;
    }
    
    /* Floating points animation */
    .floating-point {
      position: fixed;
      color: #10b981;
      font-family: 'Lexend', sans-serif !important;
      font-size: 28px;
      text-shadow: 0 2px 4px rgba(0,0,0,0.3), 0 0 10px #ffffff;
      pointer-events: none;
      animation: floatUpFade 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
      z-index: 10000;
    }
    .hero-shield.tappable {
      cursor: pointer;
      transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
      position: relative;
      user-select: none;
      -webkit-tap-highlight-color: transparent;
    }
    .hero-shield.tappable:active {
      transform: scale(0.7) !important;
    }
    @keyframes floatUpFade {
      0% { transform: translateY(0) scale(1); opacity: 1; }
      100% { transform: translateY(-50px) scale(1.5); opacity: 0; }
    }
    
    /* House group header - for mobile grouping */
    .house-group-header {
      background: white;
      border-radius: 12px;
      padding: 14px 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      box-shadow: 0 4px 10px rgba(0,0,0,0.05);
      border: 1px solid #e2e8f0;
      cursor: pointer;
      transition: all 0.2s ease;
      border-left: 6px solid var(--group-color, #64748b);
      margin-bottom: 8px;
    }
    .house-group-header:active {
      transform: scale(0.98);
    }
    .house-group-title {
      font-size: 16px;
      font-weight: 800;
      color: #1e293b;
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .house-group-count {
      background: #f1f5f9;
      color: #64748b;
      font-size: 11px;
      font-weight: 700;
      padding: 4px 10px;
      border-radius: 20px;
    }
    .house-chevron {
      font-size: 14px;
      color: #94a3b8;
      transition: transform 0.3s ease;
    }
    .house-group-header.active .house-chevron {
      transform: rotate(180deg);
    }
    .house-group-grid {
      display: none;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
      padding: 4px 0 12px 0;
      width: 100%;
      box-sizing: border-box;
    }
    .house-group-grid.show {
      display: grid;
    }
    .house-select-wrapper {
      display: none !important;
    }
    body.selection-mode-active .house-select-wrapper {
      display: flex !important;
      align-items: center;
      justify-content: center;
      padding: 4px;
      border-radius: 8px;
      transition: background 0.2s;
    }
    .house-group-checkbox {
      width: 22px;
      height: 22px;
      cursor: pointer;
      accent-color: #10b981;
      border-radius: 6px;
      margin: 0;
    }
    .house-group-pts-chip {
      background: rgba(0,0,0,0.05);
      color: #475569;
      font-size: 11px;
      font-weight: 800;
      padding: 4px 10px;
      border-radius: 20px;
      display: flex;
      align-items: center;
      gap: 4px;
      border: 1px solid rgba(0,0,0,0.05);
    }





    @media (min-width: 1371px) {
  #selectionToolbar {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 20px !important;
    padding: 0 24px !important;
    height: 64px !important;
    width: auto !important;
    min-width: 450px !important;
  }
  
  /* Force any wrapper divs inside the toolbar to also sit in a row */
  #selectionToolbar > div {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    position: static !important;
    gap: 12px !important;
  }
  
  /* Strip the mobile vertical stacking (absolute positioning & transforms) */
  #selectionToolbar button {
    position: static !important; 
    transform: none !important; 
    margin: 0 !important;
    height: 38px !important;
    width: 38px !important;
    min-width: 38px !important;
    border-radius: 50% !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 800 !important;
    font-size: 14px !important;
    color: white !important;
    padding: 0 !important;
    cursor: pointer !important;
    opacity: 1 !important;
    visibility: visible !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
    transition: transform 0.2s ease !important;
  }
  
  #selectionToolbar button:hover {
    transform: scale(1.1) !important;
  }
  
  /* Format the "All" Button into a Pill - REMOVE HARDCODED BACKGROUND */
  #selectionToolbar button:nth-of-type(1) {
    border-radius: 20px !important;
    width: auto !important;
    padding: 0 16px !important;
    /* REMOVED: background: #3b82f6 !important; - Let JavaScript control the color */
  }
  
  /*
   * Selection toolbar button colours.
   * Use explicit classes instead of nth-of-type,
   * because labelled buttons change the button order.
   */

  #selectionToolbar
  .action-group
  .btn-bulk:nth-of-type(1) {
    background: #10b981 !important;
  }

  #selectionToolbar
  .action-group
  .btn-bulk:nth-of-type(2) {
    background: #f59e0b !important;
  }

  #selectionToolbar
  .reason-award-toolbar-btn {
    background: #f59e0b !important;
  }

  #selectionToolbar
  .action-group
  .btn-custom:not(.reason-award-toolbar-btn) {
    background: #8b5cf6 !important;
  }
}

    /* --- FIX: GREEN BORDER FOR SELECTED CARDS ON DESKTOP --- */
    @media (min-width: 1371px) {
      #students-section .student-card.selected {
        border: 3px solid #10b981 !important; /* Thick green border */
        box-shadow: 0 8px 16px rgba(16, 185, 129, 0.15) !important; /* Soft green glow */
      }
      
      /* Ensure the little green checkmark icon also shows up in the corner */
      #students-section .student-card.selected .select-tick-box {
        display: flex !important;
        background: #10b981 !important;
        color: white !important;
      }
    }


/* --- FINAL NUCLEAR TOAST FIX --- */
    
    /* 1. Force ANY toast container to be a small floating box in the top right */
    #toast-container, #toastContainer, .toast-container, #toolbar-toast-container {
      position: fixed !important;
      top: 20px !important;
      right: 20px !important;
      left: auto !important;
      bottom: auto !important;
      width: auto !important;
      height: auto !important;
      max-width: 400px !important;
      display: flex !important;
      flex-direction: column !important;
      align-items: flex-end !important;
      gap: 10px !important;
      z-index: 2000000 !important;
      pointer-events: none !important;
      transform: none !important;
      background: transparent !important; /* Prevents the white bar at bottom */
    }

    /* 2. Force the individual bubbles to look like floating pills */
    .toast-central, .toast, .toast-notification, .toolbar-toast-item, .toast-item {
      position: relative !important;
      display: inline-flex !important; /* Stops it from stretching 100% wide */
      align-items: center !important;
      justify-content: flex-start !important;
      background: #ffffff !important;
      color: #1e293b !important;
      padding: 14px 24px !important;
      border-radius: 16px !important;
      box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important;
      font-weight: 700 !important;
      font-size: 15px !important;
      pointer-events: auto !important;
      width: auto !important;
      min-width: 280px !important;
      border-left: 6px solid #10b981 !important;
      margin: 0 !important; /* Removes any browser default margins */
      animation: toastSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    }

    @keyframes toastSlideIn {
      from { opacity: 0; transform: translateX(50px); }
      to { opacity: 1; transform: translateX(0); }
    }

    /* 3. Mobile/iPad Adjustment to keep it clear of the header */
    @media (max-width: 1370px) {
      #toast-container, #toastContainer, .toast-container, #toolbar-toast-container {
        top: 70px !important;
        right: 15px !important;
      }
    }



/* ANT PROFILE ONLY: Unframed artwork, centred identity and progress. */
@media (min-width: 1371px) {
  #studentModalContent .trackedu-ant-profile-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    width: 100%;
    margin: 8px 0 12px;
  }
  #studentModalContent .trackedu-ant-profile-art {
    flex: 0 0 180px;
    width: 180px;
    height: 190px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #studentModalContent .trackedu-ant-profile-art img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
  #studentModalContent .trackedu-ant-profile-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    min-width: 0;
  }
  #studentModalContent .trackedu-ant-profile-details h2 {
    font-size: 34px !important;
    line-height: 1.12;
    margin-bottom: 10px !important;
  }
  #studentModalContent .trackedu-ant-profile-details > div {
    justify-content: flex-start !important;
  }
  #studentModalContent .trackedu-ant-progress {
    width: 100%;
    margin: 0 0 20px;
    text-align: left;
    color: #1e293b;
  }
}

/* --- STUDENT PROFILE MODAL: PHONES --- */
@media (max-width: 780px) {
  #desktopStudentModal {
    align-items: center !important;
    justify-content: center !important;
    padding: 10px !important;
  }

  #desktopStudentModal.show {
    display: flex !important;
    opacity: 1;
  }

  #desktopStudentModal #studentModalContent {
    width: 100%;
    max-width: 460px;
    max-height: calc(100dvh - 20px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 48px 16px 20px;
    border-radius: 18px;
  }

  #studentModalContent .trackedu-ant-profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    margin: 0 0 12px;
  }

  #studentModalContent .trackedu-ant-profile-art {
    flex: 0 0 110px;
    width: 110px;
    height: 110px;
    max-width: 110px;
    max-height: 110px;
    border-radius: 50%;
    overflow: hidden;
    background: #ffffff;
    border: 3px solid #dbe2ea;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #studentModalContent .trackedu-ant-profile-art img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }

  #studentModalContent .trackedu-ant-profile-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-width: 0;
    text-align: center;
  }

  #studentModalContent .trackedu-ant-profile-details h2 {
    font-size: clamp(21px, 6vw, 27px) !important;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  #studentModalContent .trackedu-ant-profile-details > div {
    justify-content: center !important;
  }

  #studentModalContent #studentPointsTabs {
    width: 100%;
    gap: 8px !important;
    margin: 16px 0 8px !important;
  }

  #studentModalContent #studentPointsTabs > button {
    min-height: 44px !important;
    padding: 9px 5px !important;
    gap: 5px !important;
    font-size: 12px !important;
  }

  #studentModalContent .student-card-details {
    padding: 12px;
    margin: 12px 0;
  }

  #studentModalContent .student-card-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
    width: 100%;
  }

  #studentModalContent .student-card-actions .btn {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 9px 6px;
    font-size: 11px;
    white-space: normal;
  }

  #studentModalContent .trackedu-ant-progress {
    width: 100%;
    margin: 12px 0;
  }
}

/* --- STUDENT PROFILE MODAL: IPAD + DESKTOP (PHONE UNCHANGED) --- */
@media (min-width: 781px) {
      #desktopStudentModal {
        align-items: center !important;
        justify-content: center !important;
        padding: 18px !important;
      }

      #desktopStudentModal.show { display: flex !important; opacity: 1; }

      #desktopStudentModal #studentModalContent {
        width: min(700px, 100%);
        max-height: calc(100dvh - 36px);
        overflow-x: hidden;
        overflow-y: auto;
      }

      #studentModalContent .trackedu-ant-profile-header {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 24px;
        width: 100%;
        margin: 8px 0 4px;
      }

      #studentModalContent .trackedu-ant-profile-art {
        flex: 0 0 190px;
        width: 190px;
        height: 190px;
        aspect-ratio: 1 / 1;
        border-radius: 50%;
        overflow: hidden;
        background: #ffffff;
        border: 4px solid rgba(148, 163, 184, 0.35);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
      }

      #studentModalContent .trackedu-ant-profile-art img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
        border-radius: 50%;
      }

      #studentModalContent .trackedu-ant-profile-details {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        min-width: 0;
      }

      #studentModalContent .trackedu-ant-profile-details h2 {
        font-size: 34px !important;
        line-height: 1.12;
        margin-bottom: 10px !important;
      }

      #studentModalContent .trackedu-ant-profile-details > div {
        justify-content: flex-start !important;
      }

      #studentModalContent .trackedu-ant-profile-header + .student-card-details {
        padding: 18px 20px;
        margin: 14px 0 16px;
      }

      #studentModalContent .trackedu-ant-progress {
        width: 100%;
        margin: 0 0 20px;
        text-align: left;
      }

      #studentModalContent .student-card-actions {
        display: grid !important;
        grid-template-columns:
          minmax(0, 1fr)
          minmax(0, 1fr)
          minmax(0, 1.4fr)
          minmax(0, .65fr) !important;
        gap: 6px !important;
        width: 100%;
      }

      #studentModalContent .student-card-actions .btn {
        min-width: 0;
        width: 100%;
        padding: 10px 4px;
        font-size: clamp(10px, 1vw, 13px);
        white-space: nowrap;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
      }

      /* Student Details: Dark Mode */
      body.house-display-dark #desktopStudentModal #studentModalContent {
        background: #111827 !important;
        color: #f8fafc !important;
      }

      body.house-display-dark #studentModalContent h2 {
        color: #f8fafc !important;
      }

      /* House, Points and Role panel */
      body.house-display-dark #studentModalContent .student-card-details {
        background: #1e293b !important;
        border-color: #334155 !important;
        color: #e2e8f0 !important;
      }

      body.house-display-dark #studentModalContent .rd-dropdown::before,
      body.house-display-dark #studentModalContent .rd-points::before {
        color: #94a3b8 !important;
      }

      body.house-display-dark #studentModalContent .form-control {
        background: #111827 !important;
        border-color: #475569 !important;
        color: #f8fafc !important;
      }

      body.house-display-dark #studentModalContent .form-control option {
        background: #111827;
        color: #f8fafc;
      }

      /* Student ID and edit controls */
      body.house-display-dark #studentModalContent .student-id-badge > div {
        background: #1e293b !important;
        border-color: #475569 !important;
        color: #e2e8f0 !important;
      }

      body.house-display-dark #studentModalContent .student-id-badge > button {
        background: #263449 !important;
        border-color: #475569 !important;
        color: #93c5fd !important;
      }

      /* Administrative point correction */
      body.house-display-dark #studentModalContent .rd-points .btn {
        background: #263449 !important;
        border-color: #475569 !important;
        color: #e2e8f0 !important;
      }

      /* Next character and progression */
      body.house-display-dark #studentModalContent .trackedu-ant-progress {
        color: #f8fafc !important;
      }

      body.house-display-dark #studentModalContent .trackedu-ant-progress
      [style*="color:#64748b"] {
        color: #cbd5e1 !important;
      }

      body.house-display-dark #studentModalContent .trackedu-ant-progress
      [role="progressbar"] {
        background: #334155 !important;
      }

      /* Retain coloured action buttons */
      body.house-display-dark #studentModalContent .student-card-actions .btn {
        transition: filter 0.15s ease;
      }

      body.house-display-dark #studentModalContent .student-card-actions .btn:hover {
        filter: brightness(1.12);
      }

      #studentModalContent {
        width: 700px;
        background: white;
        border-radius: 24px;
        padding: 40px;
        position: relative;
        box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
        border: 3px solid var(--house-color);
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
      }

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

      #studentModalContent .student-card-details {
        display: block;
        background: #f8fafc;
        padding: 24px;
        border-radius: 16px;
        border: 1px solid #e2e8f0;
        margin: 25px 0;
        width: 100%;
      }

      /* Keep all three profile fields aligned on iPad and desktop */
      #studentModalContent .responsive-details-row {
        width: 100%;
        align-items: stretch;
      }

      #studentModalContent .responsive-details-row .rd-dropdown,
      #studentModalContent .responsive-details-row .rd-points {
        width: 100%;
        min-width: 0;
        margin-left: 0;
        margin-right: 0;
      }

      #studentModalContent .responsive-details-row .form-control,
      #studentModalContent .responsive-details-row .rd-points .btn {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
      }

      /* Compact spacing for the enlarged Ant Character profile only */
      #studentModalContent .trackedu-ant-profile-header {
        margin-bottom: 4px;
      }

      #studentModalContent .trackedu-ant-profile-header + .student-card-details {
        padding: 18px 20px;
        margin: 14px 0 16px;
      }

      #studentModalContent .trackedu-ant-profile-header + .student-card-details .rd-points {
        gap: 5px !important;
      }

      #studentModalContent .trackedu-ant-profile-header + .student-card-details .rd-points .btn {
        min-height: 40px !important;
        padding: 8px 10px;
      }

      #studentModalContent .trackedu-ant-profile-header + .student-card-details .rd-dropdown::before,
      #studentModalContent .trackedu-ant-profile-header + .student-card-details .rd-points::before {
        margin-bottom: 5px;
      }

      #studentModalContent .responsive-details-row {
        display: grid;
        grid-template-columns: 1.2fr 0.8fr 1.2fr;
        gap: 15px;
      }
      
      #studentModalContent .rd-dropdown::before,
      #studentModalContent .rd-points::before {
        display: block; font-size: 10px; font-weight: 800; color: #94a3b8;
        text-transform: uppercase; margin-bottom: 8px; letter-spacing: 1px;
      }
      #studentModalContent .rd-dropdown:nth-of-type(1)::before { content: "HOUSE"; }
      #studentModalContent .rd-points::before { content: "POINTS"; }
      #studentModalContent .rd-dropdown:nth-of-type(3)::before { content: "ROLE"; }

      #studentModalContent .student-card-actions {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 0.75fr;
        gap: 10px;
        width: 100%;
      }

      #studentModalContent .student-card-actions .btn {
        min-width: 0;
        width: 100%;
        padding: 10px 8px;
        font-size: 13px;
        white-space: nowrap;
      }
      
      /* Disable the old layout jump on desktop */
      #students-section .student-card.expanded { display: none !important; }



    }




/* --- PRESTIGE STYLE FOR HOUSE CAPTAINS --- */
#students-section .student-card[data-role="House Captain"] {
      border: 2px solid #fbbf24 !important; /* Gold Border */
      background: linear-gradient(135deg, #ffffff 0%, #fffbeb 100%) !important;
      box-shadow: 0 10px 20px rgba(251, 191, 36, 0.15) !important;
    }

    /* Add a small crown above their avatar */
    #students-section .student-card[data-role="House Captain"] .hero-shield::after {
      content: '👑';
      position: absolute;
      top: -12px;
      left: 50%;
      transform: translateX(-50%);
      font-size: 18px;
      filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    }

    /* Make their name stand out */
    #students-section .student-card[data-role="House Captain"] .student-card-name {
      color: #b45309 !important; /* Deep Gold/Amber */
    }




    .effort-badge {
      font-size: 10px;
      padding: 3px 8px;
      border-radius: 6px;
      font-weight: 800;
      text-transform: uppercase;
      margin-left: 8px;
    }
    .effort-low { background: #dcfce7; color: #15803d; }
    .effort-med { background: #fef3c7; color: #b45309; }
    .effort-high { background: #fee2e2; color: #b91c1c; }


    .effort-pill {
      font-size: 10px;
      font-weight: 800;
      padding: 4px 10px;
      border-radius: 20px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-left: 10px;
      vertical-align: middle;
    }
    .effort-low { background: #dcfce7; color: #15803d; }
    .effort-medium { background: #fef3c7; color: #b45309; }
    .effort-high { background: #fee2e2; color: #b91c1c; }




/* --- FULL HEIGHT IMMERSIVE CHALLENGE MODAL (IPAD & MOBILE) --- */

@media (max-width: 1371px) {
      #challengeDetailsModal {
        align-items: flex-start !important; 
      }

      #challengeDetailsModal .house-expanded-content {
        width: 100vw !important;         
        height: 100vh !important;        
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;     
        margin: 0 !important;
        
        /* THE FIX: Override the global 90px padding with a tight 20px */
        padding: 20px !important;
        padding-top: 70px !important;    
        padding-bottom: 20px !important; /* Forces the white space to go away */
        
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
      }
      
      #challengeModalContent {
        flex: 1;                         
        overflow-y: auto !important;     
        /* Remove large bottom padding here too */
        padding-bottom: 20px !important; 
        -webkit-overflow-scrolling: touch;
      }
    }




    .leaderboard-category-section {
      width: 100%;
      margin-bottom: 22px;
    }

    .leaderboard-category-section:last-child {
      margin-bottom: 0;
    }
    
    .leaderboard-category-section h3 {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    /* Make the first place card in each league pop slightly */
    .leaderboard-category-section .class-rank-card:nth-child(1) {
      background: linear-gradient(135deg, #ffffff 0%, #fffbeb 100%);
      transform: scale(1.02);
      box-shadow: 0 4px 12px rgba(251, 191, 36, 0.1);
    }
    








    /* THE FIX: Visual cues for dragging */
.eb-student-row {
    cursor: grab;
    transition: background 0.2s;
}
.eb-student-row:active {
    cursor: grabbing;
}
.eb-student-row.dragging {
    opacity: 0.4;
    border: 2px dashed var(--primary-blue) !important;
}
.eb-group-card.drag-over {
    border: 2px solid var(--primary-blue) !important;
    transform: scale(1.02);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}





  /* Featured Action Buttons - Full Width Cards */
  .house-featured-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
  }
  
  .action-card-featured {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    border-radius: 20px;
    padding: 20px 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    width: 100%;
  }
  
  .action-card-featured:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(0,0,0,0.15);
  }
  
  .action-card-featured:active {
    transform: translateY(0px);
  }
  
  .featured-icon-wrapper {
    flex-shrink: 0;
  }
  
  .featured-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: transform 0.2s ease;
  }
  
  .action-card-featured:hover .featured-icon {
    transform: scale(1.05);
  }
  
  .featured-content {
    flex: 1;
    margin-left: 18px;
    text-align: left;
  }
  
  .featured-label {
    font-size: 18px;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 4px;
  }
  
  .featured-desc {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
  }
  
  .featured-arrow {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.2s ease;
  }
  
  .action-card-featured:hover .featured-arrow {
    background: var(--featured-color);
    color: white;
    transform: translateX(4px);
  }
  
  /* Featured Award Button Colors */
  .featured-award {
    --featured-color: #f59e0b;
    border-left: 4px solid #f59e0b;
  }
  
  .featured-award .featured-icon {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #d97706;
  }
  
  .featured-award:hover {
    border-color: #f59e0b;
    box-shadow: 0 12px 24px -8px rgba(245, 158, 11, 0.25);
  }
  
  .action-card-featured.featured-award:hover .featured-arrow {
    background: #f59e0b;
  }
  
  /* Featured Toolkit Button Colors */
  .featured-toolkit {
    --featured-color: #9333ea;
    border-left: 4px solid #9333ea;
  }
  
  .featured-toolkit .featured-icon {
    background: #faf5ff;
    color: #9333ea;
  }
  
  .featured-toolkit:hover {
    border-color: #9333ea;
    box-shadow: 0 12px 24px -8px rgba(147, 51, 234, 0.25);
  }
  
  .action-card-featured.featured-toolkit:hover .featured-arrow {
    background: #9333ea;
  }
  
  /* Standard Action Grid - Responsive */
  .house-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
  }
  
  .house-actions-grid .action-card {
    background: white;
    border-radius: 20px;
    padding: 20px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  
  .house-actions-grid .action-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(0,0,0,0.15);
    border-color: #cbd5e1;
  }
  
  .house-actions-grid .action-card:active {
    transform: translateY(0px);
  }
  
  .house-actions-grid .action-icon-box {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.2s ease;
  }
  
  .house-actions-grid .action-card:hover .action-icon-box {
    transform: scale(1.05);
  }
  
  .house-actions-grid .action-label {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
  }
  
  /* Card color variants */
  .house-actions-grid .card-teal .action-icon-box {
    background: #ecfdf5;
    color: #10b981;
  }
  
  .house-actions-grid .accent-blue .action-icon-box {
    background: #eff6ff;
    color: #3b82f6;
  }
  
  /* Tablet optimization */
  @media (min-width: 768px) and (max-width: 1024px) {
    .house-actions-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 14px;
    }
    .house-actions-grid .action-card {
      padding: 18px 10px;
    }
    .featured-label {
      font-size: 16px;
    }
    .featured-desc {
      font-size: 12px;
    }
    .featured-icon {
      width: 48px;
      height: 48px;
      font-size: 24px;
    }
    .action-card-featured {
      padding: 16px 20px;
    }
  }
  
  /* Mobile optimization */
  @media (max-width: 767px) {
    .house-actions-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;
    }
    .house-actions-grid .action-card {
      padding: 16px 8px;
    }
    .house-actions-grid .action-icon-box {
      width: 40px;
      height: 40px;
      font-size: 20px;
    }
    .house-actions-grid .action-label {
      font-size: 11px;
    }
    
    .action-card-featured {
      padding: 14px 16px;
    }
    .featured-icon {
      width: 44px;
      height: 44px;
      font-size: 22px;
    }
    .featured-label {
      font-size: 14px;
    }
    .featured-desc {
      font-size: 11px;
    }
    .featured-arrow {
      width: 32px;
      height: 32px;
    }
    .featured-content {
      margin-left: 12px;
    }
  }
  
  /* Desktop large screens */
  @media (min-width: 1370px) {
    .house-actions-grid {
      grid-template-columns: repeat(3, 1fr);
      gap: 18px;
    }
  }


/* Responsive announcement layout */
@media (max-width: 767px) {
    .announcement-row-desktop {
      flex-direction: column !important;
      gap: 12px !important;
    }
    .announcement-row-desktop > div {
      min-width: 100% !important;
    }
  }
  
  /* Tablet optimization */
  @media (min-width: 768px) and (max-width: 1024px) {
    .announcement-row-desktop {
      flex-direction: column !important;
      gap: 12px !important;
    }
    .announcement-row-desktop > div {
      min-width: 100% !important;
    }
  }
  
  /* Desktop - keep side by side */
  @media (min-width: 1025px) {
    .announcement-row-desktop {
      flex-direction: row !important;
    }
  }


   /* Start Here button special styling */
   .action-card.card-start-here {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  
  .action-card.card-start-here:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px -8px rgba(16, 185, 129, 0.5) !important;
    background: linear-gradient(135deg, #059669, #047857) !important;
  }
  
  .action-card.card-start-here:active {
    transform: translateY(0px);
  }
  
  .action-card.card-start-here .action-icon-box {
    transition: transform 0.2s ease;
  }
  
  .action-card.card-start-here:hover .action-icon-box {
    transform: scale(1.05);
  }


  #eventBuilderModule {
  z-index: 30000 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: var(--bg-light) !important;
}



  /* Featured Toolkit Button - Eye-catching Style */
  .featured-toolkit {
    --featured-color: #9333ea;
    border-left: 4px solid #9333ea;
    background: linear-gradient(135deg, #faf5ff 0%, #ffffff 100%) !important;
    border: 2px solid #e9d5ff;
  }
  
  .featured-toolkit .featured-icon {
    background: linear-gradient(135deg, #9333ea, #a855f7) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
  }
  
  .featured-toolkit .featured-label {
    color: #5b21b6 !important;
  }
  
  .featured-toolkit .featured-desc {
    color: #7c3aed !important;
  }
  
  .featured-toolkit:hover {
    border-color: #9333ea !important;
    box-shadow: 0 12px 28px -8px rgba(147, 51, 234, 0.4) !important;
    transform: translateY(-4px);
  }
  
  .featured-toolkit:hover .featured-arrow {
    background: linear-gradient(135deg, #9333ea, #a855f7) !important;
    transform: translateX(4px);
  }
  
  .featured-toolkit .featured-arrow {
    background: #f3e8ff;
    color: #9333ea;
  }



    /* Force Master House Config Modal to Full Screen on ALL Devices */
    #houseManagerModalStandalone {
      align-items: flex-start !important;
      background: rgba(0,0,0,0.85) !important;
    }
    
    #houseManagerModalStandalone > div {
      width: 100vw !important;
      height: 100vh !important;
      max-width: none !important;
      max-height: none !important;
      border-radius: 0 !important;
      margin: 0 !important;
      padding: 0 !important;
      display: flex !important;
      flex-direction: column !important;
    }
    
    /* Fix house settings list layout on mobile */
    @media (max-width: 1370px) {
      #houseSettingsListStandalone {
        padding: 16px !important;
        gap: 16px !important;
      }
      
      #houseSettingsListStandalone > div {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        padding: 16px !important;
        position: relative;
      }
      
      #houseSettingsListStandalone .btn-danger {
        position: absolute !important;
        top: 12px !important;
        right: 12px !important;
        width: 36px !important;
        height: 36px !important;
      }
      
      /* Fix emoji and color picker layout */
      #houseSettingsListStandalone > div > div:first-child {
        flex-direction: row !important;
        justify-content: center !important;
        gap: 16px !important;
      }
      
      /* Make inputs full width */
      #houseSettingsListStandalone input.form-control {
        width: 100% !important;
        height: 44px !important;
      }
      
      /* Fix header buttons layout */
      #houseManagerModalStandalone > div > div:first-child + div {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
        padding: 12px !important;
      }
      
      #houseManagerModalStandalone .btn {
        white-space: nowrap !important;
        font-size: 12px !important;
        padding: 10px 4px !important;
      }
    }




    #houseMasterToolkitsModal .house-expanded-content {
      width: 90vw;
      max-width: 1200px;
      height: 90vh;
      max-height: 90vh;
      overflow-y: auto;
      background: #ffffff;
      border-radius: 24px;
      padding: 60px 30px 30px 30px !important; /* Increased top padding to clear the X button */
      position: relative;
    }
    
    /* Ensure the close button has proper z-index and spacing */
    #houseMasterToolkitsModal .house-expanded-close {
      position: absolute !important;
      top: 15px !important;
      right: 15px !important;
      z-index: 100 !important;
      background: #f1f5f9 !important;
      border: none !important;
      border-radius: 50% !important;
      width: 36px !important;
      height: 36px !important;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      cursor: pointer !important;
      box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
      transition: all 0.2s ease !important;
    }
    
    #houseMasterToolkitsModal .house-expanded-close:hover {
      background: #e2e8f0 !important;
      transform: scale(1.05) !important;
    }
    
    /* Fix for mobile/iPad to ensure content doesn't hide behind X */
    @media (max-width: 1370px) {
      #houseMasterToolkitsModal .house-expanded-content {
        padding: 70px 20px 20px 20px !important;
      }
      
      .toolkit-header-section {
        margin-top: 0 !important;
      }
    }




    /* Ant character gallery: desktop school administrators only. */
    #viewClassAntCharactersBtn {
      display: none !important;
    }

    @media (min-width: 1371px) {
      body.trackedu-license-admin #viewClassAntCharactersBtn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        gap: 8px;
        height: 38px;
        min-height: 38px;
        width: auto;
        min-width: 0;
        padding: 0 14px;
        border: 1px solid #86efac;
        border-radius: 8px;
        background: #f0fdf4;
        color: #166534;
        font-family: inherit;
        font-size: 12px;
        font-weight: 800;
        line-height: 1;
        white-space: nowrap;
        box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
        cursor: pointer;
      }

      body.trackedu-license-admin #viewClassAntCharactersBtn:hover {
        background: #dcfce7;
        border-color: #4ade80;
      }

      body.house-display-dark.trackedu-license-admin #viewClassAntCharactersBtn {
        background: #123e30;
        color: #bbf7d0;
        border-color: #166534;
      }
    }

    /* Select Button - Works on ALL devices with fixed width */
#globalSelectToggle {
  height: 38px;
  width: 110px;
  min-width: 110px;
  max-width: 110px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  border: none;
  color: white;
  background: #3b82f6;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}



    .reset-center-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 30000;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.3s ease, opacity 0.3s ease;
}

.reset-center-modal.active {
  visibility: visible;
  opacity: 1;
}

.reset-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.reset-modal-container {
  position: relative;
  width: 90%;
  max-width: 550px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 32px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reset-center-modal.active .reset-modal-container {
  transform: scale(1);
}

/* Header Styles */
.reset-modal-header {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  padding: 28px 24px;
  text-align: center;
  position: relative;
  color: white;
}

.reset-header-icon {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
  backdrop-filter: blur(4px);
}

.reset-header-title {
  font-family: 'Fredoka One', cursive;
  font-size: 28px;
  margin: 0 0 4px 0;
  letter-spacing: -0.5px;
  font-weight: 700;
}

.reset-header-subtitle {
  font-size: 13px;
  margin: 0;
  opacity: 0.9;
  font-weight: 500;
}

.reset-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.reset-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* Body Styles */
.reset-modal-body {
  padding: 24px;
}

/* Option Items */
.reset-options-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.reset-option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
  cursor: pointer;
}

.reset-option-item:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transform: translateX(4px);
}

.reset-option-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.reset-option-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.reset-option-text {
  flex: 1;
}

.reset-option-title {
  font-weight: 800;
  color: #1e293b;
  font-size: 15px;
  margin-bottom: 2px;
}

.reset-option-desc {
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
}

.reset-option-all {
  background: linear-gradient(135deg, #fff1f0, #ffffff);
  border-color: #fecaca;
}

.reset-option-all .reset-option-title {
  color: #dc2626;
}

/* Divider */
.reset-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
  margin: 8px 0;
}

/* Toggle Switch */
.reset-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 26px;
  flex-shrink: 0;
}

.reset-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.reset-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.3s;
  border-radius: 34px;
}

.reset-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

input:checked + .reset-slider {
  background-color: #ef4444;
}

input:checked + .reset-slider:before {
  transform: translateX(26px);
}

.reset-slider-danger {
  background-color: #fecaca;
}

input:checked + .reset-slider-danger {
  background-color: #dc2626;
}

/* Warning Note */
.reset-warning-note {
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: #92400e;
  font-weight: 600;
}

.reset-warning-note i {
  font-size: 16px;
  color: #f59e0b;
  flex-shrink: 0;
}

/* Footer */
.reset-modal-footer {
  display: flex;
  gap: 12px;
  padding: 20px 24px 24px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.reset-btn {
  flex: 1;
  padding: 14px 20px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.reset-btn-cancel {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.reset-btn-cancel:hover {
  background: #e2e8f0;
  transform: translateY(-2px);
}

.reset-btn-execute {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.reset-btn-execute:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

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

/* Mobile Responsive */
@media (max-width: 780px) {
  .reset-modal-container {
    width: 95%;
    border-radius: 24px;
  }
  
  .reset-modal-header {
    padding: 24px 20px;
  }
  
  .reset-header-icon {
    width: 48px;
    height: 48px;
    font-size: 24px;
    margin-bottom: 12px;
  }
  
  .reset-header-title {
    font-size: 24px;
  }
  
  .reset-modal-body {
    padding: 20px;
  }
  
  .reset-option-item {
    padding: 10px 14px;
  }
  
  .reset-option-icon {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }
  
  .reset-option-title {
    font-size: 14px;
  }
  
  .reset-option-desc {
    font-size: 10px;
  }
  
  .reset-modal-footer {
    padding: 16px 20px 20px;
  }
  
  .reset-btn {
    padding: 12px 16px;
    font-size: 13px;
  }
}

/* Animation Keyframes */
@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Style for clicked/active state */
.reset-option-item.selected {
  background: linear-gradient(135deg, #fef2f2, #ffffff);
  border-color: #fecaca;
}

.reset-option-item input:focus + .reset-slider {
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* Disabled state for all options when "All Features" is checked */
.reset-option-item.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.reset-option-item.disabled .reset-switch {
  pointer-events: none;
}



/* --- PROFESSIONAL PWA SPLASH SCREEN CSS --- */
#pwa-splash-screen {
    position: fixed;
    inset: 0;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s;
  }

  #pwa-splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
  }

  .splash-icon {
    width: 115px; /* Slightly larger looks better as a circle */
    height: 115px;
    margin-bottom: 20px;
    border-radius: 50%; /* THE FIX: Makes it a perfect circle */
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
    border: 4px solid #ffffff; /* Adds a clean white rim */
    animation: splashBounce 2.5s infinite cubic-bezier(0.28, 0.84, 0.42, 1);
    object-fit: cover; /* Ensures the image fills the circle cleanly */
    background: #ffffff;
  }

  /* ClassDojo style chunky main branding */
  

  .splash-brand-title .text-track { color: #0f172a; }
  .splash-brand-title .text-edu { color: #10b981; }

  .splash-brand-title {
  font-family: 'Fredoka One', sans-serif !important;
  font-size: 56px;
  line-height: 1.1;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.splash-app-title {
  font-family: 'Inter', sans-serif !important;
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.splash-subtitle {
  font-family: 'Inter', sans-serif !important;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 30px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

  .splash-loader {
    margin-top: 50px;
    width: 60px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
  }

  .splash-loader::after {
    content: '';
    position: absolute;
    left: -50%;
    top: 0;
    height: 100%;
    width: 50%;
    background: #10b981;
    border-radius: 6px;
    animation: splashLoad 1.2s ease-in-out infinite;
  }

  @keyframes splashBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
  }

  @keyframes splashLoad {
    0% { left: -50%; }
    100% { left: 100%; }
  }


/* --- AUTHENTICATION LOGIN SCREEN --- */
#auth-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000000; /* Highest z-index to cover absolutely everything */
    transition: opacity 0.5s ease;
  }

  .auth-card {
    background: white;
    padding: 40px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  }

  .auth-logo {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  }

  .auth-title {
    font-family: 'Fredoka One', cursive, sans-serif;
    font-size: 28px;
    color: #1e293b;
    margin: 0 0 10px 0;
  }

  .auth-subtitle {
    color: #64748b;
    font-size: 15px;
    margin-bottom: 30px;
    line-height: 1.5;
  }

  .google-sign-in-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    background: white;
    color: #334155;
    border: 2px solid #e2e8f0;
    padding: 14px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  }

  .google-sign-in-btn:hover {
    border-color: #1e293b;
    background: #1e293b;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(15,23,42,.18);
  }

  .google-icon {
    width: 24px;
    height: 24px;
  }


  /* FORCE STUDENT MODAL CONTENT TO STAY WHITE */
#studentModalContent {
  background-color: #ffffff !important;
}

#studentModalContent .house-expanded-content {
  background-color: #ffffff !important;
  color: #1e293b !important;
}









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


/* Show on Desktop (>1100px), Hide on Mobile & iPad (≤1100px) */
@media (max-width: 1100px) {
  #headerUserProfile {
    display: none !important;
  }
}

@media (min-width: 1101px) {
  #headerUserProfile {
    display: flex !important;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    padding: 6px 16px;
    border-radius: 30px;
    border: 2px solid #e2e8f0;
    margin-right: 8px;
  }
}





/* Class Passcode Badge Animation */
.class-passcode-badge {
  transition: all 0.2s ease;
}
.class-passcode-badge:hover {
  background: #10b981 !important;
  color: white !important;
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}
.class-passcode-badge:active {
  transform: scale(0.98);
}

/* Copy success animation */
@keyframes copyFlash {
  0% { background: #10b981; color: white; transform: scale(1); }
  50% { background: #059669; color: white; transform: scale(1.05); }
  100% { background: #d1fae5; color: #065f46; transform: scale(1); }
}
.copy-success {
  animation: copyFlash 0.4s ease-out;
}



/* Passcode badge styling */
#classPasscodeBadge {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
}

/* Regenerate button hover effect */
#regeneratePasscodeBtn {
  transition: all 0.2s ease;
}

#regeneratePasscodeBtn:hover {
  transform: scale(1.1);
}

#regeneratePasscodeBtn:active {
  transform: scale(0.95);
}


#expandedHouseView .house-expanded-content {
  touch-action: pan-y pinch-zoom; /* Allow vertical scroll but capture horizontal swipes */
  user-select: none; /* Prevent text selection during swipe */
}


/* Desktop: House detail modal fills the entire screen */
@media (min-width: 1371px) {

  #expandedHouseView {
    align-items: flex-start !important;
    justify-content: flex-start !important;
    padding: 0 !important;
  }

  #expandedHouseView .house-expanded-content {
    width: 100vw !important;
    max-width: 100vw !important;

    height: 100vh !important;
    max-height: 100vh !important;

    margin: 0 !important;
    border-radius: 0 !important;

    overflow-y: auto !important;
  }
}

#expandedHouseView .house-expanded-content:active {
  cursor: grabbing;
}

.swipe-hint {
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 0.6;
    transform: translateY(0);
  }
}

/* Mobile optimization for swipe area */
@media (max-width: 780px) {
  #expandedHouseView .house-expanded-content {
    padding: 20px 15px !important;
  }
  
  .swipe-hint div {
    font-size: 10px !important;
    gap: 12px !important;
  }
}



/* Bulk action buttons styling */
.btn-bulk.house-bulk {
  background: #8b5cf6 !important;
  color: white !important;
  border: none !important;
  width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  border-radius: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.btn-bulk.house-bulk:hover {
  background: #7c3aed !important;
  transform: scale(1.02);
}

.btn-bulk.status-bulk {
  background: #ef4444 !important;
  color: white !important;
  border: none !important;
  width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.btn-bulk.status-bulk:hover {
  background: #dc2626 !important;
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.4);
}

.btn-bulk.status-bulk.restore-mode {
  background: #10b981 !important;
}

.btn-bulk.status-bulk.restore-mode:hover {
  background: #059669 !important;
}



/* --- MOBILE ONLY: KEEP TITLE AND BUTTONS ON SAME ROW --- */
@media (max-width: 767px) {
      .students-header-row1 {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: wrap !important;
        gap: 12px !important;
        width: 100% !important;
        margin-bottom: 12px !important;
      }

      .students-header-title {
        margin-bottom: 0 !important;
        flex-shrink: 0 !important;
      }

      .students-header-actions {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        flex: 1 !important;
        justify-content: flex-start !important;
        padding-top: 4px !important;
        padding-bottom: 8px !important;
        gap: 8px !important;
      }
      
      .students-header-actions::-webkit-scrollbar {
        display: none !important; 
      }

      .students-header-actions .btn {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
      }

    }


    .students-header-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  color: #0f172a;
  font-weight: 800;
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .students-header-title {
    font-size: 18px !important;
  }
}



/* Custom button animation */
[onclick*="setAwardPreset('custom')"]:active {
    transform: scale(0.95) !important;
    background: #e2e8f0 !important;
}

/* Reason chip selected state */
.reason-chip.selected {
    background: #1e40af !important;
    color: white !important;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(30, 64, 175, 0.3);
}

/* House orb selected state animation */
.house-orb.selected {
    animation: orbPulse 0.3s ease-out;
}

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




/* Quick Action Button Selected State */
.quick-action-btn.selected {
    border: 2px solid #f59e0b !important;
    transform: scale(1.02) !important;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3) !important;
}

/* Reason Chip Selected State - Navy Blue */
.reason-chip.selected {
    background: #1e40af !important;
    color: white !important;
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4) !important;
    border-color: #1e40af !important;
}

/* Quick Action Button Hover Effect */
.quick-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}




/* Desktop Express Award: compact two-column workspace. iPad and mobile unchanged. */
#tedAwardStepsLeft,
#tedAwardStepsRight { display: contents; }

@media (min-width: 1371px) {
  #awardHousePointsModal #tedAwardStepsWorkspace {
    display: grid !important;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    align-content: start;
    gap: 14px;
    padding: 18px 22px 106px !important;
    overflow-x: hidden;
    overflow-y: auto;
  }

  #awardHousePointsModal #tedAwardStepsLeft,
  #awardHousePointsModal #tedAwardStepsRight {
    display: flex !important;
    flex-direction: column;
    gap: 14px;
    align-self: start;
    min-width: 0;
  }

  #awardHousePointsModal #tedAwardStepsLeft > div,
  #awardHousePointsModal #tedAwardStepsRight > div {
    min-width: 0;
    margin-bottom: 0 !important;
    padding: 15px !important;
    background: var(--school-surface) !important;
    border: 1px solid var(--school-border);
    border-left-width: 4px !important;
    border-radius: 14px !important;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.035);
  }
  #awardHousePointsModal #tedAwardStepsLeft > div:first-child {
    border-left-color: var(--school-primary) !important;
  }
  #awardHousePointsModal #tedAwardStepsLeft > div:nth-child(2) {
    border-left-color: #10b981 !important;
  }
  #awardHousePointsModal #tedAwardStepsRight > div:first-child {
    border-left-color: #8b5cf6 !important;
  }
  #awardHousePointsModal #tedAwardStepsRight > div:nth-child(2) {
    border-left-color: #f59e0b !important;
  }

  #awardHousePointsModal #awardClassSearchResults {
    max-height: 265px !important;
  }
  #awardHousePointsModal #awardPointsAmountInput {
    width: 110px !important;
    font-size: 23px !important;
  }

  /* Larger desktop point adjustment buttons */
  @media (min-width: 1371px) {

    #awardHousePointsModal
    #allHousePositivePointInput > div > button {
      display: inline-flex !important;
      align-items: center !important;
      justify-content: center !important;

      width: 48px !important;
      min-width: 48px !important;
      height: 48px !important;
      min-height: 48px !important;

      padding: 0 !important;
      border: 1px solid #cbd5e1 !important;
      border-radius: 12px !important;

      background: #f1f5f9 !important;
      color: #1e293b !important;

      font-size: 16px !important;
      font-weight: 800 !important;
      line-height: 1 !important;

      flex: 0 0 48px !important;
      cursor: pointer;

      transition:
        background 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
    }

    #awardHousePointsModal
    #allHousePositivePointInput > div > button:hover:not(:disabled) {
      background: #dbeafe !important;
      border-color: #93c5fd !important;
      box-shadow: 0 2px 6px rgba(37, 99, 235, 0.12);
    }

    #awardHousePointsModal
    #allHousePositivePointInput > div > button:focus-visible {
      outline: 3px solid #93c5fd !important;
      outline-offset: 2px;
    }

    #awardHousePointsModal
    #allHousePositivePointInput > div > button:disabled {
      opacity: 0.45 !important;
      cursor: not-allowed;
    }

  }

  /* Existing live award preview, presented in a desktop bottom dock. */
  #awardHousePointsModal #awardModalContent::after {
    content: '';
    position: fixed;
    inset: auto 0 0 0;
    height: 80px;
    background: var(--school-surface);
    border-top: 1px solid var(--school-border);
    box-shadow: 0 -5px 18px rgba(15, 23, 42, 0.06);
    pointer-events: none;
    z-index: 8;
  }
  #awardHousePointsModal #awardModalHeader #housePointsDisplay {
    position: fixed !important;
    bottom: 17px !important;
    left: 22px !important;
    width: auto !important;
    max-width: calc(100vw - 254px);
    min-width: 0 !important;
    white-space: normal !important;
    background: var(--school-surface-soft) !important;
    z-index: 11;
  }
  #awardHousePointsModal #housePointsDisplay > div {
    flex-wrap: wrap !important;
    white-space: normal !important;
  }
  #awardHousePointsModal #awardPointsButton {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 9px;
    bottom: 15px !important;
    right: 22px !important;
    height: 50px !important;
    padding: 0 23px !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.18) !important;
  }
}

/* Express Award: desktop usability refinements */
@media (min-width: 1371px) {

  #awardHousePointsModal #tedAwardStepsRight {
    position: sticky;
    top: 0;
  }

  /* Many Houses, including longer names */
  #awardHousePointsModal #visualHouseSelector {
    max-height: 245px;
    overflow-y: auto;
    align-content: flex-start;
    padding: 4px;
    scrollbar-gutter: stable;
  }

  #awardHousePointsModal #visualHouseSelector .house-orb {
    width: 98px !important;
    flex: 0 0 98px;
    min-width: 0;
  }

  #awardHousePointsModal #visualHouseSelector .house-orb > div:last-child {
    white-space: normal !important;
    overflow-wrap: anywhere;
    line-height: 1.3;
    margin-top: 7px;
  }

  /* Long reasons and multiple reason chips */
  #awardHousePointsModal
  #awardReasonCategoryPanels
  .horizontal-scroll-container {
    flex-wrap: wrap !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    max-height: 180px;
    align-content: flex-start;
  }

  #awardHousePointsModal
  #awardReasonCategoryPanels
  .reason-chip {
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere;
    text-align: left;
    line-height: 1.4;
  }

  #awardHousePointsModal
  #awardReasonCategoryPanels
  .reason-chip span {
    flex-shrink: 0;
  }

  /* Class names and selected state */
  #awardHousePointsModal .award-class-result {
    min-width: 0;
    border: 1px solid transparent !important;
  }

  #awardHousePointsModal
  .award-class-result[aria-pressed="true"] {
    border-color: #2563eb !important;
    background: #eff6ff !important;
  }

  #awardHousePointsModal
  .award-class-result > div:first-child {
    min-width: 0;
    flex: 1;
    overflow-wrap: anywhere;
  }

  /* Incomplete awards cannot be submitted */
  #awardHousePointsModal #awardPointsButton:disabled {
    opacity: .48 !important;
    cursor: not-allowed !important;
    transform: none !important;
    pointer-events: none;
    box-shadow: none !important;
  }

  /* Normal award preview */
  #awardHousePointsModal
  #awardModalHeader #housePointsDisplay {
    max-width: calc(100vw - 260px) !important;
    max-height: 60px;
    overflow-y: auto;
    overflow-wrap: anywhere;
  }

  #awardHousePointsModal #housePointsDisplay > div {
    gap: 4px 7px !important;
  }

  /* Compact live progress in the desktop bottom bar */
  #awardHousePointsModal
  #awardModalHeader #housePointsDisplay.trackedu-bulk-progress {
    width: min(480px, calc(100vw - 300px)) !important;
    max-width: calc(100vw - 300px) !important;
    min-width: 0 !important;
    height: 58px !important;
    max-height: 58px !important;
    padding: 10px 15px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  #awardHousePointsModal
  #housePointsDisplay .trackedu-bulk-progress-inner {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  #awardHousePointsModal
  #housePointsDisplay .trackedu-bulk-progress-heading {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    margin-bottom: 9px;
    line-height: 16px;
    white-space: nowrap !important;
  }

  .trackedu-bulk-progress-heading strong {
    font-size: 12px;
    font-weight: 800;
    color: #1e293b;
  }

  .trackedu-bulk-progress-heading span {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
  }

  #awardHousePointsModal
  #housePointsDisplay .trackedu-bulk-progress-track {
    display: block !important;
    width: 100% !important;
    height: 7px;
    background: #dbe4f0;
    border-radius: 999px;
    overflow: hidden;
  }

  #awardHousePointsModal
  #housePointsDisplay .trackedu-bulk-progress-fill {
    display: block !important;
    height: 100%;
    border-radius: 999px;
    transition: width .3s ease;
  }

  body.house-display-dark .trackedu-bulk-progress-heading strong {
    color: #f8fafc;
  }

  body.house-display-dark .trackedu-bulk-progress-heading span {
    color: #cbd5e1;
  }
}

/* =====================================================
   ALL HOUSES AWARD: PREMIUM LIVE PROGRESS FOOTER
   ===================================================== */

@media (min-width: 1371px) {

  /* Full-size progress panel on the left */
  #awardHousePointsModal
  #awardModalHeader
  #housePointsDisplay.trackedu-bulk-progress {
    position: fixed !important;
    left: 24px !important;
    bottom: 11px !important;

    width: min(650px, calc(100vw - 370px)) !important;
    max-width: calc(100vw - 370px) !important;
    min-width: 0 !important;

    height: 60px !important;
    max-height: none !important;

    padding: 10px 18px !important;

    display: flex !important;
    align-items: center !important;

    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 12px !important;

    box-shadow: 0 2px 8px rgba(15, 23, 42, .06) !important;

    overflow: hidden !important;
    white-space: normal !important;
    opacity: 1 !important;

    z-index: 20 !important;
  }

  /* Remove inherited preview layout */
  #awardHousePointsModal
  #housePointsDisplay.trackedu-bulk-progress
  .trackedu-bulk-progress-inner {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #0f172a !important;
    white-space: normal !important;
  }

  /* Heading, student count and percentage */
  #awardHousePointsModal
  #housePointsDisplay.trackedu-bulk-progress
  .trackedu-bulk-progress-heading {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;

    width: 100% !important;
    gap: 16px !important;

    margin: 0 0 10px !important;
    padding: 0 !important;

    color: #0f172a !important;
    line-height: 16px !important;
    white-space: nowrap !important;
  }

  #awardHousePointsModal
  #housePointsDisplay.trackedu-bulk-progress
  .trackedu-bulk-progress-heading strong:first-child {
    color: #0f172a !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    opacity: 1 !important;
  }

  #awardHousePointsModal
  #housePointsDisplay.trackedu-bulk-progress
  .trackedu-bulk-progress-heading span {
    color: #475569 !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    opacity: 1 !important;

    margin-left: auto !important;
  }

  #awardHousePointsModal
  #housePointsDisplay.trackedu-bulk-progress
  .trackedu-bulk-progress-heading strong:last-child {
    color: #2563eb;
    font-size: 15px !important;
    font-weight: 900 !important;
    opacity: 1 !important;
  }

  /* Wider, clearly visible progress bar */
  #awardHousePointsModal
  #housePointsDisplay.trackedu-bulk-progress
  .trackedu-bulk-progress-track {
    display: block !important;
    width: 100% !important;
    height: 10px !important;

    background: #e2e8f0 !important;
    border-radius: 999px !important;

    overflow: hidden !important;
    margin: 0 !important;
  }

  #awardHousePointsModal
  #housePointsDisplay.trackedu-bulk-progress
  .trackedu-bulk-progress-fill {
    display: block !important;
    height: 100% !important;
    border-radius: 999px !important;

    transition: width .35s ease !important;
  }

  /* Keep the Awarding button readable while disabled */
  #awardHousePointsModal
  #awardPointsButton.loading:disabled {
    opacity: 1 !important;

    background: #2563eb !important;
    color: #ffffff !important;

    box-shadow: none !important;

    pointer-events: none !important;
    cursor: progress !important;
  }

  /* Avoid a second spinner being generated by the button CSS */
  #awardHousePointsModal
  #awardPointsButton.loading::after {
    display: none !important;
  }
}

/* Dark mode */
body.house-display-dark
#awardHousePointsModal
#housePointsDisplay.trackedu-bulk-progress {
  background: #1e293b !important;
  border-color: #475569 !important;
}

body.house-display-dark
#awardHousePointsModal
.trackedu-bulk-progress-heading strong:first-child {
  color: #f8fafc !important;
}

body.house-display-dark
#awardHousePointsModal
.trackedu-bulk-progress-heading span {
  color: #cbd5e1 !important;
}

/* Express Award: Manage Reasons is desktop only */
@media (max-width: 1370px) {

  #awardModalManageReasonsBtn {
    display: none !important;
  }

}


/* Express Award Modal - Full Screen on ALL Devices */
#awardHousePointsModal {
  align-items: flex-start !important;
  justify-content: flex-start !important;
  background: rgba(0, 0, 0, 0.65) !important;
}

#awardHousePointsModal .house-expanded-content {
  width: 100vw !important;
  height: 100vh !important;

  max-width: none !important;
  max-height: none !important;

  border-radius: 0 !important;

  margin: 0 !important;
  padding: 0 !important;

  overflow: hidden !important;

  display: flex !important;
  flex-direction: column !important;

  background:
    var(--school-canvas) !important;
}

/* Desktop: Also full width/height - NO SCROLLING NEEDED */
@media (min-width: 1024px) {
  #awardHousePointsModal .house-expanded-content {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    top: 0 !important;
    transform: none !important;
    position: fixed !important;
  }
  
  #awardHousePointsModal {
    align-items: flex-start !important;
    justify-content: flex-start !important;
  }
}

/* For tablets and smaller desktops, ensure content fits */
@media (min-width: 768px) and (max-width: 1023px) {
  #awardHousePointsModal .house-expanded-content {
    padding: 0 !important;
  }
  
  #awardHousePointsModal .scrollable-content {
    padding: 20px 24px 24px 24px !important;
  }
}



/* Force remove all top padding/margin from Express Award modal */
#awardHousePointsModal .house-expanded-content {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

#awardHousePointsModal .house-expanded-content > div:first-child {
  padding-top: 24px !important;
  margin-top: 0 !important;
}


/* Dynamic color transition for modal */
#awardModalContent {
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* House-specific header styles (applied via JS) */
#awardModalHeader {
  border-bottom: 3px solid #f1f5f9;
  transition: all 0.3s ease;
}

/* When house selected, the border becomes thicker and colored */
#awardModalHeader.house-selected {
  border-bottom: 3px solid var(--house-color, #1e40af) !important;
}

#awardModalTitle.house-selected {
  color: var(--house-color) !important;
}

#awardModalDescription.house-selected {
  color: var(--house-color-dark) !important;
}

#awardPreview.house-selected {
  background: var(--house-color-ultralight) !important;
  border-color: var(--house-color) !important;
  color: var(--house-color-dark) !important;
}


/* Mobile: Keep title and description stacked */
@media (max-width: 780px) {
  #awardModalHeader > div:first-child > div:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  #awardModalDescription {
    margin-top: 0 !important;
  }
}

/* --- REASON SELECTOR MODAL --- */
#reasonSelectorModal {
      align-items: center !important;
      justify-content: center !important;
    }

    #reasonSelectorModal .house-expanded-content {
      width: 90% !important;
      max-width: 750px !important;
      height: auto !important;
      min-height: 480px !important;
      max-height: 90vh !important;
      border-radius: 24px !important;
      margin: 0 auto !important;
      padding: 40px 30px 30px 30px !important;
    }

    #modalReasonChips {
      min-height: 250px !important;
    }


    /* Selected-student distribution controls are available on all devices */


    /* ==========================================
       REASON SELECTOR - DESKTOP
       Desktop only. iPad/mobile remain unchanged.
       ========================================== */
    @media (min-width: 1371px) {

      #reasonSelectorModal .house-expanded-content {
        width: 100vw !important;
        max-width: 100vw !important;

        height: 100vh !important;
        min-height: 100vh !important;
        max-height: 100vh !important;

        margin: 0 !important;

        padding: 28px 34px 34px !important;

        border-radius: 0 !important;

        display: grid !important;

        grid-template-columns:
          minmax(0, 0.72fr)
          minmax(0, 1.28fr) !important;

        grid-auto-rows:
          max-content !important;

        gap: 14px 18px !important;

        align-items: start !important;
        align-content: start !important;

        overflow-x: hidden !important;
        overflow-y: auto !important;

        background: #ffffff !important;

        border: none !important;

        box-shadow: none !important;
      }


      /* Modal title */
      #reasonSelectorModal
      .house-expanded-content
      > h3 {
        grid-column: 1 / -1 !important;

        margin:
          0
          0
          2px !important;

        padding:
          0
          54px
          18px
          0 !important;

        border-bottom:
          1px solid
          #e2e8f0 !important;

        font-size: 22px !important;
      }


      /* ==========================================
   STEP 1 - AWARD TARGET
   ========================================== */

      #reasonSelectorModal
      #reasonAwardControls {
        grid-column:
          1 / -1 !important;

        width:
          100% !important;

        max-width:
          760px !important;

        justify-self:
          center !important;

        margin:
          0 auto !important;

        padding:
          12px 14px !important;

        box-sizing:
          border-box !important;
      }


      /* ==========================================
         STEP 2 - QUICK REASONS
         ========================================== */

      #reasonSelectorModal
      #reasonQuickSelectionSection {
        grid-column:
          1 / -1 !important;

        width:
          100% !important;

        margin:
          2px 0 0 !important;

        padding:
          0 !important;
      }


      #reasonSelectorModal
      #reasonQuickSelectionSection
      > .form-label {
        margin-bottom:
          10px !important;

        padding:
          2px
          2px
          0 !important;

        font-size:
          12px !important;

        color:
          #334155 !important;
      }


      #reasonSelectorModal
      #reasonQuickSelectionSection
      > .form-label
      > span {
        font-size:
          10px !important;

        color:
          #94a3b8 !important;
      }


      /* ==========================================
         REASON CARD GRID
         Honesty      | Belonging
         Teamwork     | My Reasons
         ========================================== */

      #reasonSelectorModal
      #reasonQuickSelectionSection {
        display: block !important;

        width: 100% !important;
      }


      #reasonSelectorModal
      #reasonCardsGrid {
        display: grid !important;

        grid-template-columns:
          repeat(
            2,
            minmax(0, 1fr)
          ) !important;

        gap: 12px !important;

        width: 100% !important;

        align-items: stretch !important;
      }


      #reasonSelectorModal
      #modalReasonChips {
        display: contents !important;
      }


      /* Honesty */
      #reasonSelectorModal
      #modalReasonChips
      > div:nth-child(1) {
        grid-column: 1 !important;
        grid-row: 1 !important;
      }


      /* Belonging */
      #reasonSelectorModal
      #modalReasonChips
      > div:nth-child(2) {
        grid-column: 2 !important;
        grid-row: 1 !important;
      }


      /* Teamwork */
      #reasonSelectorModal
      #modalReasonChips
      > div:nth-child(3) {
        grid-column: 1 !important;
        grid-row: 2 !important;
      }


      /* My Reasons */
      #reasonSelectorModal
      #reasonCardsGrid
      #teacherSavedReasonsSection {
        grid-column: 2 !important;
        grid-row: 2 !important;

        width: 100% !important;
        min-width: 0 !important;

        height: 100% !important;
        min-height: 0 !important;

        margin: 0 !important;

        padding: 16px !important;

        align-self: stretch !important;

        box-sizing: border-box !important;

        background: #fffbeb !important;

        border:
          1px solid
          #fde68a !important;

        border-radius: 14px !important;
      }


      @media (max-width: 900px) {

        #reasonSelectorModal
        #reasonCardsGrid {
          grid-template-columns:
            1fr !important;
        }


        #reasonSelectorModal
        #modalReasonChips
        > div:nth-child(1),
        #reasonSelectorModal
        #modalReasonChips
        > div:nth-child(2),
        #reasonSelectorModal
        #modalReasonChips
        > div:nth-child(3),
        #reasonSelectorModal
        #reasonCardsGrid
        #teacherSavedReasonsSection {
          grid-column:
            1 !important;

          grid-row:
            auto !important;
        }

      }


      /* Each configured school category */
      #reasonSelectorModal
      #modalReasonChips
      > div {
        min-width: 0 !important;

        margin: 0 !important;

        padding: 13px !important;

        background: #f8fafc !important;

        border:
          1px solid
          #e2e8f0 !important;

        border-radius: 14px !important;

        box-shadow:
          0 2px 6px
          rgba(15, 23, 42, 0.035) !important;
      }


      /* Category heading */
      #reasonSelectorModal
      #modalReasonChips
      > div
      > div:first-child {
        min-height: 25px !important;

        margin-bottom: 9px !important;

        padding-bottom: 8px !important;

        border-bottom:
          1px solid
          #e2e8f0 !important;

        font-size: 14px !important;
        font-weight: 800 !important;

        letter-spacing: 0 !important;
      }


      /* Reasons within each category */
      #reasonSelectorModal
      #modalReasonChips
      > div
      > div:last-child {
        display: flex !important;

        flex-direction: column !important;
        flex-wrap: nowrap !important;

        gap: 6px !important;

        width: 100% !important;
      }


      /* Individual school reason */
            #reasonSelectorModal
      #modalReasonChips
      .reason-chip {
        display: flex !important;

        align-items: center !important;
        justify-content: space-between !important;

        width: 100% !important;
        min-width: 0 !important;

        min-height: 38px !important;
        height: auto !important;

        margin: 0 !important;

        padding:
          8px
          10px !important;

        display: flex !important;

        align-items: center !important;
        justify-content: space-between !important;

        gap: 8px !important;

        background: #ffffff !important;

        border:
          1px solid
          #dbe5ef !important;

        border-radius: 9px !important;

        color: #334155 !important;

        font-size: 13px !important;
        font-weight: 600 !important;

        line-height: 1.4 !important;

        white-space: normal !important;

        text-align: left !important;

        box-shadow: none !important;

        transition:
          border-color 0.16s ease,
          background 0.16s ease,
          transform 0.16s ease !important;
      }


      #reasonSelectorModal
      #modalReasonChips
      .reason-chip:hover {
        background:
          var(--school-surface-soft) !important;

        border-color:
          var(--school-primary) !important;

        transform:
          translateY(-1px) !important;
      }


      #reasonSelectorModal
      #modalReasonChips
      .reason-chip
      > span {
        flex:
          0
          0
          auto !important;

        margin-left: auto !important;

        padding:
          3px
          7px !important;

        border-radius: 999px !important;

        font-size: 11px !important;
        font-weight: 800 !important;
      }


      /* My Reasons positioning is controlled
         by #reasonCardsGrid above. */


      #reasonSelectorModal
      #teacherSavedReasonsSection
      > div:first-child {
        margin-bottom: 3px !important;
      }


      #reasonSelectorModal
      #teacherSavedReasonsSection
      > div:first-child::after {
        content: none !important;
        display: none !important;
      }


      #reasonSelectorModal
      #teacherSavedReasonsList {
        margin-top: 12px !important;

        gap: 7px !important;
      }


      /*
       * Normal My Reasons award shortcuts only.
       * Do not target edit/delete controls nested
       * inside an edit-mode row.
       */
      #reasonSelectorModal
      #teacherSavedReasonsList
      > .reason-chip,
      #reasonSelectorModal
      #teacherSavedReasonsList
      > button {
        min-height: 34px !important;

        padding:
          7px
          10px !important;

        font-size: 12px !important;
        font-weight: 650 !important;

        border-radius: 999px !important;
      }


      /* ==========================================
         CUSTOM REASON
         ========================================== */
      #reasonSelectorModal
      #reasonCustomSection {
        grid-column: 2 !important;

        width: 100% !important;
        min-width: 0 !important;

        align-self: start !important;

        margin: 0 !important;

        padding: 16px !important;

        background: #f8fafc !important;

        border:
          1px solid
          #e2e8f0 !important;

        border-radius: 14px !important;

        box-sizing: border-box !important;
      }


      #reasonSelectorModal
      .house-expanded-content
      > .form-group:last-of-type
      > .form-label {
        margin-bottom: 12px !important;

        color: #0f172a !important;
      }


      #reasonSelectorModal
      .custom-reason-grid {
        display: grid !important;

        grid-template-columns:
          minmax(0, 1fr)
          minmax(160px, 190px)
          86px !important;

        gap: 9px !important;

        align-items: center !important;
      }


      #reasonSelectorModal
      #modalCustomReason,
      #reasonSelectorModal
      #modalCustomCategory,
      #reasonSelectorModal
      #modalCustomPoints {
        height: 42px !important;

        min-width: 0 !important;

        border-radius: 9px !important;

        background: #ffffff !important;

        font-size: 14px !important;
        font-weight: 500 !important;
      }


      #reasonSelectorModal
      #modalCustomReason {
        width: 100% !important;
      }


      #reasonSelectorModal
      #modalCustomCategory {
        width: 100% !important;
      }


      #reasonSelectorModal
      #modalCustomPoints {
        width: 86px !important;

        text-align: center !important;

        font-weight: 800 !important;
      }


      /* Desktop custom Award button */
      #reasonSelectorModal
      .house-expanded-content
      > .form-group:last-of-type
      .btn {
        display: flex !important;

        width: 100% !important;
        max-width: 260px !important;

        min-width: 180px !important;
        min-height: 52px !important;

        margin:
          16px
          0
          0
          auto !important;

        padding:
          13px
          24px !important;

        align-items: center !important;
        justify-content: center !important;

        border-radius: 12px !important;

        font-size: 14px !important;
        font-weight: 800 !important;

        gap: 8px !important;
      }


      /* Desktop close button */
      #reasonSelectorModal
      .house-expanded-close {
        position: fixed !important;

        top: 24px !important;
        right: 30px !important;
        left: auto !important;

        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;

        margin: 0 !important;
        padding: 0 !important;

        display: flex !important;
        align-items: center !important;
        justify-content: center !important;

        border-radius: 50% !important;

        font-size: 22px !important;
        line-height: 1 !important;

        z-index: 20000 !important;
      }

    }


    @media (max-width: 1370px) {
      #reasonSelectorModal .house-expanded-content {
        /* Strictly kills the 90px bottom padding bug on iPads */
        padding: 50px 24px 24px 24px !important; 
      }
    }

    @media (max-width: 780px) {
      #reasonSelectorModal .house-expanded-content {
        width: 95% !important;
        padding: 45px 20px 20px 20px !important;
        min-height: auto !important; 
      }
      
      /* Force chips to stack nicely on mobile */
      #modalReasonChips {
        min-height: auto !important;
        flex-direction: column !important; 
        flex-wrap: nowrap !important;
        gap: 8px !important;
      }

      /* Allow text to wrap onto 2 lines and format as full-width buttons */
      #modalReasonChips .reason-chip {
        width: 100% !important;
        white-space: normal !important;
        height: auto !important;
        text-align: left !important;
        justify-content: space-between !important;
        padding: 10px 14px !important;
        line-height: 1.4 !important;
        font-size: 13px !important;
      }

      /* Ensure the point badge never gets squished by the wrapping text */
      #modalReasonChips .reason-chip span {
        flex-shrink: 0 !important;
        font-size: 11px !important;
        padding: 3px 8px !important;
        margin-left: 8px !important;
      }
    }



    /* --- FIX: Express Award Reason Chips - Horizontal Scroll on ALL Devices --- */
@media (max-width: 780px) {
  /* Keep horizontal scrolling - same as desktop/iPad */
  #academicReasons,
  #pastoralReasons,
  #leadershipReasons,
  #awardQuickReasons {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 8px !important;
    padding-bottom: 8px !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Reason chips stay as inline buttons, not full width */
  #awardHousePointsModal .reason-chip {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    width: auto !important;
    text-align: center !important;
    justify-content: center !important;
    padding: 8px 16px !important;
    font-size: 12px !important;
  }

  /* Point badge stays inline */
  #awardHousePointsModal .reason-chip span {
    display: inline-block !important;
    margin-left: 8px !important;
    flex-shrink: 0 !important;
  }
  
  /* Quick action presets also horizontal */
  .quick-action-btn {
    flex: 0 0 auto !important;
    width: auto !important;
    margin-bottom: 0 !important;
  }
}

/* ==========================================
   🔧 FIX: Express Award Modal - Bottom Button Visibility
   ========================================== */
@media (max-width: 1370px) {
  /* Ensure the modal content has proper bottom padding for scrolling */
  #awardHousePointsModal .house-expanded-content {
    padding-bottom: 30px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Add extra padding to the scrollable content area */
  #awardHousePointsModal .house-expanded-content > div:last-child,
  #awardHousePointsModal .house-expanded-content > div:last-child > div:last-child {
    padding-bottom: 30px !important;
  }
  
  /* Specifically target the Award Points button container */
  #awardHousePointsModal #awardPointsButton {
    margin-bottom: 20px !important;
  }
  
  /* Ensure the button is clearly visible at the bottom */
  #awardHousePointsModal .scrollable-content,
  #awardHousePointsModal > div:last-child {
    padding-bottom: 40px !important;
  }
}

/* Extra safe padding for smaller phones */
@media (max-width: 780px) {
  #awardHousePointsModal .house-expanded-content {
    padding-bottom: 90px !important;
  }
  
  #awardHousePointsModal #awardPointsButton {
    margin-bottom: 30px !important;
  }
}




    /* --- FIX: FULL SCREEN MODALS ON MOBILE (Express Award & Reason Selector) --- */
    @media (max-width: 780px) {
      /* 1. Force the modal overlay wrappers to snap to the absolute top-left */
      #reasonSelectorModal,
      #awardHousePointsModal {
        align-items: flex-start !important;
        justify-content: flex-start !important;
        padding: 0 !important;
      }

      /* 2. Force the content boxes to fill 100% of the screen, removing all curves and margins */
      #reasonSelectorModal .house-expanded-content,
      #awardHousePointsModal .house-expanded-content {
        width: 100vw !important;
        max-width: none !important;
        height: 100vh !important;
        min-height: 100vh !important;
        max-height: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
      }

      /* 3. Reason Selector: Needs top padding to prevent text from hitting the notch/close button */
      #reasonSelectorModal .house-expanded-content {
        padding: 60px 20px 20px 20px !important;
      }

      /* 4. Express Award: Keep 0 padding because it has a custom sticky header */
      #awardHousePointsModal .house-expanded-content {
        padding: 0 !important;
      }
      
      /* 5. Tweak the Express Award sticky header for mobile full-screen */
      #awardModalHeader {
        padding: 20px 20px 10px 20px !important;
      }
    }


    /* ==========================================
   ALL HOUSES AWARD - iPAD HEADER SPACING
   ========================================== */

@media (min-width: 781px) and (max-width: 1370px) {

  #awardHousePointsModal #awardModalHeader {
    position: sticky !important;
  }

  #awardHousePointsModal #awardModalHeader > div:first-child {
    position: relative !important;
    padding-right: 52px !important;
    gap: 14px !important;
    min-width: 0 !important;
  }

  #awardHousePointsModal #housePointsDisplay {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    white-space: normal !important;
  }

  #awardHousePointsModal #housePointsDisplay > div {
    flex-wrap: wrap !important;
    white-space: normal !important;
  }

  #awardHousePointsModal #awardModalHeader .house-expanded-close {
    position: absolute !important;
    top: 50% !important;
    right: 0 !important;
    transform: translateY(-50%) !important;

    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;

    flex-shrink: 0 !important;
    z-index: 20 !important;
  }

}

/* Mobile only: Hide Express Award description text */
@media (max-width: 780px) {
  #awardModalDescription {
    display: none !important;
  }
  
  /* Reorganize header layout for mobile */
  #awardModalHeader > div:first-child {
    flex-wrap: wrap !important;
    gap: 12px !important;
  }
  
  /* Mobile: keep the live award preview within the screen. */
  #awardHousePointsModal #housePointsDisplay {
    order: 3 !important;
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 10px 12px !important;
    margin-top: 8px !important;
    text-align: center !important;
    white-space: normal !important;
    overflow: hidden;
  }

  /* Override the inline nowrap styling generated by JavaScript. */
  #awardHousePointsModal #housePointsDisplay > div {
    display: flex !important;
    align-items: baseline !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 4px 6px !important;
    width: 100%;
    min-width: 0;
    white-space: normal !important;
  }

  /* Put the student count and House on a separate line. */
  #awardHousePointsModal #housePointsDisplay > div > span:last-child {
    flex: 0 0 100%;
    max-width: 100%;
    text-align: center;
    white-space: normal !important;
    overflow-wrap: anywhere;
    line-height: 1.4;
  }
  
  /* Ensure title stays on its own row */
  #awardModalHeader > div:first-child > div:first-child {
    width: auto !important;
    flex: 1 !important;
  }
  
  /* Close button stays in corner */
  .house-expanded-close {
    order: 2 !important;
  }
}



/* Authorized Emails - Mobile: Stack input above Add button */
@media (max-width: 768px) {
  .authorized-emails-input-wrapper {
    flex-direction: column !important;
    gap: 10px !important;
  }
  
  .authorized-emails-input-wrapper input {
    width: 100% !important;
    order: 1 !important;
  }
  
  .authorized-emails-input-wrapper button {
    width: 100% !important;
    order: 2 !important;
  }
}




/* ==========================================
   ISSUE #4: HORIZONTAL SCROLLING FOR BUTTON GROUPS
   ========================================== */

/* Manage Award Dropdown Modal - Framework Buttons */
#reasonManagerModal .horizontal-scroll-buttons {
  display: flex !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  gap: 12px !important;
  padding: 8px 0 16px 0 !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

#reasonManagerModal .horizontal-scroll-buttons button {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

/* Quick Quiz Modal - Top Dropdown Filters */
#weeklyQuizModal .quiz-filters-row {
  display: flex !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  gap: 10px !important;
  padding: 8px 0 12px 0 !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  align-items: center;
}

#weeklyQuizModal .quiz-filters-row select,
#weeklyQuizModal .quiz-filters-row button {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

/* For tablets and mobile - ensure proper spacing */
@media (max-width: 1024px) {
  #reasonManagerModal .horizontal-scroll-buttons {
    gap: 8px !important;
    padding-bottom: 12px !important;
  }
  
  #reasonManagerModal .horizontal-scroll-buttons button {
    padding: 8px 14px !important;
    font-size: 11px !important;
  }
  
  #weeklyQuizModal .quiz-filters-row {
    gap: 8px !important;
  }
  
  #weeklyQuizModal .quiz-filters-row select {
    min-width: 120px !important;
    padding: 8px 12px !important;
    font-size: 12px !important;
  }
}
    


/* Plan Selector Modal - Mobile Fix */
@media (max-width: 768px) {
    .plan-cards-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
    }
    
    .plan-cards-container > div {
        width: 100% !important;
        margin: 0 !important;
    }
}



/* ==========================================
   NEEDS WORK SETTINGS
   CLEAN RESPONSIVE LAYOUT
   ========================================== */

#reasonManagerModal #needsWorkReasonSettingsPanel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}


#reasonManagerModal #needsWorkReasonsContainer {
  display: grid !important;
  grid-template-columns:
    repeat(
      2,
      minmax(0, 1fr)
    ) !important;

  gap: 10px !important;

  width: 100% !important;
  min-width: 0 !important;

  padding: 2px 0 !important;
}


#reasonManagerModal .needs-work-reason-row {
  display: grid !important;

  grid-template-columns:
    minmax(0, 1fr)
    72px
    38px !important;

  align-items: center !important;

  gap: 8px !important;

  min-width: 0 !important;

  padding: 9px 10px !important;

  border:
    1px solid
    #e2e8f0 !important;

  border-left:
    3px solid
    #fb923c !important;

  border-radius: 11px !important;

  background:
    #ffffff !important;

  box-shadow:
    0 1px 2px
    rgba(15,23,42,.03) !important;
}


#reasonManagerModal
.needs-work-reason-text {
  width: 100% !important;
  min-width: 0 !important;

  height: 38px !important;

  padding:
    8px
    10px !important;

  border:
    1px solid
    #dbe3ec !important;

  border-radius:
    8px !important;

  background:
    #ffffff !important;

  font-size:
    11px !important;

  color:
    #0f172a !important;
}


#reasonManagerModal
.needs-work-points-input {
  width: 100% !important;

  font-size:
    12px !important;

  font-weight:
    850 !important;

  color:
    #c2410c !important;
}


#reasonManagerModal
.needs-work-reason-row
> div:nth-child(2) {
  height:
    38px !important;

  border:
    1px solid
    #fed7aa !important;

  border-radius:
    8px !important;

  background:
    #fff7ed !important;
}


#reasonManagerModal
.needs-work-reason-row
> div:nth-child(2)
> span {
  padding-left:
    8px !important;

  color:
    #c2410c !important;
}


#reasonManagerModal
.needs-work-reason-row
> button {
  width:
    38px !important;

  min-width:
    38px !important;

  height:
    38px !important;

  min-height:
    38px !important;

  padding:
    0 !important;

  border-radius:
    8px !important;
}


#reasonManagerModal
#saveNeedsWorkReasonsBtn {
  min-height:
    38px !important;

  padding:
    8px
    16px !important;

  border-radius:
    9px !important;

  font-size:
    10px !important;

  box-shadow:
    0 2px 5px
    rgba(37,99,235,.16);
}


/* iPad / tablet */
@media (
  min-width: 768px
) and (
  max-width: 1024px
) {

  #reasonManagerModal
  #needsWorkReasonsContainer {
    grid-template-columns:
      repeat(
        2,
        minmax(0, 1fr)
      ) !important;

    gap:
      9px !important;
  }


  #reasonManagerModal
  .needs-work-reason-row {
    grid-template-columns:
      minmax(0, 1fr)
      66px
      38px !important;
  }

}


/* Phones */
@media (
  max-width: 767px
) {

  #reasonManagerModal
  #needsWorkReasonSettingsPanel {
    gap:
      12px !important;

    overflow:
      visible !important;
  }


  #reasonManagerModal
  #needsWorkReasonsContainer {
    grid-template-columns:
      1fr !important;

    gap:
      8px !important;
  }


  #reasonManagerModal
  .needs-work-reason-row {
    grid-template-columns:
      minmax(0, 1fr)
      62px
      40px !important;

    gap:
      7px !important;

    padding:
      8px !important;
  }


  #reasonManagerModal
  .needs-work-reason-text {
    height:
      42px !important;

    font-size:
      13px !important;
  }


  #reasonManagerModal
  .needs-work-reason-row
  > div:nth-child(2) {
    height:
      42px !important;
  }


  #reasonManagerModal
  .needs-work-reason-row
  > button {
    width:
      40px !important;

    min-width:
      40px !important;

    height:
      40px !important;

    min-height:
      40px !important;
  }


  #reasonManagerModal
  #saveNeedsWorkReasonsBtn {
    width:
      100% !important;

    min-height:
      46px !important;

    align-self:
      stretch !important;

    font-size:
      12px !important;
  }

}

/* ==========================================
   MANAGE AWARD DROPDOWN MODAL - FULL SCREEN ON ALL DEVICES
   ========================================== */
   
/* Desktop (1025px and above): FULL SCREEN */
@media (min-width: 1025px) {
  #reasonManagerModal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 100002 !important;
  }
  
  #reasonManagerModal .house-expanded-content {
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    max-height: none !important;
    border-radius: 0 !important;
    padding: 24px 32px !important;
    margin: 0 !important;
    background: #ffffff !important;
    position: relative !important;
    z-index: 100003 !important;
  }
  
  #reasonManagerModal #reasonsInputsContainer {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 24px !important;
  }
  
  #reasonManagerModal #reasonsInputsContainer > div {
    width: 100% !important;
    margin: 0 !important;
  }
  
  .horizontal-scroll-buttons {
    display: flex !important;
    gap: 16px !important;
    margin-bottom: 24px !important;
    flex-wrap: wrap !important;
    flex-shrink: 0 !important;
  }
  
  /* Make the close button more visible on desktop */
  #reasonManagerModal .house-expanded-close {
    top: 20px !important;
    right: 20px !important;
    width: 40px !important;
    height: 40px !important;
    font-size: 20px !important;
    z-index: 100004 !important;
    background: #ef4444 !important;
    color: white !important;
    cursor: pointer !important;
  }
  
  /* Better spacing for category cards on desktop */
  #reasonManagerModal #reasonsInputsContainer > div {
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    overflow: visible;
    transition: box-shadow 0.2s ease;
  }
  
  #reasonManagerModal #reasonsInputsContainer > div:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  }
  
  /* FIX: Add proper spacing for reason rows inside each card */
  #reasonManagerModal .reason-row {
    display: flex !important;
    gap: 12px !important;
    align-items: center !important;
    padding: 12px 16px !important;
    margin-bottom: 8px !important;
    background: #f8fafc !important;
    border-radius: 12px !important;
    border-left: 4px solid !important;
  }
  
  /* Category-specific left border colors */
  #reasonManagerModal #academicManagerReasons .reason-row {
    border-left-color: #10b981 !important;
  }
  #reasonManagerModal #pastoralManagerReasons .reason-row {
    border-left-color: #f59e0b !important;
  }
  #reasonManagerModal #leadershipManagerReasons .reason-row {
    border-left-color: #8b5cf6 !important;
  }
  #reasonManagerModal #uncategorizedManagerReasons .reason-row {
    border-left-color: #64748b !important;
  }
  
  /* Make inputs take proper space */
  #reasonManagerModal .preset-reason-input {
    flex: 2 !important;
    padding: 10px 12px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    background: white !important;
  }
  
  #reasonManagerModal .preset-points-input {
    width: 80px !important;
    padding: 10px 8px !important;
    font-size: 13px !important;
    text-align: center !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    background: white !important;
  }
  
  /* Ensure category cards have internal padding */
  #reasonManagerModal #reasonsInputsContainer > div > div:first-child {
    padding: 16px 16px 0 16px !important;
    background: white !important;
    border-bottom: 2px solid #f1f5f9 !important;
    margin-bottom: 8px !important;
  }
  
  /* Style the category header area */
  #reasonManagerModal #reasonsInputsContainer > div > div:first-child h3 {
    font-size: 16px !important;
    font-weight: 800 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  
  /* Container for reasons list with proper scrolling */
  #academicManagerReasons,
  #pastoralManagerReasons,
  #leadershipManagerReasons,
  #uncategorizedManagerReasons {
    padding: 8px 16px 16px 16px !important;
    max-height: 400px !important;
    overflow-y: auto !important;
  }
  
  /* Add button styling - FIXED: Dark text for visibility */
  #reasonManagerModal button[onclick*="addReasonToCategory"] {
    background: #f1f5f9 !important;
    border: 1px solid !important;
    padding: 6px 12px !important;
    border-radius: 20px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    color: #1e293b !important;
  }
  
  /* Category-specific border colors - keep borders colored, text dark */
  #academicManagerReasons + div button {
    border-color: #10b981 !important;
  }
  #pastoralManagerReasons + div button {
    border-color: #f59e0b !important;
  }
  #leadershipManagerReasons + div button {
    border-color: #8b5cf6 !important;
  }
  #uncategorizedManagerReasons + div button {
    border-color: #64748b !important;
  }
  
  /* Hover effect for add buttons */
  #reasonManagerModal button[onclick*="addReasonToCategory"]:hover {
    background: #e2e8f0 !important;
    transform: translateY(-1px);
  }
}

/* Tablet (768px to 1024px): FULL SCREEN */
@media (min-width: 768px) and (max-width: 1024px) {
  #reasonManagerModal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 100002 !important;
  }
  
  #reasonManagerModal .house-expanded-content {
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    max-height: none !important;
    border-radius: 0 !important;
    padding: 20px !important;
    margin: 0 !important;
    background: #ffffff !important;
    position: relative !important;
    z-index: 100003 !important;
  }
  
  #reasonManagerModal #reasonsInputsContainer {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }
  
  #reasonManagerModal #reasonsInputsContainer > div {
    width: 100% !important;
  }
  
  /* Tablet: Ensure reason rows have proper spacing and scrolling */
  #reasonManagerModal .reason-row {
    display: flex !important;
    gap: 10px !important;
    align-items: center !important;
    padding: 10px 14px !important;
    margin-bottom: 8px !important;
    background: #f8fafc !important;
    border-radius: 10px !important;
  }
  
  #academicManagerReasons,
  #pastoralManagerReasons,
  #leadershipManagerReasons,
  #uncategorizedManagerReasons {
    padding: 8px 12px 12px 12px !important;
    max-height: 350px !important;
    overflow-y: auto !important;
  }
  
  #reasonManagerModal .preset-reason-input {
    flex: 2 !important;
    padding: 8px 10px !important;
    font-size: 12px !important;
  }
  
  #reasonManagerModal .preset-points-input {
    width: 70px !important;
    padding: 8px 6px !important;
    font-size: 12px !important;
  }
  
  .horizontal-scroll-buttons {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
  }
  
  #reasonManagerModal .house-expanded-close {
    top: 15px !important;
    right: 15px !important;
    width: 40px !important;
    height: 40px !important;
    font-size: 20px !important;
    z-index: 100004 !important;
  }
}

@media (max-width: 767px) {
  #googleClassroomImportCard {
    width: 100% !important;
    max-width: 100% !important;
    padding: 16px !important;
    box-sizing: border-box !important;
  }

    #reasonManagerModal
  #needsWorkReasonSettingsPanel
  > div:first-child {
    flex-direction:
      column !important;

    align-items:
      stretch !important;

    gap:
      10px !important;

    padding:
      12px !important;
  }


  #reasonManagerModal
  #needsWorkReasonSettingsPanel
  > div:first-child
  > button {
    width:
      100% !important;

    min-height:
      42px !important;

    justify-content:
      center !important;
  }


  #reasonManagerModal
  #needsWorkReasonSettingsPanel
  > div:nth-child(2) {
    align-items:
      flex-end !important;

    gap:
      10px !important;
  }


  #reasonManagerModal
  #needsWorkReasonSettingsPanel
  > div:nth-child(2)
  > div {
    min-width:
      0 !important;

    flex:
      1 !important;
  }


  #reasonManagerModal
  #needsWorkReasonSettingsPanel
  > div:nth-child(2)
  > button {
    flex:
      0 0 auto !important;

    min-height:
      40px !important;
  }

  #googleClassroomImportCard .google-classroom-import-layout {
    grid-template-columns: 46px minmax(0, 1fr) !important;
    gap: 10px 12px !important;
    align-items: start !important;
  }

  #googleClassroomImportCard .google-classroom-import-layout > div:first-child {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
  }

  #googleClassroomImportCard .google-classroom-import-layout > div:nth-child(2) {
    min-width: 0 !important;
  }

  #googleClassroomImportCard h4 {
    font-size: 14px !important;
    line-height: 1.3 !important;
  }

  #googleClassroomImportCard p {
    font-size: 11px !important;
    line-height: 1.5 !important;
  }

  #connectGoogleClassroomBtn {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
    margin-top: 2px !important;
    padding: 11px 12px !important;
  }
}

@media (max-width: 767px) {
  #classLeaderboardModal .official-standings-filter-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;

    width: 100% !important;
    max-width: 100% !important;

    overflow-x: auto !important;
    overflow-y: hidden !important;

    padding: 10px 14px 12px !important;

    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #classLeaderboardModal .official-standings-filter-row::-webkit-scrollbar {
    display: none;
  }

  #classLeaderboardModal .official-standings-filter-row > * {
    flex: 0 0 auto !important;
    min-width: max-content !important;
  }

  #classLeaderboardModal #classStandingsScopeFilter,
  #classLeaderboardModal #classStandingsGradeFilter,
  #classLeaderboardModal #topStudentsCategoryFilter,
  #classLeaderboardModal #topStudentsReasonFilter {
    width: auto !important;
    min-width: 145px !important;
    max-width: 210px !important;
  }

  #classLeaderboardModal #topStudentsReasonFilter {
    min-width: 190px !important;
  }

  #classLeaderboardModal #officialStandingsManageReasonsBtn {
    width: auto !important;
    min-width: max-content !important;
  }
}

/* Mobile (767px and below): FULL SCREEN */
@media (max-width: 767px) {
  #reasonManagerModal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    background: rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 100002 !important;
    overflow: hidden !important;
  }

  #reasonManagerModal .house-expanded-content {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    padding: 16px 14px 24px !important;
    margin: 0 !important;
    background: #ffffff !important;
    position: relative !important;
    z-index: 100003 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
  }

  #reasonManagerModal .award-suggestions-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  #reasonManagerModal .award-suggestions-row > div:first-child {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  #reasonManagerModal .award-suggestions-row > div:first-child > div {
    white-space: normal !important;
  }

  #reasonManagerModal .award-suggestions-row > div:last-child {
    width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px !important;
  }

  #reasonManagerModal .award-suggestions-row > div:last-child button {
    width: auto !important;
    min-width: max-content !important;
    flex: 0 0 auto !important;
  }

  #reasonManagerModal #reasonsInputsContainer {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
  }

  #reasonManagerModal #reasonsInputsContainer > div {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  #reasonManagerModal .reason-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 60px 40px !important;
    align-items: center !important;
    gap: 7px !important;
    padding: 10px !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  #reasonManagerModal .preset-reason-input {
    width: 100% !important;
    min-width: 0 !important;
    height: 42px !important;
  }

  #reasonManagerModal .preset-points-input {
    width: 60px !important;
    min-width: 60px !important;
    height: 42px !important;
    text-align: center !important;
  }

  #reasonManagerModal .reason-row .btn-danger {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 !important;
  }

  #academicManagerReasons,
  #pastoralManagerReasons,
  #leadershipManagerReasons,
  #uncategorizedManagerReasons {
    padding: 8px !important;
    max-height: none !important;
    overflow: visible !important;
  }

  #reasonManagerModal .house-expanded-close {
    top: 12px !important;
    right: 12px !important;
    width: 44px !important;
    height: 44px !important;
    font-size: 22px !important;
    background: #ef4444 !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
    z-index: 100004 !important;
  }

  #reasonManagerModal h2 {
    font-size: 18px !important;
    padding-right: 48px !important;
  }
}


/* FIX: Ensure category cards have consistent height and spacing */
#reasonManagerModal #reasonsInputsContainer {
  display: grid !important;
  gap: 24px !important;
  align-items: start !important;
}

#reasonManagerModal #reasonsInputsContainer > div {
  height: fit-content !important;
  max-height: none !important;
  overflow: visible !important;
}

/* Style the scrollbar for better visibility */
#academicManagerReasons::-webkit-scrollbar,
#pastoralManagerReasons::-webkit-scrollbar,
#leadershipManagerReasons::-webkit-scrollbar,
#uncategorizedManagerReasons::-webkit-scrollbar {
  width: 6px;
}

#academicManagerReasons::-webkit-scrollbar-track,
#pastoralManagerReasons::-webkit-scrollbar-track,
#leadershipManagerReasons::-webkit-scrollbar-track,
#uncategorizedManagerReasons::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

#academicManagerReasons::-webkit-scrollbar-thumb,
#pastoralManagerReasons::-webkit-scrollbar-thumb,
#leadershipManagerReasons::-webkit-scrollbar-thumb,
#uncategorizedManagerReasons::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

#academicManagerReasons::-webkit-scrollbar-thumb:hover,
#pastoralManagerReasons::-webkit-scrollbar-thumb:hover,
#leadershipManagerReasons::-webkit-scrollbar-thumb:hover,
#uncategorizedManagerReasons::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Small phones (480px and below) */
@media (max-width: 480px) {
  #reasonManagerModal .house-expanded-content {
    padding: 12px !important;
  }
  
  #reasonManagerModal h2 {
    font-size: 16px !important;
  }
  
  .horizontal-scroll-buttons button {
    padding: 5px 10px !important;
    font-size: 9px !important;
  }
}

/* Ensure Reason Manager Modal always stays on top */
#reasonManagerModal.show {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#reasonManagerModal {
  z-index: 100002 !important;
}

#reasonManagerModal .house-expanded-content {
  z-index: 100003 !important;
}

#gmailReviewScreen,
.gmail-review-modal,
.verification-overlay {
  display: none !important;
}


  /* Hide Student App button on mobile and iPad */
  @media (max-width: 1370px) {
    .mobile-hidden {
      display: none !important;
    }
  }

  /* Hide desktop-only elements on mobile and iPad (max-width: 1370px) */
@media (max-width: 1370px) {
  .desktop-only {
    display: none !important;
  }
  
  /* Additional selector to ensure any button with desktop-only class is hidden */
  button.desktop-only,
  .btn.desktop-only {
    display: none !important;
  }
}

/* Show desktop-only elements on desktop (min-width: 1371px) */
#students-section .top-row-container {
  position: sticky !important;
  z-index: 850 !important;

  background: rgba(255,255,255,0.97) !important;

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  padding: 8px 12px !important;

  margin:
    0
    -12px
    4px !important;

  width:
    calc(100% + 24px) !important;

  border-bottom:
    1px solid #e2e8f0;

  box-shadow:
    0 4px 10px rgba(15,23,42,0.05);
}


/* iPad + Mobile */
@media (max-width: 1370px) {

  #students-section .top-row-container {
    top: 52px !important;
  }

}


/* Desktop */
@media (min-width: 1371px) {

  #students-section .top-row-container {
    top: 58px !important;
  }


  .desktop-only:not(#headerLicenseWidget):not(#dashboardManageHousesBtn):not(#dashboardHouseBadgesBtn):not(#dashboardStudentBadgesBtn) {
    display: inline-flex !important;
  }

  button.desktop-only:not(#dashboardManageHousesBtn):not(#dashboardHouseBadgesBtn):not(#dashboardStudentBadgesBtn),
  .btn.desktop-only:not(#dashboardManageHousesBtn):not(#dashboardHouseBadgesBtn):not(#dashboardStudentBadgesBtn) {
    display: inline-flex !important;
  }

}

@media (min-width: 1371px) {

  #dashboardManageHousesBtn,
  #dashboardHouseBadgesBtn,
  #dashboardStudentBadgesBtn {
    display: none !important;
  }

  #dashboardManageHousesBtn.admin-visible,
  #dashboardHouseBadgesBtn.admin-visible,
  #dashboardStudentBadgesBtn.admin-visible {
    display: inline-flex !important;
  }

}










/* Desktop: Show desktop buttons, hide mobile buttons */
@media (min-width: 1371px) {
  .desktop-btn-group {
    display: flex !important;
  }
  .mobile-btn-group {
    display: none !important;
  }
}



/* Hide the old desktop-only class buttons on mobile */
@media (max-width: 1370px) {
  .btn.desktop-only {
    display: none !important;
  }
}




/* ==========================================
   COMPACT BUTTONS - UNIFIED STYLES
   ========================================== */

/* Base compact button styles */
.compact-btn {
  padding: 6px 12px;
  font-size: 12px;
  min-height: 28px;
  height: auto;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 16px !important;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: var(--light-text);
  white-space: nowrap;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  cursor: pointer;
  border: none;
  line-height: 1;
}

.compact-btn:active {
  transform: scale(0.96);
}


/* ==========================================
   DESKTOP ADD STUDENTS MENU
   ========================================== */

.desktop-add-students-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}


.desktop-add-students-dropdown {
  position: absolute;

  top: calc(100% + 10px);
  left: 0;

  width: 300px;

  display: none;

  flex-direction: column;

  padding: 8px;

  background: #ffffff;

  border: 1px solid #dbe4ee;
  border-radius: 16px;

  box-shadow:
    0 16px 35px
    rgba(15,23,42,0.16);

  z-index: 5000;
}


.desktop-add-students-dropdown.show {
  display: flex;
}


.desktop-add-students-option {
  width: 100%;

  display: flex;
  align-items: center;

  gap: 12px;

  padding: 12px;

  border: none;
  border-radius: 12px;

  background: transparent;

  text-align: left;

  cursor: pointer;

  transition:
    background 0.16s ease,
    transform 0.16s ease;
}


.desktop-add-students-option:hover {
  background: #f8fafc;

  transform:
    translateX(2px);
}


.desktop-add-students-option-icon {
  width: 38px;
  height: 38px;

  flex: 0 0 38px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 11px;

  font-size: 15px;
}


.desktop-add-students-option-icon.manual {
  background: #ecfdf5;
  color: #059669;
}


.desktop-add-students-option-icon.bulk {
  background: #eff6ff;
  color: #2563eb;
}


.desktop-add-students-option-copy {
  display: flex;
  flex-direction: column;

  gap: 3px;

  min-width: 0;
}


.desktop-add-students-option-copy strong {
  color: #172033;

  font-size: 13px;
  font-weight: 800;
}


.desktop-add-students-option-copy small {
  color: #64748b;

  font-size: 11px;
  font-weight: 500;
}


/* ==========================================
   DESKTOP STUDENT ACCESS MENU
   ========================================== */

.student-access-menu {
  position: relative;

  display: inline-flex;

  align-items: center;
}


.student-access-trigger {
  height: 38px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: 8px;

  padding: 0 16px;

  border: none;

  border-radius: 10px;

  background:
    linear-gradient(
      135deg,
      #2563eb,
      #1d4ed8
    );

  color: #ffffff;

  font-size: 12px;
  font-weight: 800;

  white-space: nowrap;

  cursor: pointer;

  box-shadow:
    0 4px 12px
    rgba(37,99,235,0.24);

  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}


.student-access-trigger:hover {
  background:
    linear-gradient(
      135deg,
      #1d4ed8,
      #1e40af
    );

  transform:
    translateY(-1px);

  box-shadow:
    0 6px 16px
    rgba(37,99,235,0.30);
}


.student-access-chevron {
  font-size: 9px;

  transition:
    transform 0.18s ease;
}


.student-access-trigger[aria-expanded="true"]
.student-access-chevron {
  transform: rotate(180deg);
}


.desktop-student-access-dropdown {
  position: absolute;

  top: calc(100% + 10px);
  right: 0;

  z-index: 5000;

  width: 320px;

  display: none;

  flex-direction: column;

  gap: 4px;

  padding: 10px;

  border:
    1px solid
    #dbe4ee;

  border-radius: 16px;

  background: #ffffff;

  box-shadow:
    0 16px 35px
    rgba(15,23,42,0.16);
}


.desktop-student-access-dropdown.show {
  display: flex;
}


.student-access-heading {
  padding:
    4px
    8px
    6px;

  color: #2563eb;

  font-size: 9px;
  font-weight: 900;

  letter-spacing: 0.9px;
}


.student-access-intro {
  padding:
    4px
    8px
    10px;

  color: #475569;

  font-size: 11px;
  line-height: 1.45;
}


.student-access-intro strong {
  color: #172033;

  font-weight: 800;
}


.student-access-app-btn {
  width: 100%;

  display: flex;
  align-items: center;

  gap: 11px;

  padding:
    11px
    12px;

  border: none;

  border-radius: 12px;

  background:
    linear-gradient(
      135deg,
      #2563eb,
      #1d4ed8
    );

  color: #ffffff;

  text-align: left;

  cursor: pointer;

  box-shadow:
    0 5px 14px
    rgba(37,99,235,0.20);

  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease;
}


.student-access-app-btn:hover {
  transform:
    translateY(-1px);

  box-shadow:
    0 7px 18px
    rgba(37,99,235,0.28);
}


.student-access-app-btn > i:first-child {
  font-size: 17px;

  flex: 0 0 auto;
}


.student-access-app-btn > i:last-child {
  margin-left: auto;

  font-size: 11px;

  opacity: 0.8;
}


.student-access-app-btn span {
  flex: 1;

  display: flex;
  flex-direction: column;

  gap: 2px;
}


.student-access-app-btn strong {
  color: #ffffff;

  font-size: 12px;
  font-weight: 800;
}


.student-access-app-btn small {
  color:
    rgba(255,255,255,0.78);

  font-size: 10px;
}


.student-access-divider {
  height: 1px;

  margin:
    8px
    4px;

  background: #e2e8f0;
}


.student-access-option {
  width: 100%;

  display: flex;
  align-items: center;

  gap: 12px;

  padding: 12px;

  border: none;

  border-radius: 12px;

  background: transparent;

  text-align: left;
}


button.student-access-option {
  cursor: pointer;

  transition:
    background 0.16s ease,
    transform 0.16s ease;
}


button.student-access-option:hover {
  background: #f8fafc;

  transform: translateX(2px);
}


.student-access-option-icon {
  width: 38px;
  height: 38px;

  flex: 0 0 38px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 11px;

  font-size: 15px;
}


.student-access-option-icon.code {
  background: #eff6ff;

  color: #2563eb;
}


.student-access-option-icon.print {
  background: #eef2ff;

  color: #4338ca;
}


.student-access-option-copy {
  min-width: 0;

  flex: 1;

  display: flex;
  flex-direction: column;

  gap: 3px;
}


.student-access-option-copy strong {
  color: #172033;

  font-size: 13px;
  font-weight: 800;
}


.student-access-option-copy small {
  color: #64748b;

  font-size: 10px;
  font-weight: 500;
}


.student-access-code {
  width: fit-content;

  margin-top: 7px;

  align-items: center;

  gap: 7px;

  padding:
    6px
    9px;

  border:
    1px solid
    #bfdbfe;

  border-radius: 8px;

  background: #eff6ff;

  color: #1e40af;

  font-family: monospace;

  font-size: 14px;
  font-weight: 900;

  letter-spacing: 1.5px;

  cursor: pointer;
}


.student-access-regenerate {
  display: inline-flex;

  align-items: center;
  justify-content: center;

  margin-left: 2px;

  padding: 3px 5px;

  border: none;

  border-radius: 5px;

  background: transparent;

  color: #2563eb;

  cursor: pointer;
}


.student-access-regenerate:hover {
  background: #dbeafe;
}


/*
 * Desktop:
 * one Student Access dropdown.
 */
@media (min-width: 1371px) {

  .student-access-menu {
    display: inline-flex;
  }

}


/*
 * iPad / mobile:
 * keep the existing Class Code behaviour.
 * Hide the new Student Access trigger and
 * make the contents behave like normal controls.
 */
@media (max-width: 1370px) {

  /* Mobile / iPad: show ONLY the compact Class Code */
  .student-access-trigger,
  .student-access-heading,
  .student-access-intro,
  .student-access-app-btn,
  .student-access-divider,
  .student-access-option-icon,
  .student-access-option-copy > strong,
  .student-access-option-copy > small,
  #printClassLoginCardsBtn {
    display: none !important;
  }

  .student-access-menu {
    display: flex !important;
    position: static !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
  }

  .desktop-student-access-dropdown {
    position: static !important;
    display: flex !important;
    width: auto !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .student-access-option {
    display: flex !important;
    width: auto !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .student-access-option-copy {
    display: flex !important;
    width: auto !important;
    min-width: 0 !important;
  }

  #classPasscodeBadge {
    display: inline-flex !important;
    align-items: center !important;
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    margin: 0 !important;
    padding: 4px 8px !important;
    gap: 5px !important;
  }

}


@media (max-width: 780px) {

  #printClassLoginCardsBtn {
    display: none !important;
  }

}


@media (max-width: 1370px) {

  .desktop-add-students-menu {
    display: none !important;
  }

}

.compact-btn i {
  font-size: 12px;
  margin: 0;
}

.compact-btn span {
  display: inline-block;
  font-size: 11px;
}

/* Desktop (≥1371px) */
@media (min-width: 1371px) {
  .desktop-btn-group {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .desktop-btn-group > .compact-btn,
  .desktop-btn-group #desktopAddStudentsBtn {
    height: 40px !important;
    min-height: 40px !important;
    box-sizing: border-box;
    padding: 0 14px !important;
    border-radius: 12px !important;
    font-size: 12px;
    white-space: nowrap;
  }

  .desktop-btn-group > .btn-tutorial {
    width: 40px !important;
    padding: 0 !important;
  }

  .desktop-btn-group .toolkit-icon-mascot {
    width: 24px;
    height: 24px;
    object-fit: contain;
  }

  .mobile-btn-group {
    display: none !important;
  }

  .compact-btn {
    font-size: 13px;
  }

  .compact-btn i {
    font-size: 13px;
  }

  .compact-btn span {
    font-size: 12px;
  }
}

/* Mobile & iPad (≤1370px) - SUPER COMPACT, TEXT VISIBLE */
@media (max-width: 1370px) {
  .desktop-btn-group {
    display: none !important;
  }
  .mobile-btn-group {
    display: flex !important;
    gap: 6px !important;
    align-items: center !important;
    padding: 0 16px !important;  /* ADDED: horizontal padding for buttons */
  }
  
  .mobile-btn-group .compact-btn {
    padding: 3px 8px !important;
    min-height: 24px !important;
    height: auto !important;
    font-size: 11px !important;
    border-radius: 12px !important;
    gap: 4px !important;
    line-height: 1.2 !important;
  }
  
  .mobile-btn-group .compact-btn i {
    font-size: 10px !important;
    margin: 0 !important;
  }
  
  .mobile-btn-group .compact-btn span,
  .mobile-btn-group .compact-btn .mobile-text {
    display: inline-block !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
  }
  
  /* Extra small phones - even tighter */
  @media (max-width: 480px) {
    .mobile-btn-group .compact-btn {
      padding: 2px 6px !important;
      min-height: 22px !important;
      font-size: 10px !important;
      border-radius: 10px !important;
      gap: 3px !important;
    }
    
    .mobile-btn-group .compact-btn span,
    .mobile-btn-group .compact-btn .mobile-text {
      font-size: 9px !important;
      display: inline-block !important;
    }
    
    .mobile-btn-group .compact-btn i {
      font-size: 9px !important;
    }
    
    .mobile-btn-group {
      gap: 4px !important;
      padding: 0 12px !important;  /* ADDED: smaller padding on very small phones */
    }
  }
}

/* Hide old conflicting styles */
@media (max-width: 1370px) {
  .btn.desktop-only {
    display: none !important;
  }
  
  /* Override any conflicting #students-section styles */
  #students-section .compact-btn {
    padding: 3px 8px !important;
    min-height: 24px !important;
    min-width: auto !important;
    font-size: 11px !important;
    border-radius: 12px !important;
  }
  
  #students-section .compact-btn span,
  #students-section .compact-btn .text-mobile {
    display: inline-block !important;
    font-size: 10px !important;
  }
  
  #students-section .compact-btn i {
    font-size: 10px !important;
  }
}




/* ==========================================
   FILTERS - SUPER COMPACT (ALL DEVICES)
   ========================================== */

/* Base filter styles */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-group {
  min-width: 0;
  flex: 1;
}

.filter-group label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.filter-group .form-control {
  height: 34px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 0 28px 0 12px;
  color: #1e293b;
  width: 100%;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  background-size: 12px !important;
}

.filter-group .form-control:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Hide role filter and refresh button on mobile initially */
.filter-group.role-filter,
.filter-group.refresh-button {
  display: none;
}

/* DESKTOP LARGE (≥1200px) - Normal layout with padding */
@media (min-width: 1200px) {
  .filters {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding: 0;
  }
  
  .filter-group {
    flex: 1;
    min-width: 160px;
    max-width: 220px;
  }
  
  .filter-group.role-filter,
  .filter-group.refresh-button {
    display: block;
  }
  
  .filter-group label {
    font-size: 10px;
    margin-bottom: 4px;
  }
  
  .filter-group .form-control {
    height: 34px;
    font-size: 13px;
    padding: 0 28px 0 12px;
    background-position: right 10px center;
    background-size: 12px;
  }
}





/* IPAD & TABLET (769px to 1370px) - Desktop style, NO horizontal scroll */
@media (min-width: 769px) and (max-width: 1370px) {
  /* Filters - normal wrap layout like desktop, with side padding */
  .filters {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    padding: 0 16px !important;
    margin: 0 0 12px 0 !important;
    overflow-x: visible !important;
  }

  .filter-group {
    flex: 0 0 auto !important;
    min-width: 120px !important;
    max-width: 160px !important;
  }

  .filter-group label {
    display: block !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    color: #64748b !important;
    text-transform: uppercase !important;
    margin-bottom: 4px !important;
  }

  .filter-group .form-control {
    height: 34px !important;
    font-size: 12px !important;
    border-radius: 8px !important;
    padding: 0 28px 0 12px !important;
    width: 100% !important;
    min-width: auto !important;
  }
  
  /* Show role filter on iPad */
  .filter-group.role-filter {
    display: block !important;
  }

  /* Top row - NO horizontal scroll, items stay on same row */
  .top-row-container {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    width: 100% !important;
    overflow-x: visible !important;
    padding: 0 16px !important;
    padding-bottom: 0 !important;
    box-sizing: border-box !important;
  }
  
  #classInfoContainer {
    flex-shrink: 1 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    min-width: 0 !important;
  }
  
  .search-select-container {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
  }
  
  .search-group {
    width: 160px !important;
    min-width: 140px !important;
    max-width: 160px !important;
    margin-right: 4px !important;
  }
  
  #studentSearchInput {
    height: 32px !important;
    font-size: 12px !important;
    padding-left: 32px !important;
  }
  
  /* 🔥 FIX: Select button with FIXED width */
  #globalSelectToggle {
    height: 32px !important;
    min-height: 32px !important;
    width: 85px !important;
    min-width: 85px !important;
    max-width: 85px !important;
    padding: 0 10px !important;
    font-size: 11px !important;
    border-radius: 16px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
  
  #globalSelectToggle .btn-text {
    font-size: 10px !important;
  }
  
  #globalSelectToggle i {
    font-size: 10px !important;
  }
  
  /* 🔥 FIX: Passcode badge styling - PREVENTS COVERING */
  #classPasscodeBadge {
    display: inline-flex !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding: 3px 10px !important;
    font-size: 11px !important;
    gap: 4px !important;
  }
  
  #classPasscodeBadge span {
    font-size: 9px !important;
  }
  
  #classPasscodeValue {
    font-size: 11px !important;
  }
  
  #regeneratePasscodeBtn {
    font-size: 10px !important;
    padding: 2px 5px !important;
  }
  
  /* Teacher and Ranking badges */
  #classTeacherBadge {
    padding: 3px 8px !important;
    font-size: 11px !important;
  }
  
  #classRankingBadge {
    padding: 3px 8px !important;
    font-size: 11px !important;
  }
}

/* EXTRA SMALL PHONES (≤480px) */
@media (max-width: 480px) {
  .filters {
    gap: 4px !important;
    padding: 0 12px 6px 12px !important;
  }
  
  .filter-group .form-control {
    height: 26px !important;
    font-size: 10px !important;
    padding: 0 20px 0 8px !important;
    min-width: 70px !important;
    border-radius: 13px !important;
    background-position: right 6px center !important;
    background-size: 9px !important;
  }
}

/* MOBILE & TABLET (≤768px) - Horizontal scrollable chips */
@media (max-width: 768px) {
  .filters {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    gap: 6px !important;
    padding: 0 16px 8px 16px !important;  /* CHANGED: added 16px left and right padding */
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    align-items: center;
    background: transparent;
    margin: 0 0 12px 0 !important;
    flex-wrap: nowrap !important;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .filter-group {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: auto !important;
    max-width: none !important;
  }

  .filter-group label {
    display: none !important;
  }

  .filter-group .form-control {
    height: 28px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    border-radius: 14px !important;
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    padding: 0 22px 0 10px !important;
    color: var(--primary-blue) !important;
    width: auto !important;
    min-width: 80px !important;
    background-position: right 8px center !important;
    background-size: 10px !important;
  }
  
  /* Hide role filter on mobile completely */
  .filter-group.role-filter {
    display: none !important;
  }
}

/* EXTRA SMALL PHONES (≤480px) */
@media (max-width: 480px) {
  .filters {
    gap: 4px !important;
    padding: 0 12px 6px 12px !important;  /* CHANGED: added 12px left and right padding */
  }
  
  .filter-group .form-control {
    height: 26px !important;
    font-size: 10px !important;
    padding: 0 20px 0 8px !important;
    min-width: 70px !important;
    border-radius: 13px !important;
    background-position: right 6px center !important;
    background-size: 9px !important;
  }
}

/* DESKTOP LARGE (≥1200px) */
@media (min-width: 1200px) {
  .filter-group {
    min-width: 160px;
    max-width: 220px;
  }

  .filter-group .form-control {
    height: 34px;
    font-size: 13px;
  }
}

/* MY CLASS: Content-aware desktop filters */
@media (min-width: 1371px) {
  #students-section .filters {
    justify-content: flex-start !important;
    align-items: flex-end !important;
    gap: 12px !important;
    width: 100% !important;
  }

  #students-section .filters > .filter-group {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  #students-section .filters > .filter-group > div {
    flex: none !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  #students-section .filters > .filter-group select {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box !important;
    text-overflow: ellipsis;
  }
}


/* MY CLASS: Mobile and iPad scrollable filters and attendance */
@media (max-width: 1370px) {

  #students-section .filters {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    padding: 8px 14px 12px !important;
    margin: 0 0 12px !important;
    box-sizing: border-box !important;
  }

  #students-section .filters::-webkit-scrollbar {
    display: none;
  }

  #students-section .filters > .filter-group {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 90px !important;
    max-width: none !important;
  }

  #students-section .filters > .filter-group > div {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
  }

  #students-section .filters .filter-group select {
    width: auto !important;
    min-width: 90px !important;
    max-width: none !important;
    white-space: nowrap !important;
  }

  #students-section .filters > .classboard-attendance-actions {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
    width: auto !important;
    min-width: max-content !important;
    margin-left: 0 !important;
    align-self: center !important;
  }

  #students-section .classboard-attendance-toggle[hidden] {
    display: none !important;
  }

  #students-section .classboard-attendance-toggle:not([hidden]) {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    align-items: center !important;
    gap: 7px !important;
    min-height: 38px;
    padding: 7px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #ffffff;
    color: #334155;
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
    cursor: pointer;
  }

  #students-section .classboard-attendance-toggle input {
    appearance: auto !important;
    -webkit-appearance: checkbox !important;
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    accent-color: #2563eb;
    flex: 0 0 auto;
    cursor: pointer;
  }

  #students-section .classboard-take-attendance-btn:not([hidden]) {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: max-content !important;
    min-height: 38px !important;
    padding: 7px 12px !important;
    white-space: nowrap !important;
    font-size: 11px !important;
  }

  #students-section .classboard-take-attendance-btn span {
    display: inline !important;
  }
}

.students-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 16px;  /* ADDED: horizontal padding */
}




/* Mobile & Tablet (≤768px) - Horizontal scrollable chips */
@media (max-width: 768px) {
  .search-select-container {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
  }
  
  .search-group {
    flex-shrink: 0 !important;
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
  }
  
  #classPasscodeBadge {
    padding: 2px 6px !important;
    font-size: 9px !important;
    white-space: nowrap !important;
  }
}




/* --- MOBILE ONLY: HORIZONTALLY SCROLLABLE ROW --- */
@media (max-width: 767px) {
  .top-row-container {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 4px !important;
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: thin !important;
    padding-bottom: 8px !important;
    padding-left: 0 !important;
  }
  
  /* Class Info Container (Teacher + Ranking) */
  #classInfoContainer {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important; /* THE FIX: Forces items to stay on one line */
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
    width: auto !important;
  }
  
  #classTeacherBadge {
    white-space: nowrap !important;
    font-size: 11px !important;
    padding: 4px 8px !important;
  }
  
  #classRankingBadge {
    white-space: nowrap !important;
    font-size: 11px !important;
    padding: 4px 8px !important;
  }
  
  /* Search + Select Container */
 
  
  #studentSearchInput {
    min-width: 0 !important;
    width: 100% !important;
    height: 32px !important;
    font-size: 11px !important;
    padding-left: 32px !important;
  }
  
  /* Passcode Badge */
  #classPasscodeBadge {
    display: inline-flex !important;
    flex-shrink: 0 !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
  }
  
  /* Select Button - Fixed width on mobile */
  #globalSelectToggle {
    flex: 0 0 auto !important;
    height: 32px !important;
    min-height: 32px !important;
    width: 85px !important;
    min-width: 85px !important;
    max-width: 85px !important;
    padding: 0 10px !important;
    font-size: 10px !important;
    white-space: nowrap !important;
    border-radius: 16px !important;
    line-height: 1 !important;
    gap: 4px !important;
  }
  
  #globalSelectToggle .btn-text {
    font-size: 9px !important;
    line-height: 1 !important;
  }
  
  #globalSelectToggle i {
    font-size: 9px !important;
  }
  
  #globalSelectToggle .btn-text {
    font-size: 10px !important;
    line-height: 1 !important;
  }
  
  #globalSelectToggle i {
    font-size: 10px !important;
  }
}

/* Hide Projector in the smart menu on phones and desktop */
@media (max-width: 780px), (min-width: 1371px) {
  .projector-menu-item {
    display: none !important;
  }
}

/* Desktop: hide the iPad-specific Assembly Mode button */
@media (min-width: 1371px) {
  .dashboard-projector-nondesktop {
    display: none !important;
  }
}

/* Phones only: hide Assembly Mode in House Highlights */
@media (max-width: 780px) {
  #dashboard-section
  #trackeduHighlightsActions
  .dashboard-projector-role-button {
    display: none !important;
  }

  #dashboard-section
  .card:has(#houseOverview)
  .dashboard-projector-nondesktop {
    display: none !important;
  }
}

/* Behaviour overview: hide the iPad Assembly / Class button */
body.dashboard-behaviour-mode
#dashboard-section
.dashboard-projector-nondesktop {
  display: none !important;
}

/* Show Projector in the smart menu on iPads/tablets only */
@media (min-width: 781px) and (max-width: 1370px) {
  .projector-menu-item {
    display: flex !important;
  }
}


/* Hide announcement bar when not logged in */
body:not(.ready) .announcement-bar {
  display: none !important;
}




/* Show Toolkit in mobile nav on iPads/Tablets (781px - 1370px) */
@media (min-width: 781px) and (max-width: 1370px) {
  .mobile-nav-item.nav-item-toolkit {
    display: flex !important;
  }
}


/* House Master Toolkits visibility in smart menu - controlled by JS */
#smartMenuHouseMasterToolkits {
  transition: all 0.2s ease;
}

#smartMenuHouseMasterToolkits.hidden {
  display: none !important;
}
    
/* Hide mobile search button on desktop (≥1371px) */
@media (min-width: 1371px) {
  .mobile-search-btn {
    display: none !important;
  }

  /* House Settings:
     shortcuts are redundant with desktop navigation */
  .house-control-quick-actions {
    display: none !important;
  }
}

/* Header search: phones only, not iPad */
@media (max-width: 780px) {
  .mobile-search-btn {
    display: inline-flex !important;
  }
}

/* iPad uses the dashboard search field instead */
@media (min-width: 781px) and (max-width: 1370px) {
  .mobile-search-btn {
    display: none !important;
  }
}

/* Style adjustments for mobile */
@media (max-width: 480px) {
  .mobile-search-btn {
    padding: 0 10px !important;
    min-width: 40px !important;
    width: auto !important;
  }
  
  .mobile-search-btn .btn-text {
    display: none !important;
  }
  
  .mobile-search-btn i {
    margin: 0 !important;
  }
}

/* 🛡️ Cloak: Hide app UI until authentication/data is ready */
.app-container,
.header,
.announcement-bar,
.mobile-nav,
.toolkit-fab,
.mobile-search-btn {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* Auth screen is visible only while logged out */
#auth-screen {
  display: flex !important;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.4s ease;
}


/* Logged-in state: remove the login screen completely */
body.ready #auth-screen {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}


/* Extra protection: nothing inside the hidden login screen
   may intercept clicks after login */
body.ready #auth-screen *,
body.ready #auth-screen .premium-login-auth {
  pointer-events: none !important;
}


/* Only show app content when ready */
body.ready .header,
body.ready .announcement-bar,
body.ready .app-container {
  display: flex !important;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}


/* Mobile navigation may only appear after login */
@media (max-width: 1370px) {

  body.ready .mobile-nav {
    display: flex !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

}


/* Mobile-only floating controls may only appear after login */
@media (max-width: 780px) {

  body.ready .toolkit-fab.mobile-only {
    display: flex !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

}


/* Header search is available on phones after login */
@media (max-width: 780px) {

  body.ready .mobile-search-btn {
    display: inline-flex !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

}

/* iPad: suppress duplicate header search */
@media (min-width: 781px) and (max-width: 1370px) {

  body.ready .mobile-search-btn {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

}

/* Ensure expanded house view modal content can receive touch events */
#expandedHouseView .house-expanded-content {
  touch-action: pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
}








/* Ensure Teacher Toolkit appears above Class Dashboard */
#teacherToolkitModal {
  z-index: 99999 !important;
}

#classDashboardModal {
  z-index: 30000 !important;
}

/* When toolkit is open, ensure it stays on top */
#teacherToolkitModal.show {
  z-index: 99999 !important;
}

/* ==========================================
   FINAL FORCE FIX: Search bar & Passcode side by side
   ========================================== */

/* Desktop & iPad - Force proper layout */
@media (min-width: 769px) {
  .top-row-container {
    justify-content: flex-start !important;
  }
  
  .search-select-container {
    margin-left: auto !important;
  }
  
  .search-group {
    flex-shrink: 0 !important;
  }
  
  #classPasscodeBadge {
    flex-shrink: 0 !important;
    margin-left: 0 !important;
  }
}



/* Hide scrollbar for Plan Selector Modal */
#planSelectorModal .modal-content::-webkit-scrollbar {
  display: none;
}

#pendingApprovalsCard, #approvedTeachersCard {
  transition: none !important;
  display: none;
}


/* ==========================================
   MOBILE/IPAD STUDENT MANAGEMENT - CLEAN LAYOUT
   ========================================== */

/* Three-dot overflow menu styles */
.overflow-menu-container {
  position: relative;
  display: inline-block;
}

.overflow-menu-trigger {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 40px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.overflow-menu-trigger:active {
  background: #e2e8f0;
}

.overflow-menu-trigger i {
  font-size: 16px;
  color: #64748b;
}

.overflow-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  border: 1px solid #e2e8f0;
  min-width: 200px;
  z-index: 1000;
  display: none;
  overflow: hidden;
  animation: menuSlideDown 0.2s ease;
}

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

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

.overflow-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: background 0.2s ease;
  border-bottom: 1px solid #f1f5f9;
}

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

.overflow-menu-item:active {
  background: #f1f5f9;
}

.overflow-menu-item i {
  width: 20px;
  font-size: 14px;
  color: #94a3b8;
}

.overflow-menu-item.danger {
  color: #ef4444;
}

.overflow-menu-item.danger i {
  color: #ef4444;
}

.divider {
  height: 1px;
  background: #f1f5f9;
  margin: 4px 0;
}

/* Mobile/iPad specific header layout */
@media (max-width: 1370px) {
  #students-section .students-header-row1 {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;

    padding:
      4px 12px !important;

    background:
      transparent !important;

    border-bottom:
      none !important;
  }
  
  #students-section .students-header-title {
    font-size: 18px !important;
    margin: 0 !important;
  }
  
  /* Hide all old action buttons on mobile/ipad */
  #students-section .students-header-actions {
    display: none !important;
  }
  
  /* Show the overflow menu on mobile/ipad only */
  .overflow-menu-container {
    display: block !important;
  }
  
  /* Keep desktop buttons hidden on mobile */
  .desktop-btn-group,
  .mobile-btn-group {
    display: none !important;
  }
}

/* Desktop: Hide overflow menu, show regular buttons */
@media (min-width: 1371px) {
  .overflow-menu-container {
    display: none !important;
  }
  
  #students-section .students-header-actions {
    display: flex !important;
  }
}

/* ==========================================
   ATTENDANCE STYLES
   ========================================== */

/* Attendance Bar - LIGHTER VERSION */
.attendance-bar {
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Date Row - Contains both Date and Rate badge */
.attendance-date-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.attendance-date {
  display: flex;
  align-items: center;
  gap: 8px;
}

.attendance-date i {
  font-size: 16px;
  color: #64748b;
}

.attendance-date .date-text {
  font-weight: 600;
  color: #475569;
  font-size: 13px;
}

/* Class Attendance Rate Badge - Shows "Attendance 75%" */
.class-attendance-rate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 30px;
  font-size: 11px;
  font-weight: 800;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.class-attendance-rate i {
  font-size: 10px;
}

.attendance-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.attendance-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

.attendance-stat.present { color: #10b981; }
.attendance-stat.absent { color: #ef4444; }
.attendance-stat.unmarked { color: #94a3b8; }

.attendance-stat .count {
  font-size: 15px;
  font-weight: 800;
}

.attendance-buttons {
  display: flex;
  gap: 8px;
}

.attendance-btn {
  padding: 10px 16px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.attendance-btn:active {
  transform: scale(0.97);
}

.attendance-btn-mark {
  background: #10b981;
  color: white;
}

.attendance-btn-mark:hover {
  background: #059669;
}

.attendance-btn-clear {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.attendance-btn-clear:hover {
  background: #e2e8f0;
}

.attendance-btn-save {
  background: #3b82f6;
  color: white;
  padding: 5px 16px;
  border-radius: 20px;
  font-weight: 600;
}

.attendance-btn-save:hover:not(:disabled) {
  background: #2563eb;
}

.attendance-btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.attendance-btn-history {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* Student Attendance Toggle - IMPROVED LARGER TOUCH TARGET */
.student-attendance-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 40px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  min-width: 90px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.student-attendance-toggle:active {
  transform: scale(0.97) !important;
}

/* Mobile-specific touch improvements */
@media (max-width: 780px) {
  .student-attendance-toggle {
    padding: 10px 12px !important;
    font-size: 13px !important;
    min-height: 44px !important;
  }
  
  .student-attendance-toggle i {
    font-size: 16px !important;
  }
}

/* Color states remain the same */
.student-attendance-toggle.present {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.student-attendance-toggle.absent {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.student-attendance-toggle.unmarked {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.student-attendance-toggle:hover {
  transform: scale(1.02);
}

.student-attendance-toggle i {
  font-size: 12px;
}

.student-attendance-toggle.present {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.student-attendance-toggle.absent {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.student-attendance-toggle.unmarked {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.student-attendance-toggle:hover {
  transform: scale(1.02);
}

.student-attendance-toggle i {
  font-size: 9px;
}

/* History Modal */
.attendance-history-table {
  width: 100%;
  border-collapse: collapse;
}

.attendance-history-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f1f5f9;
  font-weight: 700;
  color: #475569;
  font-size: 11px;
}

.attendance-history-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.attendance-history-table tr:hover td {
  background: #f8fafc;
}

.attendance-history-table .status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
}

/* Attendance Chips - 3 buttons side by side */
.attendance-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 30px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  flex: 1;
  background: #f1f5f9;
  color: #64748b;
}

.attendance-chip i {
  font-size: 9px;
}

.attendance-chip.present.active {
  background: #10b981;
  color: white;
  border-color: #059669;
}

.attendance-chip.present:not(.active):hover {
  background: #d1fae5;
  color: #065f46;
  border-color: #a7f3d0;
}

.attendance-chip.absent.active {
  background: #ef4444;
  color: white;
  border-color: #dc2626;
}

.attendance-chip.absent:not(.active):hover {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.attendance-chip.unmarked.active {
  background: #64748b;
  color: white;
  border-color: #475569;
}

.attendance-chip.unmarked:not(.active):hover {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

/* ==========================================
   MOBILE & TABLET RESPONSIVE STYLES
   ========================================== */

/* Mobile & iPad Responsive */
@media (max-width: 1370px) {
  /* Attendance Bar - Stack vertically */
  .attendance-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px !important;
    gap: 10px !important;
  }
  
  /* Date row - spread across with space-between */
  .attendance-date-row {
    justify-content: space-between;
    width: 100%;
  }
  
  .attendance-date {
    font-size: 12px;
  }
  
  .attendance-date .date-text {
    font-size: 11px !important;
  }
  
  /* Stats - spread evenly */
  .attendance-stats {
    justify-content: space-around;
    width: 100%;
  }
  
  /* Hide full text, show single letters on mobile */
  .attendance-stat span:not(.count) {
    display: none !important;
  }
  
  .attendance-stat .stat-label-desktop {
    display: none !important;
  }
  
  .attendance-stat .stat-label-mobile {
    display: inline-block !important;
    font-size: 9px !important;
    font-weight: 800 !important;
    margin-left: 2px !important;
  }
  
  .attendance-stat {
    gap: 2px !important;
  }
  
  .attendance-stat i {
    font-size: 12px !important;
  }
  
  .attendance-stat .count {
    font-size: 14px !important;
  }
  
  /* Buttons - spread evenly */
  .attendance-buttons {
    justify-content: space-between;
    width: 100%;
    gap: 4px !important;
  }
  
  .attendance-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 8px !important;
    font-size: 12px !important;
    border-radius: 30px !important;
    min-height: 48px !important;
  }
  
  .attendance-btn i {
    font-size: 14px !important;
  }
  
  .attendance-btn .btn-text-desktop {
    display: none !important;
  }
  
  .attendance-btn .btn-text-mobile {
    display: inline !important;
  }
  
  .attendance-btn-mark .btn-text-mobile,
  .attendance-btn-clear .btn-text-mobile {
    margin-left: 4px !important;
  }
  
  .attendance-btn-save {
    padding: 4px 10px !important;
  }
  
  .attendance-btn-save .btn-text-desktop {
    display: none !important;
  }
  
  /* Rate badge adjustments */
  .class-attendance-rate {
    font-size: 10px !important;
    padding: 3px 10px !important;
  }
  
  .class-attendance-rate i {
    display: inline-block !important;
  }
  
  /* Toolbar buttons */
  .cd-toolbar {
    padding: 8px !important;
    gap: 8px !important;
  }
  
  .cd-tool-btn {
    padding: 5px 8px !important;
    font-size: 10px !important;
  }
  
  .cd-tool-btn i {
    font-size: 10px !important;
  }
  
  .cd-add-btn {
    padding: 5px 10px !important;
    font-size: 10px !important;
  }
  
  .cd-add-btn i {
    font-size: 9px !important;
  }
  
  .tool-btn-text {
    font-size: 9px !important;
  }
}

/* Desktop: Show full text, hide mobile labels */
@media (min-width: 1371px) {
  .attendance-stat .stat-label-mobile {
    display: none !important;
  }
  
  .attendance-stat .stat-label-desktop {
    display: inline-block !important;
  }
  
  .attendance-btn .btn-text-mobile {
    display: none !important;
  }
  
  .attendance-btn .btn-text-desktop {
    display: inline !important;
  }
  
  .attendance-btn-save .btn-text-desktop {
    display: inline !important;
  }
  
  /* Desktop rate badge */
  .class-attendance-rate i {
    display: inline-block !important;
  }
}

/* Default: Hide mobile labels */
.stat-label-mobile {
  display: none;
}

.btn-text-mobile {
  display: none;
}

/* Small mobile (under 480px) - extra compact */
@media (max-width: 480px) {
  .attendance-bar {
    padding: 10px 12px !important;
    gap: 8px !important;
  }
  
  .attendance-date-row {
    justify-content: center;
  }
  
  .attendance-date {
    font-size: 10px;
  }
  
  .attendance-date i {
    font-size: 11px;
  }
  
  .class-attendance-rate {
    font-size: 9px !important;
    padding: 2px 8px !important;
  }
  
  /* Hide icon on very small screens */
  .class-attendance-rate i {
    display: none !important;
  }
  
  .attendance-stat .count {
    font-size: 13px !important;
  }
  
  .attendance-stat i {
    font-size: 10px !important;
  }
  
  .attendance-btn {
    padding: 8px 6px !important;
    font-size: 11px !important;
    min-height: 40px !important;
  }
  
  .attendance-btn i {
    font-size: 12px !important;
  }
  
  .cd-toolbar {
    flex-direction: column !important;
  }
  
  .cd-btn-group {
    justify-content: space-between !important;
    width: 100% !important;
  }
  
  .cd-tool-btn, .cd-add-btn {
    flex: 1 !important;
    justify-content: center !important;
  }
}

/* Tablet adjustments (781px - 1024px) */
@media (min-width: 781px) and (max-width: 1024px) {
  .class-attendance-rate {
    margin-left: 0 !important;
    padding: 3px 12px !important;
  }
  
  .class-attendance-rate i {
    display: inline-block !important;
  }
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}



/* ==========================================
   ATTENDANCE HISTORY MODAL - MOBILE FRIENDLY
   ========================================== */

/* Make tables scrollable horizontally on mobile */
#attendanceDailyContent,
#attendanceStudentContent {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

#attendanceDailyContent table,
#attendanceStudentContent table {
  min-width: 500px;
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 12px;
  overflow: hidden;
}

#attendanceDailyContent th,
#attendanceStudentContent th {
  background: #1e293b;
  color: white;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

#attendanceDailyContent td,
#attendanceStudentContent td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  white-space: nowrap;
}

/* Mobile specific adjustments */
@media (max-width: 780px) {
  #attendanceHistoryModal .house-expanded-content {
    padding: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
  }
  
  #attendanceHistoryModal .house-expanded-close {
    top: 10px !important;
    right: 10px !important;
    width: 36px !important;
    height: 36px !important;
    background: #ef4444 !important;
    z-index: 1000 !important;
  }
  
  /* Tab buttons - larger touch targets */
  #attendanceTabDaily,
  #attendanceTabStudent {
    padding: 14px 8px !important;
    font-size: 14px !important;
  }
  
  /* Table cells - larger for touch */
  #attendanceDailyContent td,
  #attendanceStudentContent td {
    padding: 12px 10px !important;
    font-size: 12px !important;
  }
  
  /* Footer buttons - side by side on mobile (not stacked) */
#attendanceHistoryModal .house-expanded-content > div:last-child {
  flex-direction: row !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
}

#attendanceHistoryModal .house-expanded-content > div:last-child button {
  flex: 1 !important;
  width: auto !important;
  padding: 12px !important;
  white-space: nowrap !important;
}

/* For very small phones (under 400px), allow text to wrap */
@media (max-width: 400px) {
  #attendanceHistoryModal .house-expanded-content > div:last-child button {
    white-space: normal !important;
    font-size: 12px !important;
  }
}
  
  /* Student summary table - card style on mobile (CENTERED) */
#attendanceStudentContent table {
  min-width: 100%;
}

#attendanceStudentContent td {
  display: block;
  text-align: center;
  border-bottom: none;
  padding: 8px 12px !important;
}

#attendanceStudentContent tr {
  display: block;
  margin-bottom: 16px;
  background: white;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

#attendanceStudentContent th {
  display: none;
}

/* Student Name row - distinct background */
#attendanceStudentContent td:first-child {
  font-weight: 800;
  background: linear-gradient(135deg, #f8fafc, #ffffff);
  padding: 14px !important;
  font-size: 16px !important;
  text-align: center;
  border-bottom: 1px solid #e2e8f0;
}

/* Data rows - centered with labels */
#attendanceStudentContent td {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 10px 12px !important;
  border-bottom: 1px solid #f1f5f9;
  text-align: center;
}

#attendanceStudentContent td:last-child {
  border-bottom: none;
}

/* Label styling */
#attendanceStudentContent td:before {
  content: attr(data-label);
  font-weight: 700;
  color: #64748b;
  font-size: 11px;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-block;
}

/* Value styling */
#attendanceStudentContent td span {
  font-weight: 700;
  min-width: 40px;
  text-align: center;
}

/* Status badge - centered */
#attendanceStudentContent td:last-child:before {
  background: transparent;
  padding: 0;
}
}



/* Daily Attendance Table - Mobile/Desktop column visibility */
.desktop-th {
  display: table-cell;
}

.mobile-th {
  display: none;
}

.desktop-td {
  display: table-cell;
}

.mobile-td {
  display: none;
}

/* On mobile: show icons, hide text labels, COMPACT WIDTH */
@media (max-width: 780px) {
  .desktop-th {
    display: none !important;
  }

  .mobile-th {
    display: table-cell !important;
  }
  
  .desktop-td {
    display: none !important;
  }
  
  .mobile-td {
    display: table-cell !important;
  }
  
  /* Make ALL header icons white */
  #attendanceDailyContent th {
    color: white !important;
    background: #10b981 !important;
  }
  
  /* Specifically target the Unmarked symbol (◌) - it's the 4th mobile column */
  #attendanceDailyContent th.mobile-th {
    color: white !important;
  }
  
  /* Also target by nth-child for the Unmarked column header */
  #attendanceDailyContent tr th:nth-child(4) {
    color: white !important;
  }
  
  /* Ensure the Unmarked numbers are visible (gray) */
  #attendanceDailyContent td.mobile-td:nth-child(4) {
    color: #94a3b8 !important;
  }
  
  /* Make table more compact on mobile */
  #attendanceDailyContent table {
    min-width: 100%;
    font-size: 11px;
  }
  
  /* Reduce padding on all cells */
  #attendanceDailyContent th,
  #attendanceDailyContent td {
    padding: 8px 4px !important;
  }
  
  /* Date column - compact */
  #attendanceDailyContent td:first-child,
  #attendanceDailyContent th:first-child {
    font-size: 10px !important;
    white-space: nowrap;
    padding-right: 6px !important;
  }
  
  /* TODAY badge - smaller */
  #attendanceDailyContent td:first-child span {
    font-size: 7px !important;
    padding: 1px 4px !important;
    margin-left: 2px !important;
  }
  
  /* Number columns - centered, compact */
  #attendanceDailyContent td:nth-child(2),
  #attendanceDailyContent td:nth-child(3),
  #attendanceDailyContent td:nth-child(4),
  #attendanceDailyContent td:nth-child(5) {
    padding: 8px 2px !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    text-align: center !important;
  }
  
  /* Rate badge - smaller */
  #attendanceDailyContent td:last-child span {
    font-size: 9px !important;
    padding: 2px 6px !important;
    white-space: nowrap;
  }
  
  /* Make header icons smaller */
  #attendanceDailyContent th {
    font-size: 10px !important;
    padding: 8px 2px !important;
    text-align: center !important;
  }
  
  /* Force table to not overflow */
  #attendanceDailyContent {
    overflow-x: auto;
  }
  
  #attendanceDailyContent table {
    width: 100%;
    table-layout: fixed;
  }
  
  /* Distribute width evenly */
  #attendanceDailyContent th:first-child { width: 35%; }
  #attendanceDailyContent th:nth-child(2) { width: 15%; }
  #attendanceDailyContent th:nth-child(3) { width: 15%; }
  #attendanceDailyContent th:nth-child(4) { width: 15%; }
  #attendanceDailyContent th:last-child { width: 20%; }
}



/* Tablet adjustments */
@media (min-width: 781px) and (max-width: 1024px) {
  #attendanceHistoryModal .house-expanded-content {
    width: 95vw !important;
    max-width: 900px !important;
    height: 85vh !important;
    border-radius: 20px !important;
  }
  
  #attendanceDailyContent table,
  #attendanceStudentContent table {
    min-width: 100%;
  }
}

/* Force Unmarked symbol to be white on mobile - ULTRA SPECIFIC */
@media (max-width: 780px) {
  #attendanceDailyContent table thead tr th.mobile-th {
    color: white !important;
  }
  
  /* Target by the actual symbol content */
  #attendanceDailyContent th:contains("◌") {
    color: white !important;
  }
}

/* ==========================================
   REWARD STARS GRID
   ========================================== */

.reward-stars-list {
  display:grid !important;
  grid-template-columns:
    repeat(4, minmax(0, 1fr)) !important;
  gap:12px !important;
}


/* iPad / tablet */
@media (max-width: 1100px) {

  .reward-stars-list {
    grid-template-columns:
      repeat(2, minmax(0, 1fr)) !important;
  }

}


/* Mobile */
@media (max-width: 600px) {

  .reward-stars-list {
    grid-template-columns:
      1fr !important;
  }

}




/* Activity Timer Section - New Placement */
.timer-preset-btn {
  transition: all 0.2s ease;
  cursor: pointer;
}

.timer-preset-btn:hover {
  transform: translateY(-2px);
  background: rgba(255,255,255,0.25) !important;
}

.timer-preset-btn.active-preset {
  background: #22d3ee !important;
  color: #0f172a !important;
  font-weight: 700 !important;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.5);
}

.timer-control-btn {
  transition: all 0.2s ease;
  cursor: pointer;
}

.timer-control-btn:hover {
  transform: scale(1.05);
}

.timer-control-btn:active {
  transform: scale(0.95);
}

/* Mobile adjustments for timer section */
@media (max-width: 780px) {
  .activity-timer-section {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  
  .timer-controls-group {
    justify-content: center !important;
  }
}



/* Animated gradient overlay on hover */
.nav-item.behavior-tracker-nav::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.12), transparent);
    transition: left 0.5s ease;
}

.nav-item.behavior-tracker-nav:hover::before {
    left: 100%;
}

.nav-item.behavior-tracker-nav:hover {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.18), rgba(59, 130, 246, 0.1));
    border-left-color: #2563eb;
    transform: translateX(2px);
}

.nav-item.behavior-tracker-nav i {
    color: #06b6d4;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.nav-item.behavior-tracker-nav:hover i {
    color: #2563eb;
    transform: scale(1.08);
}

.nav-item.behavior-tracker-nav span {
    color: #1e293b;
    font-weight: 600;
    transition: all 0.3s ease;
}

.nav-item.behavior-tracker-nav:hover span {
    color: #0f172a;
    font-weight: 700;
}

body.house-display-dark
.nav-item.behavior-tracker-nav span {
    color: #cbd5e1 !important;
}

body.house-display-dark
.nav-item.behavior-tracker-nav:hover span {
    color: #ffffff !important;
}

/* Active state */
.nav-item.behavior-tracker-nav.active {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(59, 130, 246, 0.12));
    border-left-color: #2563eb;
}

.nav-item.behavior-tracker-nav.active i {
    color: #2563eb;
}

.nav-item.behavior-tracker-nav.active span {
    color: #0f172a;
    font-weight: 700;
}

body.house-display-dark
.nav-item.behavior-tracker-nav.active span {
    color: #e2e8f0 !important;
}

/* Ripple effect on click */
.nav-item.behavior-tracker-nav:active {
    transform: scale(0.98);
    transition: transform 0.05s;
}





/* Ensure generate modal has proper styling */
#licenseGenerateModal {
  z-index: 2000000 !important;
}

#licenseGenerateModal .house-expanded-content {
  background: white !important;
  border-radius: 24px !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

#licenseGenerateModal .form-control {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  transition: all 0.2s ease;
}

#licenseGenerateModal .form-control:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

#licenseGenerateModal select.form-control {
  background-color: white;
  cursor: pointer;
}

@media (max-width: 768px) {
  #licenseGenerateModal .house-expanded-content {
    width: 95% !important;
    padding: 24px !important;
  }
  
  #licenseGenerateModal h2 {
    font-size: 20px !important;
  }
}


/* Plan Selector Modal - Mobile/iPad Full Screen Fix */
@media (max-width: 1024px) {
  #planSelectorModal {
    align-items: flex-start !important;
    padding: 0 !important;
  }
  
  #planSelectorModal .modal-content {
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    max-height: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  #planSelectorModal button[onclick="closePlanSelector()"] {
    position: fixed !important;
    top: 12px !important;
    right: 12px !important;
    z-index: 100 !important;
  }
  
  /* Adjust header padding for mobile */
  #planSelectorModal .modal-content > div:first-child {
    padding-top: 20px !important;
  }
  
  /* Ensure content is scrollable */
  #planSelectorModal .modal-content {
    display: flex !important;
    flex-direction: column !important;
  }
}



/* ==========================================
   FULL SCREEN MODALS FOR MOBILE
   ========================================== */
   @media (max-width: 768px) {
  /* Create School Modal */
  #schoolCreationOverlay {
    align-items: flex-start !important;
    padding: 0 !important;
  }
  
  #schoolCreationOverlay > div {
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    max-height: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 60px 20px 20px 20px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }
  
  /* Join School Modal */
  #joinSchoolOverlay {
    align-items: flex-start !important;
    padding: 0 !important;
  }
  
  #joinSchoolOverlay > div {
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    max-height: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 60px 20px 20px 20px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }
  
  /* Pending Admin Approval Modal */
  #joinSchoolOverlay .pending-approval-modal,
  [id*="joinSchoolOverlay"] > div {
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    max-height: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 60px 20px 20px 20px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }
  
  /* Any other modals that appear full screen on mobile */
  .house-expanded .house-expanded-content,
  .modal .modal-content {
    max-height: 100vh !important;
    overflow-y: auto !important;
  }
}



/* Responsive House Certificate Modal - Mobile Optimized */
@media (max-width: 780px) {

  #houseCertificateModal {
    width: 100vw !important;
    height: 100dvh !important;

    padding: 0 !important;
    margin: 0 !important;

    align-items: stretch !important;
    justify-content: flex-start !important;

    overflow: hidden !important;
  }

  #houseCertificateModal .house-cert-modal-content {
    width: 100vw !important;
    max-width: 100vw !important;

    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;

    margin: 0 !important;
    padding: 0 !important;

    border-radius: 0 !important;

    overflow-x: hidden !important;
    overflow-y: auto !important;

    box-sizing: border-box !important;
  }

  #houseCertificateModal
  .house-cert-modal-content
  > div:first-of-type {
    padding:
      calc(14px + env(safe-area-inset-top))
      14px
      12px
      14px !important;
  }

  #houseCertificateModal
  .house-cert-modal-content
  h2 {
    font-size: 18px !important;
    padding-right: 46px;
  }

  #houseCertificateModal
  #houseCertDownloadBtn {
    width: 100% !important;

    min-height: 44px !important;

    margin-top: 4px !important;

    justify-content: center !important;
  }

  #houseCertificateModal
  .house-cert-close-btn {
    top:
      calc(
        10px +
        env(safe-area-inset-top)
      ) !important;

    right: 12px !important;
  }

  #houseCertificateModal
  .house-cert-modal-content
  > div:last-of-type {
    flex: 1 1 auto;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 14px !important;

    box-sizing: border-box;
  }

  #houseCertificatePreviewContainer {
    width: 100% !important;

    min-height: 0 !important;

    padding: 0 !important;
  }

  #houseCertificatePreviewContainer img {
    display: block;

    width: 100% !important;
    max-width: 100% !important;

    height: auto !important;

    border-radius: 8px !important;
  }

}

/* ==========================================
   HOUSE WORD HUNT ADMIN
   Mobile / iPad / Desktop
   ========================================== */

#houseWordHuntAdminModal {
  align-items: stretch;
  justify-content: center;
  padding: 0;
}

#houseWordHuntAdminModal .house-word-hunt-admin-content {
  width: 100vw;
  max-width: 100vw;
  min-height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 0;
  padding: 28px 32px 24px 32px;
  position: relative;
  box-shadow: none;
}

.house-word-hunt-admin-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 44px;
  margin-bottom: 14px;
}

.house-word-hunt-admin-icon {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 14px;
  background: #ecfeff;
  color: #0891b2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.house-word-hunt-admin-header h2 {
  margin: 0 0 2px 0;
  color: #0f172a;
  font-size: 20px;
  font-weight: 800;
}

.house-word-hunt-admin-header p {
  margin: 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.35;
}

.house-word-hunt-status {
  padding: 16px 18px;
  border: 1px solid #bae6fd;
  background: #f0f9ff;
  color: #075985;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 22px;
}

.house-word-hunt-admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.house-word-hunt-field {
  min-width: 0;
}

.house-word-hunt-field label {
  display: block;
  margin-bottom: 6px;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.house-word-hunt-field select,
.house-word-hunt-field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: white;
  color: #0f172a;
  font-family: inherit;
  font-size: 16px;
  box-sizing: border-box;
}

.house-word-hunt-field input:focus,
.house-word-hunt-field select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.house-word-hunt-bonus-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.house-word-hunt-bonus-card {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
  padding: 12px;
  min-width: 0;
}

.house-word-hunt-bonus-card-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.house-word-hunt-bonus-card-label span:first-child {
  font-size: 16px;
}

.house-word-hunt-bonus-card input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: white;
  color: #0f172a;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  box-sizing: border-box;
}

.house-word-hunt-bonus-card input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.house-word-hunt-bonus-card.first {
  background: #fffbea;
  border-color: #fde68a;
}

.house-word-hunt-bonus-card.second {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.house-word-hunt-bonus-card.third {
  background: #fff7ed;
  border-color: #fdba74;
}

.house-word-hunt-bonus-card.fourth {
  background: #f8fafc;
  border-color: #dbeafe;
}

.house-word-hunt-auto-box {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 20px;
  padding: 16px;
  border-radius: 14px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  color: #5b21b6;
}

.house-word-hunt-auto-box > i {
  font-size: 22px;
  margin-top: 2px;
}

.house-word-hunt-auto-box strong {
  display: block;
  font-size: 14px;
  margin-bottom: 3px;
}

.house-word-hunt-auto-box span {
  display: block;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.5;
}

.house-word-hunt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.house-word-hunt-actions .btn {
  min-height: 44px;
}


/* ==========================================
   HOUSE WORD HUNT RESULTS
========================================== */

.house-word-hunt-results-panel {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #dbe5ee;
  border-radius: 18px;
  background: #f8fafc;
}

.house-word-hunt-results-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.house-word-hunt-results-kicker {
  color: #65a30d;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .7px;
  text-transform: uppercase;
}

.house-word-hunt-results-head h3 {
  margin: 4px 0 3px;
  color: #0f2742;
  font-size: 20px;
}

.house-word-hunt-results-head p {
  margin: 0;
  color: #64748b;
  font-size: 12px;
}

.house-word-hunt-results-refresh {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border: 1px solid #dbe5ee;
  border-radius: 11px;
  background: white;
  color: #475569;
  cursor: pointer;
}

.house-word-hunt-results-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 9px;
  margin-top: 16px;
}

.house-word-hunt-result-stat {
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 13px;
  background: white;
}

.house-word-hunt-result-stat strong {
  display: block;
  color: #0f2742;
  font-size: 22px;
  line-height: 1;
}

.house-word-hunt-result-stat span {
  display: block;
  margin-top: 5px;
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}

.house-word-hunt-results-content {
  margin-top: 15px;
}

.house-word-hunt-house-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 8px;
  margin-bottom: 15px;
}

.house-word-hunt-house-result {
  padding: 11px;
  border-radius: 12px;
  background: white;
  border: 1px solid #e2e8f0;
}

.house-word-hunt-house-result strong {
  display: block;
  color: #0f2742;
  font-size: 12px;
}

.house-word-hunt-house-result span {
  display: block;
  margin-top: 4px;
  color: #64748b;
  font-size: 10px;
}

.house-word-hunt-student-results {
  display: grid;
  gap: 8px;
}

.house-word-hunt-student-result {
  padding: 12px 13px;
  border-radius: 13px;
  background: white;
  border: 1px solid #e2e8f0;
}

.house-word-hunt-student-result-main {
  display: grid;
  grid-template-columns:
    minmax(150px,1.4fr)
    minmax(85px,.7fr)
    minmax(85px,.7fr)
    70px
    75px
    65px;
  gap: 10px;
  align-items: center;
}

.house-word-hunt-student-name {
  color: #0f2742;
  font-size: 12px;
  font-weight: 900;
}

.house-word-hunt-student-result small {
  color: #64748b;
  font-size: 9px;
  font-weight: 700;
}

.house-word-hunt-student-words {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid #eef2f7;
}

.house-word-hunt-word-chip {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 5px 8px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #15803d;
  font-size: 9px;
  font-weight: 900;
}


@media (max-width: 800px) {

  .house-word-hunt-results-summary {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }

  .house-word-hunt-house-results {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }

  .house-word-hunt-student-result-main {
    grid-template-columns: 1fr 1fr;
  }

}


@media (max-width: 520px) {

  .house-word-hunt-results-panel {
    padding: 13px;
  }

  .house-word-hunt-results-summary {
    grid-template-columns: 1fr 1fr;
  }

  .house-word-hunt-house-results {
    grid-template-columns: 1fr 1fr;
  }

}

@media (min-width: 768px) and (max-width: 1200px) {

  #houseWordHuntAdminModal {
    padding: 0 !important;
    align-items: stretch !important;
  }

  #houseWordHuntAdminModal .house-word-hunt-admin-content {
    width: 100vw !important;
    max-width: 100vw !important;
    min-height: 100vh;
    max-height: 100vh !important;
    border-radius: 0 !important;
    padding: 24px !important;
  }

}


/* Mobile */
@media (max-width: 767px) {

  #houseWordHuntAdminModal {
    padding: 0 !important;
    align-items: stretch !important;
  }

  #houseWordHuntAdminModal .house-word-hunt-admin-content {
    width: 100% !important;
    max-width: none !important;
    min-height: 100%;
    max-height: none !important;
    border-radius: 0 !important;
    padding: 64px 16px 24px 16px !important;
  }

  .house-word-hunt-admin-header {
    align-items: flex-start;
    gap: 12px;
    padding-right: 0;
  }

  .house-word-hunt-admin-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    font-size: 20px;
  }

  .house-word-hunt-admin-header h2 {
    font-size: 20px;
  }

  .house-word-hunt-admin-grid,
  .house-word-hunt-bonus-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .house-word-hunt-actions {
    flex-direction: column-reverse;
  }

  .house-word-hunt-actions .btn {
    width: 100%;
    min-height: 48px;
  }

}

/* iPad Portrait (768px - 1024px) - 3 columns */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  #houseMasterToolkitsModal .toolkit-grid-layout {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
  }
}

/* iPad Landscape (1024px - 1366px) - 3 or 4 columns */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
  #houseMasterToolkitsModal .toolkit-grid-layout {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 20px !important;
  }
}

/* Make sure the grid layout inside the modal uses grid, not flex */
#houseMasterToolkitsModal .toolkit-grid-layout {
  display: grid !important;
}

/* Ensure cards are full width in their grid cells */
#houseMasterToolkitsModal .toolkit-card {
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Ensure feedback modal appears above everything */
.feedback-modal {
  z-index: 200001 !important;
}
.feedback-modal .feedback-modal-content {
  z-index: 200002 !important;
}


.feedback-modal {
  animation: fadeIn 0.2s ease;
}
.feedback-modal-content {
  animation: modalSlideIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}







/* Welcome Toast Message */
.welcome-toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: white;
  padding: 8px 12px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10000;
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.3s ease;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.welcome-toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.welcome-toast:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #0f172a, #020617);
}

.welcome-toast i {
  font-size: 14px;
  color: #fbbf24;
}

.welcome-toast-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.1;
}

.welcome-toast-copy strong {
  font-size: 10px;
  font-weight: 850;
}

.welcome-toast-copy span {
  font-size: 8px;
  color: #cbd5e1;
  font-weight: 650;
}

.welcome-toast .toast-arrow {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.welcome-toast:hover .toast-arrow {
  transform: translateX(3px);
}

.welcome-toast .close-toast {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #94a3b8;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 3px;
  transition: all 0.2s;
}

.welcome-toast .close-toast i {
  font-size: 9px;
  color: inherit;
}

.welcome-toast .close-toast:hover {
  background: #ef4444;
  color: white;
}

/* Class Rewards Grid Responsive */
@media (max-width: 768px) {
  .class-rewards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
}

/* iPad (769px - 1024px) - keep 4 columns */
@media (min-width: 769px) and (max-width: 1024px) {
  .class-rewards-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 14px !important;
  }
}

/* Desktop (1025px and above) - keep 4 columns */
@media (min-width: 1025px) {
  .class-rewards-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
  }
}


/* Student Attendance Grid - Desktop: 5 per row */
.student-attendance-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

/* iPad/Tablet (768px - 1024px): 3 per row */
@media (min-width: 768px) and (max-width: 1024px) {
  .student-attendance-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 14px !important;
  }
}

/* Mobile (≤767px): 2 per row */
@media (max-width: 767px) {
  .student-attendance-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  
  /* Make cards smaller on mobile */
  .student-attendance-card {
    padding: 10px 12px !important;
  }
  
  .student-attendance-card > div:first-child {
    flex-direction: column !important;
    text-align: center !important;
    gap: 8px !important;
  }
  
  .student-attendance-card > div:first-child > div:first-child {
    margin: 0 auto !important;
  }
  
  .student-attendance-card > div:first-child > div:last-child {
    text-align: center !important;
  }
  
  .student-attendance-card .attendance-rate {
    font-size: 20px !important;
  }
}


/* Student Detail Modal - Stats Grid Responsive */
@media (max-width: 480px) {
  .attendance-stats-grid {
    gap: 8px !important;
  }
  .attendance-stats-grid > div {
    padding: 12px 8px !important;
  }
  .attendance-stats-grid > div > div:first-child {
    font-size: 22px !important;
  }
}



/* Force Attendance History Modal to full height on all devices */
#attendanceHistoryModal {
  align-items: flex-start !important;
  justify-content: flex-start !important;
  padding: 0 !important;
  background: rgba(0,0,0,0.8) !important;
}

#attendanceHistoryModal .house-expanded-content {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* Ensure content areas take full height and scroll properly */
#attendanceDailyContent,
#attendanceStudentContent {
  flex: 1 !important;
  overflow-y: auto !important;
  padding: 16px !important;
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
  #attendanceHistoryModal .house-expanded-content {
    height: 100vh !important;
  }
  
  #attendanceDailyContent,
  #attendanceStudentContent {
    padding: 12px !important;
  }
}

/* Student Attendance Detail Modal - Full Height */
#studentAttendanceDetailModal {
  align-items: flex-start !important;
  justify-content: flex-start !important;
  padding: 0 !important;
  background: rgba(0,0,0,0.8) !important;
}

#studentAttendanceDetailModal .house-expanded-content {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* Stats cards responsive on mobile */
@media (max-width: 480px) {
  #studentAttendanceDetailModal .attendance-stats-grid {
    gap: 8px !important;
  }
  #studentAttendanceDetailModal .attendance-stats-grid > div {
    padding: 10px 6px !important;
  }
  #studentAttendanceDetailModal .attendance-stats-grid > div > div:first-child {
    font-size: 20px !important;
  }
}

/* Mobile Create School Modal Fix */
@media (max-width: 768px) {
  #schoolCreationOverlay {
    align-items: flex-start !important;
    padding: 0 !important;
  }
  
  #schoolCreationOverlay > div {
    margin: 10px auto !important;
    padding: 20px !important;
    max-height: 95vh !important;
    border-radius: 20px !important;
  }
  
  #schoolCreationOverlay .form-group input,
  #schoolCreationOverlay .form-group select {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }
  
  #createSchoolBtn {
    margin-bottom: 10px !important;
  }
}


/* ==========================================
   BACKGROUND FLOATING ECOSYSTEM ELEMENTS
   ========================================== */

.floating-ecosystem-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Allows clicks to pass through to the modal */
  z-index: 1;
  overflow: hidden;
}

/* Base Glassmorphism Card Style */
.floating-card {
  position: absolute;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  padding: 16px 20px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  pointer-events: none;
}

/* ==========================================
   PILLAR 1: TEACHER APP (Magic Hat)
   ========================================== */
.floating-teacher {
  top: 12%;
  left: 5%;
  animation: floatTeacher 4s ease-in-out infinite;
}

.floating-teacher-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.floating-teacher .magic-hat-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.mini-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.mini-leaderboard-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 600;
}

.mini-leaderboard-bar {
  width: 60px;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
}

.mini-leaderboard-fill {
  height: 100%;
  width: 70%;
  background: #10b981;
  border-radius: 2px;
}

/* ==========================================
   PILLAR 2: STUDENT APP (3D Holographic Card)
   ========================================== */
.floating-student {
  bottom: 15%;
  right: 3%;
  animation: floatStudent 6s ease-in-out infinite 1s;
  transform-style: preserve-3d;
}

.holographic-card {
  width: 120px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(139, 92, 246, 0.2));
  border-radius: 16px;
  padding: 12px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.holographic-card .card-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.holographic-card .card-label {
  font-size: 10px;
  font-weight: 700;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: cardShine 4s ease-in-out infinite;
  border-radius: 16px;
  pointer-events: none;
}

/* ==========================================
   PILLAR 3: BEHAVIOR TRACKER (Pulse Graph)
   ========================================== */
.floating-behavior {
  top: 50%;
  right: 8%;
  transform: translateY(-50%);
  animation: pulseOpacity 2s ease-in-out infinite;
  padding: 14px 18px;
}

.pulse-graph {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 40px;
}

.pulse-bar {
  width: 6px;
  background: linear-gradient(180deg, #f59e0b, #ef4444);
  border-radius: 3px;
  transition: height 0.3s ease;
}

.pulse-bar:nth-child(1) { height: 20px; animation: pulseBar 2s ease-in-out infinite 0s; }
.pulse-bar:nth-child(2) { height: 35px; animation: pulseBar 2s ease-in-out infinite 0.2s; }
.pulse-bar:nth-child(3) { height: 15px; animation: pulseBar 2s ease-in-out infinite 0.4s; }
.pulse-bar:nth-child(4) { height: 28px; animation: pulseBar 2s ease-in-out infinite 0.6s; }
.pulse-bar:nth-child(5) { height: 10px; animation: pulseBar 2s ease-in-out infinite 0.8s; }

.pulse-label {
  font-size: 9px;
  font-weight: 700;
  color: #64748b;
  margin-top: 8px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================
   PILLAR 4: SCHOOL CULTURE (Reactor Ring)
   ========================================== */
.floating-culture {
  bottom: 20%;
  left: 8%;
  animation: floatCulture 5s ease-in-out infinite 0.5s;
  padding: 12px;
}

.reactor-ring {
  position: relative;
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reactor-core {
  width: 24px;
  height: 24px;
  background: radial-gradient(circle, #fbbf24, #d97706);
  border-radius: 50%;
  box-shadow: 0 0 20px #fbbf24;
  animation: corePulse 3s ease-in-out infinite;
}

.reactor-ring-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  border: 2px solid rgba(251, 191, 36, 0.4);
  animation: ringPulse 3s ease-in-out infinite;
}

.reactor-ring-glow:nth-child(2) {
  animation-delay: 0.5s;
  border-width: 3px;
}

.reactor-label {
  font-size: 9px;
  font-weight: 700;
  color: #d97706;
  text-align: center;
  margin-top: 8px;
  text-transform: uppercase;
}

/* ==========================================
   ANIMATIONS
   ========================================== */

@keyframes floatTeacher {
  0% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
  100% { transform: translateY(0px) rotate(0deg); }
}

@keyframes floatStudent {
  0% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-15px) rotate(3deg); }
  100% { transform: translateY(0px) rotate(0deg); }
}

@keyframes floatCulture {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0px); }
}

@keyframes pulseOpacity {
  0% { opacity: 0.6; transform: translateY(-50%) scale(1); }
  50% { opacity: 1; transform: translateY(-50%) scale(1.02); }
  100% { opacity: 0.6; transform: translateY(-50%) scale(1); }
}

@keyframes pulseBar {
  0% { opacity: 0.4; transform: scaleY(0.9); }
  50% { opacity: 1; transform: scaleY(1.1); }
  100% { opacity: 0.4; transform: scaleY(0.9); }
}

@keyframes cardShine {
  0% { left: -100%; }
  20% { left: 100%; }
  100% { left: 100%; }
}

@keyframes corePulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes ringPulse {
  0% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.4); opacity: 0.2; }
  100% { transform: scale(1); opacity: 0.6; }
}

/* ==========================================
   RESPONSIVE: Hide some elements on mobile
   ========================================== */
@media (max-width: 1024px) {
  .floating-behavior,
  .floating-culture {
    display: none;
  }
  .floating-teacher { top: 5%; left: 2%; }
  .floating-student { bottom: 5%; right: 2%; }
}

@media (max-width: 768px) {
  .floating-teacher,
  .floating-student {
    transform: scale(0.8);
  }
  .floating-teacher { top: 2%; left: 0%; }
  .floating-student { bottom: 2%; right: 0%; }
}





@media (max-width: 480px) {
  .auth-card { 
    overflow-y: auto !important;
  }
}

#activationCodeModal {
    z-index: 2000001 !important; /* Higher than paywall */
  }
  #activationCodeModal .house-expanded-content {
    position: relative;
    z-index: 2000002;
  }



  /* Fix for certificate modal footer visibility */
#classCertificateModal .house-expanded-content {
  display: flex !important;
  flex-direction: column !important;
  max-height: 90vh !important;
  height: auto !important;
}

#classCertificateModal #certificatePreviewContainer {
  flex: 1 !important;
  overflow-y: auto !important;
  max-height: calc(90vh - 80px) !important;
}

#classCertificateModal .house-expanded-content > div:last-child {
  flex-shrink: 0 !important;
  position: sticky !important;
  bottom: 0 !important;
  background: #f8fafc !important;
  z-index: 10 !important;
}







.housepoints-trackedu-updates {
  display: none;
}

@media (min-width: 1371px) {

  .header {
    gap: 16px;
  }

  .logo-inline {
    flex: 0 1 auto;
    min-width: 0;
  }

  .housepoints-trackedu-updates {
    position: relative;
    display: block;
    flex: 1 1 520px;
    width: auto;
    max-width: 650px;
    min-width: 300px;
    height: 34px;
    overflow: hidden;
    margin: 0 auto;
  }

  .housepoints-trackedu-update {
    position: absolute;
    inset: 0;

    display: flex;
    align-items: center;
    gap: 8px;

    min-width: 0;
    padding: 6px 12px;

    border: 1px solid #dbeafe;
    border-radius: 999px;

    background: #f8fbff;
    color: #475569;

    text-decoration: none;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transform: translateY(5px);

    animation:
      housepointsTrackEduRotation
      24s
      infinite
      ease;
  }

  .housepoints-trackedu-update:nth-child(1) {
    animation-delay: 8s;
  }

  .housepoints-trackedu-update:nth-child(2) {
    animation-delay: 16s;
  }

  .housepoints-trackedu-updates:hover
  .housepoints-trackedu-update {
    animation-play-state: paused;
  }

  .housepoints-update-kicker {
    flex: 0 0 auto;

    color: #64748b;
    font-size: 8px;
    line-height: 1;
    font-weight: 900;

    letter-spacing: 0.55px;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .housepoints-update-copy {
    min-width: 0;
    flex: 1 1 auto;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: #475569;
    font-size: 10.5px;
    line-height: 1;
    font-weight: 600;
  }

  .housepoints-update-copy strong {
    color: #1e293b;
    font-weight: 800;
  }

  .housepoints-update-arrow {
    flex: 0 0 auto;

    color: #16a34a;
    font-size: 11px;
    font-weight: 900;
  }

  .housepoints-trackedu-update:hover {
    background: #f0fdf4;
    border-color: #bbf7d0;
  }

  @keyframes housepointsTrackEduRotation {
    0% {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transform: translateY(5px);
    }

    4%,
    28% {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transform: translateY(0);
    }

    33%,
    100% {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transform: translateY(-5px);
    }
  }
}

@media (max-width: 1370px) {
  .housepoints-trackedu-updates {
    display: none !important;
  }
}


.hp-teacher-demo-click {
  position: relative;
  z-index: 5000004 !important;

  animation:
    hpTeacherDemoClick
    .34s ease !important;
}

@keyframes hpTeacherDemoClick {
  0% {
    box-shadow:
      0 0 0 0
      rgba(37,99,235,.45);
  }

  50% {
    box-shadow:
      0 0 0 8px
      rgba(37,99,235,.20);
  }

  100% {
    box-shadow:
      0 0 0 14px
      rgba(37,99,235,0);
  }
}


@keyframes teacherWeekConfettiFall {
  0% {
    transform:
      translateY(-30px)
      rotate(0deg);
    opacity: 0;
  }

  12% {
    opacity: 1;
  }

  100% {
    transform:
      translateY(100vh)
      rotate(520deg);
    opacity: 0;
  }
}


/* =========================================================
   DESKTOP SMART MENU
   Desktop only
   Mobile + iPad remain unchanged
   ========================================================= */
@media (min-width: 1371px) {

  .smart-menu-drawer {
    left: 50% !important;

    width:
      min(
        1180px,
        calc(100vw - 48px)
      ) !important;

    max-height:
      calc(100vh - 80px) !important;

    transform:
      translateX(-50%) !important;

    border-radius:
      22px !important;

    overflow-x:
      auto !important;

    overflow-y:
      hidden !important;

    padding-bottom:
      0 !important;

    box-shadow:
      0 24px 70px rgba(15, 23, 42, 0.22),
      0 4px 14px rgba(15, 23, 42, 0.08) !important;

    border:
      1px solid #e2e8f0 !important;

    background:
      #ffffff !important;

    scrollbar-width:
      thin;
  }

  .smart-menu-drawer.active {
    bottom: 24px !important;
  }


  /* HEADER */
  .smart-menu-header {
    min-height: 66px !important;
    padding: 12px 18px !important;

    background: #ffffff !important;
    border-bottom: 1px solid #eef2f7 !important;
  }

  .smart-menu-brand {
    display: inline-block !important;
    font-size: 18px !important;
    line-height: 1 !important;
    letter-spacing: -0.4px !important;
  }

  .smart-menu-header > div:first-child > div {
    gap: 2px !important;
  }

  .smart-menu-header > div:first-child > div > div {
    margin-top: 3px !important;
  }

  .smart-menu-header > div:first-child > div > div span {
    font-size: 10px !important;
    color: #94a3b8 !important;
    font-weight: 700 !important;
  }

  .smart-menu-header button {
    width: 34px !important;
    height: 34px !important;
    font-size: 14px !important;

    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
  }

  .smart-menu-header button:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    transform: scale(1.05);
  }


  /* MAIN TOOL GRID
   9 desktop tools.
   Keep all tools on one row when space allows.
   On smaller laptop screens the drawer can
   scroll horizontally instead of clipping.
*/
.smart-menu-grid {
  grid-template-columns:
    repeat(
      9,
      minmax(96px, 1fr)
    ) !important;

  justify-content:
    center !important;

  align-items:
    start !important;

  gap:
    10px !important;

  width:
    max-content;

  min-width:
    100%;

  padding:
    22px
    24px
    20px !important;

  flex:
    none !important;

  overflow:
    visible !important;

  background:
    #ffffff;
}

  .smart-menu-grid .smart-menu-item {
    gap: 7px !important;
    min-width: 0;

    padding: 8px 4px !important;
    border-radius: 14px;

    transition:
      background 0.18s ease,
      transform 0.18s ease !important;
  }

  .smart-menu-grid .smart-menu-item:hover {
    background: #f8fafc;
    transform: translateY(-2px);
  }

  .smart-menu-grid .smart-menu-item .icon-box {
    width: 50px !important;
    height: 50px !important;

    border-radius: 14px !important;

    font-size: 21px !important;
    box-shadow: none !important;
  }

  .smart-menu-grid .smart-menu-item span {
  max-width:
    112px !important;

  font-size:
    10.5px !important;

  line-height:
    1.25 !important;

  font-weight:
    700 !important;

  color:
    #475569 !important;

  white-space:
    normal;

  text-align:
    center;
}

  /* Existing desktop-hidden duplicates */
  .desktop-menu-duplicate,
  .projector-menu-item {
    display: none !important;
  }


  /* Desktop logout behaves exactly like the other menu items */
  .smart-menu-desktop-logout {
    display: flex !important;
  }

  .smart-menu-desktop-logout span {
    color: #dc2626 !important;
  }

  .smart-menu-desktop-logout:hover {
    background: #fff1f2 !important;
  }


  /* Completely remove the old bottom profile/avatar/licence/footer
     on DESKTOP ONLY */
  .smart-menu-profile-footer {
    display: none !important;
  }
}


/* Hide desktop-only menu items everywhere except desktop */
@media (max-width: 1370px) {
  .smart-menu-desktop-logout,
  .smart-menu-trust-centre {
    display: none !important;
  }
}

@media (min-width: 1371px) {

  /*
   * Desktop Menu:
   * These tools already exist in the main sidebar,
   * so do not duplicate them here.
   */
  .smart-menu-grid
  .behavior-tracker-nav,

  .smart-menu-grid
  .smart-menu-item[
    onclick^="openMyClassDashboard"
  ],

  .smart-menu-grid
  .student-recognition-launch {
    display:none !important;
  }

}

/* ==========================================
   DESKTOP SYSTEM SETUP - FULL WIDTH
   ========================================== */
@media (min-width: 1371px) {

  #systemSetupModal .house-expanded-content {
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    max-height: none !important;

    padding: 24px 32px 32px !important;
    margin: 0 !important;

    border-radius: 0 !important;

    overflow-y: auto !important;
  }


  .system-setup-page-inner {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
  }


  .setup-wizard-card {
    width: 100% !important;
  }


  /* Main setup cards use the full desktop width */
  .system-setup-page-inner
  > div[style*="grid-template-columns"] {
    width: 100% !important;
  }

}


/* ==========================================
   LIVE HOUSE RACE GAP CHIPS
   ========================================== */

.leaderboard-gap-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;

  margin-left: 8px;
  padding: 3px 8px;

  border-radius: 999px;

  font-size: 10px;
  line-height: 1.2;
  font-weight: 700;

  white-space: nowrap;

  opacity: 0;
  transform:
    translateY(4px)
    scale(0.94);

  animation:
    leaderboardGapReveal
    0.5s
    cubic-bezier(0.34, 1.56, 0.64, 1)
    var(--gap-delay, 1.65s)
    forwards;
}


.leaderboard-gap-chip strong {
  font-weight: 900;
}


/* Leader */
.leader-gap-chip {
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}


/* Chasing house */
.chase-gap-chip {
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
}


@keyframes leaderboardGapReveal {
  0% {
    opacity: 0;
    transform:
      translateY(4px)
      scale(0.94);
  }

  70% {
    opacity: 1;
    transform:
      translateY(-1px)
      scale(1.04);
  }

  100% {
    opacity: 1;
    transform:
      translateY(0)
      scale(1);
  }
}


@media (prefers-reduced-motion: reduce) {
  .leaderboard-gap-chip {
    opacity: 1;
    transform: none;
    animation: none;
  }
}


/* =========================================================
   LEADERBOARD DISPLAY STYLES
   Desktop + iPad ONLY
   Mobile under 781px remains completely unchanged
   ========================================================= */

.leaderboard-style-control {
  display: none;
}


/*
 * Only show the display selector on iPad
 * and desktop-sized screens.
 */
@media (min-width: 781px) {

  .leaderboard-style-control {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    height: 34px;

    padding:
      0
      8px
      0
      11px;

    background: #ffffff;

    border:
      1px solid
      #cbd5e1;

    border-radius: 999px;

    color: #475569;

    box-shadow:
      0 2px 6px
      rgba(15,23,42,0.06);

    flex-shrink: 0;
  }


  .leaderboard-style-control > i {
    font-size: 11px;
    color: #6366f1;
  }


  .leaderboard-style-control select {
    appearance: none;
    -webkit-appearance: none;

    border: none;
    outline: none;

    background:
      transparent;

    color: #334155;

    font-family: inherit;
    font-size: 10px;
    font-weight: 800;

    cursor: pointer;

    padding:
      0
      18px
      0
      0;

    min-width: 82px;

    background-image:
      url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364758b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");

    background-repeat:
      no-repeat;

    background-position:
      right center;

    background-size:
      12px;
  }


  /* =======================================================
     CLASSIC
     Existing TrackEDU appearance
     ======================================================= */

  #leaderboardBars.leaderboard-style-classic {
    display: block;
  }


  /* =======================================================
     MODERN
     Premium TrackEDU leaderboard
     ======================================================= */

  #leaderboardBars.leaderboard-style-modern {
    display:
      flex;

    flex-direction:
      column;

    gap:
      10px;

    padding:
      4px
      0;

    height: auto !important;
    min-height: 0 !important;
  }

  @media (min-width: 1371px) {
    #dashboard-section .card:has(#leaderboardBars) {
      height: fit-content !important;
      min-height: 0 !important;
      align-self: start !important;
      padding-bottom: 12px !important;
    }
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-item {
    position:
      relative;

    display:
      grid !important;

    grid-template-columns:
      78px
      minmax(180px, 0.85fr)
      minmax(280px, 1.5fr)
      220px !important;

    align-items:
      center !important;

    gap:
      18px !important;

    min-height:
      94px;

    margin:
      0 !important;

    padding:
      17px
      20px !important;

    background:
      linear-gradient(
        135deg,
        color-mix(
          in srgb,
          var(--house-color) 6%,
          #ffffff
        ) 0%,
        color-mix(
          in srgb,
          var(--house-color) 3%,
          #ffffff
        ) 100%
      ) !important;

    border:
      1px solid
      color-mix(
        in srgb,
        var(--house-color) 15%,
        #e7edf4
      ) !important;

    border-radius:
      18px !important;

    box-shadow:
      0 4px 14px
      rgba(15,23,42,0.045) !important;

    overflow:
      hidden;

    transform:
      none !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-item::before {
    content:
      "";

    position:
      absolute;

    left:
      0;

    top:
      18px;

    bottom:
      18px;

    width:
      4px;

    border-radius:
      0
      999px
      999px
      0;

    background:
      var(--house-color);
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-item:hover {
    background:
      linear-gradient(
        135deg,
        color-mix(
          in srgb,
          var(--house-color) 9%,
          #ffffff
        ) 0%,
        color-mix(
          in srgb,
          var(--house-color) 5%,
          #ffffff
        ) 100%
      ) !important;

    border-color:
      color-mix(
        in srgb,
        var(--house-color) 24%,
        #dbe4ee
      ) !important;

    box-shadow:
      0 8px 22px
      color-mix(
        in srgb,
        var(--house-color) 9%,
        transparent
      ) !important;

    transform:
      translateY(-1px) !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-rank {
    grid-column:
      1 !important;

    width:
      70px !important;

    min-width:
      70px !important;

    min-height:
      64px;

    height:
      auto !important;

    display:
      flex !important;

    flex-direction:
      column !important;

    align-items:
      center !important;

    justify-content:
      center !important;

    gap:
      5px !important;

    padding:
      7px 5px !important;

    border-radius:
      16px;

    background:
      #f8fafc;

    border:
      1px solid
      #e2e8f0;

    box-shadow:
      inset
      0 1px 0
      rgba(255,255,255,0.8);

    overflow:
      visible !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-rank
  > span {
    display:
      block !important;

    font-size:
      25px !important;

    line-height:
      1 !important;
  }


  /* 4th place and below */
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-rank
  > div:first-child {
    display:
      flex !important;

    flex-direction:
      column !important;

    align-items:
      center !important;

    justify-content:
      center !important;

    line-height:
      1 !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-rank
  > div:first-child
  > div:first-child {
    font-size:
      19px !important;

    line-height:
      1 !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-rank
  > div:first-child
  > div:last-child {
    margin-top:
      4px !important;

    font-size:
      8px !important;

    line-height:
      1 !important;
  }


  /* Rank movement badge: always below medal/rank */
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-rank
  > div[style*="margin-top"] {
    position:
      static !important;

    display:
      inline-flex !important;

    margin:
      0 !important;

    transform:
      none !important;

    flex-shrink:
      0 !important;

    align-self:
      center !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-house {
    grid-column:
      2 !important;

    display:
      flex !important;

    flex-direction:
      row !important;

    align-items:
      center !important;

    justify-content:
      flex-start !important;

    flex-wrap:
      wrap !important;

    column-gap:
      10px !important;

    row-gap:
      4px !important;

    min-width:
      0 !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-house
  > span:first-child {
    color:
      #0f172a !important;

    font-size:
      20px !important;

    line-height:
      1.05 !important;

    font-weight:
      850 !important;

    letter-spacing:
      -0.35px;

    -webkit-text-stroke:
      0 !important;

    text-shadow:
      none !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-gap-chip {
    display:
      inline-flex !important;

    margin:
      0 !important;

    padding:
      3px
      8px !important;

    border-radius:
      999px !important;

    border:
      1px solid
      #e2e8f0 !important;

    background:
      #f8fafc !important;

    color:
      #64748b !important;

    font-size:
      9.5px !important;

    font-weight:
      750 !important;

    opacity:
      1 !important;

    animation:
      none !important;

    transform:
      none !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-bar-container {
    grid-column:
      3 !important;

    height:
      16px !important;

    margin:
      0 !important;

    border-radius:
      999px !important;

    background:
      #edf2f7 !important;

    box-shadow:
      inset
      0 1px 2px
      rgba(15,23,42,0.07);
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-bar {
    position:
      relative;

    border:
      none !important;

    border-radius:
      999px !important;

    box-shadow:
      inset
      0 1px 0
      rgba(255,255,255,0.45) !important;
  }

  #leaderboardBars .leaderboard-badge-progress {
    position: relative;
  }

  #leaderboardBars .leaderboard-progress-interaction {
    position: relative;
    width: 100%;
    cursor: pointer;
    outline-offset: 4px;
  }

    #leaderboardBars .leaderboard-progress-detail {
    display: flex;
    visibility: visible;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: static;
    width: 100%;
    min-height: 19px;
    box-sizing: border-box;
    margin-top: 5px;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: #475569;
    font-size: 11px;
    font-weight: 650;
    line-height: 19px;
    white-space: nowrap;
    overflow: hidden;
    text-align: left;
    opacity: 0.18;
    transition: opacity 100ms ease;
  }

  #leaderboardBars .leaderboard-progress-interaction:hover .leaderboard-progress-detail,
  #leaderboardBars .leaderboard-progress-interaction:focus-within .leaderboard-progress-detail {
    opacity: 1;
  }

  #leaderboardBars .leaderboard-progress-separator {
    color: #cbd5e1;
  }

  /* Leaderboard information in dark mode */
  body.house-display-dark #leaderboardBars .leaderboard-progress-detail,
  body.dark-mode #leaderboardBars .leaderboard-progress-detail {
    color: #cbd5e1 !important;
  }

  body.house-display-dark #leaderboardBars .leaderboard-progress-detail span,
  body.dark-mode #leaderboardBars .leaderboard-progress-detail span {
    color: #cbd5e1 !important;
  }

  body.house-display-dark #leaderboardBars .leaderboard-progress-separator,
  body.dark-mode #leaderboardBars .leaderboard-progress-separator {
    color: #94a3b8 !important;
  }

  #leaderboardBars .leaderboard-progress-detail-title {
    font-size: 13px;
    font-weight: 800;
    line-height: 1.4;
    color: #0f172a;
  }

  #leaderboardBars .leaderboard-progress-detail-note {
    font-size: 12px;
    line-height: 1.5;
    color: #475569;
    margin-top: 3px;
  }

  #leaderboardBars .leaderboard-progress-detail-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 10px 0;
  }

  @media (max-width: 1200px) {
    #leaderboardBars .leaderboard-progress-detail {
      display: none;
    }
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-bar::after {
    content:
      "";

    position:
      absolute;

    inset:
      1px;

    border-radius:
      inherit;

    background:
      linear-gradient(
        180deg,
        rgba(255,255,255,0.22),
        transparent
      );
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-points {
    grid-column:
      4 !important;

    width:
      100% !important;

    min-width:
      0 !important;

    justify-content:
      flex-end !important;

    gap:
      5px !important;

    white-space:
      nowrap !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-points
  .casino-counter {
    font-size:
      43px !important;

    line-height:
      1 !important;

    font-weight:
      900 !important;

    letter-spacing:
      -1.2px !important;

    text-shadow:
      0 2px 5px
      rgba(15,23,42,0.10) !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-points
  span:last-child {
    font-size:
      12px !important;

    color:
      #94a3b8 !important;
  }


  /* =======================================================
     HOUSE RACE
     Premium competition display
     ======================================================= */

  #leaderboardBars.leaderboard-style-race {
    position:
      relative;

    padding:
      18px;

    border-radius:
      20px;

    background:
      linear-gradient(
        180deg,
        #f8fbff 0%,
        #eef5fb 100%
      );

    border:
      1px solid
      #dce7f2;

    box-shadow:
      inset
      0 1px 0
      rgba(255,255,255,0.9);

    overflow:
      hidden;
  }


  #leaderboardBars.leaderboard-style-race::before {
    content:
      "HOUSE RACE";

    display:
      flex;

    align-items:
      center;

    margin-bottom:
      16px;

    color:
      #334155;

    font-size:
      10px;

    line-height:
      1;

    font-weight:
      900;

    letter-spacing:
      1.6px;
  }


  #leaderboardBars.leaderboard-style-race::after {
    content:
      "Every point moves your House forward";

    position:
      absolute;

    top:
      15px;

    right:
      18px;

    color:
      #94a3b8;

    font-size:
      9px;

    font-weight:
      700;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-item {
    display:
      grid !important;

    grid-template-columns:
      52px
      minmax(170px, 0.75fr)
      minmax(320px, 1.7fr)
      145px !important;

    gap:
      16px !important;

    align-items:
      center !important;

    min-height:
      82px;

    position:
      relative;

    margin:
      0
      0
      8px !important;

    padding:
      12px
      16px !important;

    background:
      rgba(255,255,255,0.72) !important;

    border:
      1px solid
      rgba(203,213,225,0.60) !important;

    border-radius:
      15px !important;

    box-shadow:
      none !important;

    backdrop-filter:
      blur(6px);
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-item:last-child {
    margin-bottom:
      0 !important;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-item:hover {
    background:
      #ffffff !important;

    border-color:
      #cbd5e1 !important;

    transform:
      translateX(2px) !important;

    box-shadow:
      0 6px 16px
      rgba(15,23,42,0.06) !important;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-rank {
    grid-column:
      1 !important;

    width:
      58px !important;

    min-width:
      58px !important;

    min-height:
      56px;

    display:
      flex !important;

    flex-direction:
      column;

    align-items:
      center;

    justify-content:
      center;

    gap:
      5px;

    text-align:
      center !important;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-rank
  > span {
    display:
      block;

    font-size:
      27px !important;

    line-height:
      1;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-rank
  div[style*="margin-top"] {
    margin-top:
      0 !important;

    position:
      static !important;

    transform:
      none !important;

    flex-shrink:
      0;

    font-size:
      9px !important;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-house {
    grid-column:
      2 !important;

    min-width:
      0 !important;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-rank
  > div:first-child {
    line-height:
      1.05;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-rank
  > div:first-child
  > div:first-child {
    font-size:
      18px !important;

    line-height:
      1 !important;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-rank
  > div:first-child
  > div:last-child {
    margin-top:
      3px;

    font-size:
      8px !important;

    line-height:
      1 !important;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-house
  > span:first-child {
    font-size:
      19px !important;

    font-weight:
      850 !important;

    letter-spacing:
      -0.25px;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-gap-chip {
    margin:
      3px
      0
      0 !important;

    padding:
      2px
      7px !important;

    font-size:
      9px !important;

    background:
      rgba(255,255,255,0.65) !important;

    backdrop-filter:
      blur(6px);

    font-weight:
      750 !important;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-bar-container {
    grid-column:
      3 !important;

    position:
      relative;

    width:
      100% !important;

    min-width:
      0 !important;

    height:
      34px !important;

    margin:
      0 !important;

    border-radius:
      12px !important;

    overflow:
      visible !important;

    background-color:
      #e5ebf2 !important;

    background-image:
      repeating-linear-gradient(
        90deg,
        transparent
        0,
        transparent
        47px,
        rgba(255,255,255,0.85)
        48px,
        rgba(255,255,255,0.85)
        50px
      ) !important;

    box-shadow:
      inset
      0 1px 3px
      rgba(15,23,42,0.10);
  }


  /*
   * Finish line
   */
  #leaderboardBars.leaderboard-style-race
  .leaderboard-bar-container::after {
    content:
      "";

    position:
      absolute;

    right:
      0;

    top:
      -4px;

    width:
      8px;

    height:
      42px;

    border-radius:
      3px;

    background:
      repeating-linear-gradient(
        0deg,
        #0f172a
        0,
        #0f172a
        5px,
        #ffffff
        5px,
        #ffffff
        10px
      );

    box-shadow:
      0 1px 4px
      rgba(15,23,42,0.20);

    z-index:
      4;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-bar {
    position:
      relative;

    height:
      100% !important;

    border:
      none !important;

    border-radius:
      10px !important;

    box-shadow:
      inset
      0
      1px
      0
      rgba(255,255,255,0.42),
      0
      2px
      6px
      color-mix(
        in srgb,
        var(--house-color) 25%,
        transparent
      ) !important;
  }


  /*
   * Moving House marker at the end
   * of the coloured race lane.
   */
  #leaderboardBars.leaderboard-style-race
  .leaderboard-bar::after {
    content:
      "";

    position:
      absolute;

    top:
      50%;

    right:
      -8px;

    width:
      18px;

    height:
      18px;

    transform:
      translateY(-50%);

    border-radius:
      50%;

    background:
      var(--house-color);

    border:
      3px solid
      #ffffff;

    box-shadow:
      0 2px 7px
      rgba(15,23,42,0.25);

    z-index:
      5;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-points {
    grid-column:
      4 !important;

    min-width:
      145px !important;

    justify-content:
      flex-end !important;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-points
  .casino-counter {
    font-size:
      42px !important;

    line-height:
      1 !important;

    letter-spacing:
      -1px !important;

    text-shadow:
      0 2px 5px
      rgba(15,23,42,0.10) !important;
  }


  #leaderboardBars.leaderboard-style-race
  .leaderboard-points
  span:last-child {
    font-size:
      12px !important;
  }
}

  


/* =========================================================
   MODERN LEADERBOARD - DARK MODE
   Desktop + iPad only
   ========================================================= */

@media (min-width: 781px) {

  body.house-display-dark
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-item {
    background:
      linear-gradient(
        135deg,
        color-mix(
          in srgb,
          var(--house-color) 7%,
          #1e293b
        ) 0%,
        color-mix(
          in srgb,
          var(--house-color) 3%,
          #1e293b
        ) 100%
      ) !important;

    border-color:
      color-mix(
        in srgb,
        var(--house-color) 13%,
        rgba(148,163,184,0.16)
      ) !important;

    box-shadow:
      0 4px 14px
      rgba(0,0,0,0.16) !important;
  }


  body.house-display-dark
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-item:hover {
    background:
      linear-gradient(
        135deg,
        color-mix(
          in srgb,
          var(--house-color) 11%,
          #243044
        ) 0%,
        color-mix(
          in srgb,
          var(--house-color) 5%,
          #243044
        ) 100%
      ) !important;

    border-color:
      color-mix(
        in srgb,
        var(--house-color) 24%,
        rgba(148,163,184,0.24)
      ) !important;

    box-shadow:
      0 8px 22px
      rgba(0,0,0,0.22) !important;
  }


  /* House names */
  body.house-display-dark
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-house
  > span:first-child {
    color:
      #f8fafc !important;

    -webkit-text-stroke:
      0 !important;

    text-shadow:
      none !important;
  }


  /* Rank tile */
  body.house-display-dark
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-rank {
    background:
      rgba(15,23,42,0.60) !important;

    border-color:
      rgba(148,163,184,0.20) !important;

    box-shadow:
      inset
      0 1px 0
      rgba(255,255,255,0.05) !important;
  }


  /* 4th, 5th etc */
  body.house-display-dark
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-rank
  > div:first-child
  > div:first-child {
    color:
      #e2e8f0 !important;
  }


  body.house-display-dark
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-rank
  > div:first-child
  > div:last-child {
    color:
      #94a3b8 !important;
  }


  /* Gap message */
  body.house-display-dark
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-gap-chip {
    background:
      rgba(15,23,42,0.48) !important;

    border-color:
      rgba(148,163,184,0.18) !important;

    color:
      #cbd5e1 !important;
  }


  body.house-display-dark
  #leaderboardBars.leaderboard-style-modern
  .leader-gap-chip {
    color:
      #a7f3d0 !important;
  }


  body.house-display-dark
  #leaderboardBars.leaderboard-style-modern
  .chase-gap-chip {
    color:
      #fde68a !important;
  }


  /* Progress track */
  body.house-display-dark
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-bar-container {
    background:
      #475569 !important;

    box-shadow:
      inset
      0 1px 3px
      rgba(0,0,0,0.24) !important;
  }


  /* pts label */
  body.house-display-dark
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-points
  span:last-child {
    color:
      #cbd5e1 !important;
  }


  /* Display selector */
  body.house-display-dark
  .leaderboard-style-control {
    background:
      #1e293b !important;

    border-color:
      rgba(148,163,184,0.25) !important;

    color:
      #e2e8f0 !important;

    box-shadow:
      0 2px 7px
      rgba(0,0,0,0.20) !important;
  }


  body.house-display-dark
  .leaderboard-style-control
  select {
    color:
      #e2e8f0 !important;
  }

}


/*
 * MOBILE SAFETY
 *
 * Do not allow any of the new styles or
 * the selector to affect smartphones.
 */
@media (max-width: 780px) {

  .leaderboard-style-control {
    display:
      none !important;
  }

}


/* ==========================================
   IPAD PORTRAIT - HOUSE POINTS DASHBOARD
   ========================================== */

@media
  (min-width: 768px)
  and (max-width: 1100px)
  and (orientation: portrait) {

  /* Dashboard card header */
  #dashboard-section .card-header {
    grid-template-columns: 1fr auto !important;
    row-gap: 10px !important;
    align-items: start !important;
  }

  #dashboard-section .card-header > div:first-child {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    align-items: start !important;
  }

  #dashboard-section .card-header .card-title {
    font-size: 18px !important;
    margin-bottom: 2px !important;
  }

  /* Keep secondary dashboard actions compact */
  #teacherOfWeekBtn,
  #weeklyChangesBtn {
    width: fit-content !important;
    margin: 0 !important;
  }

  #teacherOfWeekBtn {
    margin-right: 6px !important;
  }

  /* iPad: heading first, all three actions below */
  #dashboard-section .card-header > div:first-child {
    display:flex !important;
    flex-wrap:wrap !important;
    align-items:center !important;
    justify-content:flex-start !important;
    column-gap:8px !important;
    row-gap:8px !important;
  }

  #dashboard-section .card-header .card-title {
    width:100% !important;
    flex:0 0 100% !important;
    margin-bottom:2px !important;
  }

  /* Total points stays top-right */
  #schoolHousePointsTotal {
    align-self: start !important;
  }


  /* ======================================
     LEADERBOARD ROW
     ====================================== */

  #leaderboardBars.leaderboard-style-modern
  .leaderboard-item,
  #leaderboardBars.leaderboard-style-race
  .leaderboard-item {
    display: grid !important;

    grid-template-columns:
      76px
      minmax(135px, .9fr)
      minmax(140px, 1.2fr)
      125px !important;

    align-items: center !important;

    column-gap: 10px !important;
    row-gap: 4px !important;

    width: 100% !important;
    max-width: 100% !important;

    padding:
      14px
      14px !important;

    margin-bottom: 10px !important;

    box-sizing: border-box !important;
  }


  /* Rank */
  #leaderboardBars .leaderboard-rank {
    width: 58px !important;
    min-width: 58px !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  #leaderboardBars .leaderboard-rank > span {
    font-size: 24px !important;
  }


  /* House name + gap message */
  #leaderboardBars .leaderboard-house {
    grid-column: 2 !important;
    grid-row: 1 !important;

    min-width: 0 !important;

    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;

    column-gap: 10px !important;
    row-gap: 4px !important;
  }

  #leaderboardBars .leaderboard-house > span:first-child {
    font-size: 17px !important;
    line-height: 1.1 !important;
  }


  /* Turn gap chip into a quieter secondary line */
  #leaderboardBars .leaderboard-gap-chip {
    margin-left: 0 !important;
    padding: 0 !important;

    border: none !important;
    background: transparent !important;

    font-size: 10px !important;
    line-height: 1.25 !important;

    white-space: normal !important;
  }

  #leaderboardBars .leader-gap-chip {
    color: #047857 !important;
  }

  #leaderboardBars .chase-gap-chip {
    color: #b45309 !important;
  }


  /* Progress bar */
  #leaderboardBars .leaderboard-bar-container {
    grid-column: 3 !important;
    grid-row: 1 !important;

    width: 100% !important;
    min-width: 0 !important;

    height: 20px !important;
    margin: 0 !important;
  }


  /* Points */
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-points,
  #leaderboardBars.leaderboard-style-race
  .leaderboard-points {
    grid-column: 4 !important;
    grid-row: 1 !important;

    width: 125px !important;
    min-width: 0 !important;
    max-width: 125px !important;

    display: flex !important;

    justify-content: flex-end !important;
    align-items: baseline !important;

    gap: 4px !important;

    padding: 0 !important;

    white-space: nowrap !important;

    overflow: visible !important;

    box-sizing: border-box !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-points
  .casino-counter,
  #leaderboardBars.leaderboard-style-race
  .leaderboard-points
  .casino-counter {
    font-size: 34px !important;

    line-height: 1 !important;

    letter-spacing: -1px !important;

    flex: 0 1 auto !important;

    min-width: 0 !important;
  }


  #leaderboardBars.leaderboard-style-modern
  .leaderboard-points
  span:last-child,
  #leaderboardBars.leaderboard-style-race
  .leaderboard-points
  span:last-child {
    display: inline-block !important;

    flex: 0 0 auto !important;

    min-width: 17px !important;

    font-size: 10px !important;
    line-height: 1 !important;
    font-weight: 800 !important;

    white-space: nowrap !important;

    color: #94a3b8 !important;
  }


  /* Rank movement sits neatly with rank */
  #leaderboardBars .leaderboard-rank div[style*="margin-top"] {
    margin-top: 4px !important;
    font-size: 9px !important;
  }
}


/* ==========================================
   SCHOOL THEME - FULL PRODUCT UI
   ========================================== */


/* ==========================================
   MAIN APP BACKGROUND
   ========================================== */

html,
body,
.app-container,
.main-content {
  background:
    var(--school-canvas) !important;
}


/* ==========================================
   MAIN SECTIONS
   ========================================== */

#dashboard-section,
#students-section,
#houses-section {
  background:
    var(--school-canvas) !important;
}


/* ==========================================
   SIDEBAR
   ========================================== */

.sidebar {
  background:
    var(--school-surface) !important;

  border-right-color:
    var(--school-border) !important;
}


.sidebar-title:hover {
  background:
    var(--school-surface-soft) !important;
}


.nav-item:hover {
  background:
    var(--school-surface-soft) !important;
}


.nav-item.active {
  background:
    var(--school-surface-strong) !important;

  color:
    var(--school-primary) !important;

  border-color:
    var(--school-border-strong) !important;
}


.nav-item.active i {
  color:
    var(--school-primary) !important;
}


/* ==========================================
   HEADER
   ========================================== */

.header {
  background:
    color-mix(
      in srgb,
      var(--school-primary) 3%,
      white
    ) !important;

  border-bottom-color:
    var(--school-border) !important;
}


.header::after {
  background:
    linear-gradient(
      90deg,
      transparent,
      var(--school-accent),
      transparent
    ) !important;
}


/* ==========================================
   GENERAL CARDS
   ========================================== */

.card {
  background:
    var(--school-surface) !important;

  border-color:
    var(--school-border) !important;
}


.card:hover {
  border-color:
    var(--school-border-strong) !important;

  box-shadow:
    0 5px 16px
    color-mix(
      in srgb,
      var(--school-primary) 9%,
      transparent
    ) !important;
}


/* ==========================================
   DASHBOARD LEADERBOARD
   ========================================== */

.leaderboard-item {
  background:
    var(--school-surface) !important;

  border-color:
    transparent;
}


.leaderboard-item:hover {
  background:
    var(--school-surface-soft) !important;

  border-color:
    var(--school-border) !important;
}


.leaderboard-bar-container {
  background:
    var(--school-surface-strong) !important;
}


/* ==========================================
   HOUSE STANDING CARDS

   Keep House colour rails / bars intact.
   Only theme the card surface.
   ========================================== */

.house-card {
  background:
    var(--school-surface) !important;

  border-color:
    var(--school-border) !important;
}


.house-card:hover {
  border-color:
    var(--school-border-strong) !important;
}


.house-emoji {
  background:
    var(--school-surface-soft) !important;

  border-color:
    var(--school-border) !important;
}


.house-stats {
  border-top-color:
    var(--school-border) !important;
}


/* ==========================================
   TABLES
   ========================================== */

.table-container {
  background:
    var(--school-surface) !important;
}


table {
  background:
    var(--school-surface) !important;
}


th {
  background:
    var(--school-surface-strong) !important;

  color:
    var(--school-primary) !important;

  border-bottom-color:
    var(--school-border) !important;
}


td {
  border-bottom-color:
    var(--school-border) !important;
}


tr:hover td {
  background:
    var(--school-surface-soft) !important;
}


/* ==========================================
   FORMS
   ========================================== */

.form-control {
  background:
    var(--school-surface) !important;

  border-color:
    var(--school-border) !important;
}


.form-control:focus {
  border-color:
    var(--school-primary) !important;

  box-shadow:
    0 0 0 3px
    color-mix(
      in srgb,
      var(--school-primary) 18%,
      transparent
    ) !important;
}


/* ==========================================
   PRIMARY BUTTONS
   ========================================== */

.btn-primary {
  background:
    linear-gradient(
      135deg,
      var(--school-primary),
      var(--school-primary-hover)
    ) !important;

  color:
    #ffffff !important;
}


.btn-secondary {
  background:
    var(--school-surface) !important;

  border-color:
    var(--school-primary) !important;

  color:
    var(--school-primary) !important;
}


/* ==========================================
   GENERAL MODAL SURFACES
   ========================================== */

.house-expanded-content {
  background:
    var(--school-surface) !important;
}


/* ==========================================
   TEACHER TOOLKIT
   ========================================== */

#teacherToolkitModal .toolkit-fullscreen-content,
#houseMasterToolkitsModal .toolkit-fullscreen-content {
  background:
    linear-gradient(
      135deg,
      var(--school-canvas) 0%,
      var(--school-surface-soft) 100%
    ) !important;
}


#teacherToolkitModal .toolkit-card,
#houseMasterToolkitsModal .toolkit-card {
  background:
    var(--school-surface) !important;

  border-color:
    var(--school-border) !important;
}


#teacherToolkitModal .toolkit-card:hover,
#houseMasterToolkitsModal .toolkit-card:hover {
  border-color:
    var(--school-border-strong) !important;

  box-shadow:
    0 18px 30px -12px
    color-mix(
      in srgb,
      var(--school-primary) 22%,
      transparent
    ) !important;
}


/* ==========================================
   OFFICIAL CLASS STANDINGS
   ========================================== */

#classLeaderboardModal .house-expanded-content {
  background:
    color-mix(
      in srgb,
      var(--school-primary) 12%,
      #e2e8f0
    ) !important;
}


#classLeaderboardModal .house-expanded-content > div:first-child {
  background:
    var(--school-primary) !important;
}


#classLeaderboardModal #classLeaderboardGrid {
  background:
    color-mix(
      in srgb,
      var(--school-primary) 12%,
      #e2e8f0
    ) !important;
}


#classLeaderboardModal .class-rank-card {
  background:
    var(--school-surface) !important;

  border-top:
    1px solid
    var(--school-border) !important;

  border-right:
    1px solid
    var(--school-border) !important;

  border-bottom:
    1px solid
    var(--school-border) !important;
}


/* Keep rank colours for 1st / 2nd / 3rd */
#classLeaderboardModal .class-rank-card.rank-1 {
  background:
    color-mix(
      in srgb,
      #ffd700 8%,
      var(--school-surface)
    ) !important;
}


#classLeaderboardModal .class-rank-card.rank-2 {
  background:
    color-mix(
      in srgb,
      #c0c0c0 8%,
      var(--school-surface)
    ) !important;
}


#classLeaderboardModal .class-rank-card.rank-3 {
  background:
    color-mix(
      in srgb,
      #cd7f32 8%,
      var(--school-surface)
    ) !important;
}


/* ==========================================
   CLASS INSIGHT
   ========================================== */

#classInsightModal #classInsightContent {
  background:
    var(--school-surface) !important;
}


#classInsightModal .house-expanded-content > div:first-child {
  background:
    var(--school-primary) !important;
}


/* ==========================================
   AWARD HISTORY
   ========================================== */

#awardHistoryModal .house-expanded-content {
  background:
    var(--school-canvas) !important;
}


#awardHistoryModal .table-container {
  background:
    var(--school-surface) !important;

  border-color:
    var(--school-border) !important;
}


#awardHistoryTable th {
  background:
    var(--school-primary) !important;

  color:
    #ffffff !important;
}


#awardHistoryTable tr:hover td {
  background:
    var(--school-surface-soft) !important;
}


/* ==========================================
   GLOBAL STUDENT SEARCH
   ========================================== */

#searchModalInner {
  background:
    var(--school-surface) !important;
}


#searchModalInner > div:first-child {
  background:
    var(--school-surface) !important;

  border-bottom-color:
    var(--school-border) !important;
}


#searchModalInner > div:first-child h2 {
  color:
    var(--school-primary) !important;
}


#searchModalInner > div:nth-child(2) {
  background:
    var(--school-surface) !important;
}


#globalStudentSearchInput {
  background:
    var(--school-surface-soft) !important;

  border-color:
    var(--school-border) !important;
}


#globalStudentSearchInput:focus {
  border-color:
    var(--school-primary) !important;

  box-shadow:
    0 0 0 4px
    color-mix(
      in srgb,
      var(--school-primary) 14%,
      transparent
    ) !important;
}


#globalSearchResults {
  background:
    var(--school-surface) !important;
}


/* ==========================================
   ALL HOUSES AWARD
   ========================================== */

#awardHousePointsModal .house-expanded-content {
  background:
    var(--school-canvas) !important;
}


#awardModalHeader {
  background:
    var(--school-surface) !important;

  border-bottom-color:
    var(--school-border) !important;
}


#awardModalTitle {
  color:
    var(--school-primary) !important;
}


/* ==========================================
   SMALL GLOBAL THEME ELEMENTS
   ========================================== */

.inline-term-select {
  background-color:
    var(--school-surface-soft) !important;

  border-color:
    var(--school-border) !important;

  color:
    var(--school-primary) !important;
}


.page-title {
  color:
    var(--school-primary) !important;
}


.click-hint {
  background:
    var(--school-surface-soft) !important;

  border-color:
    var(--school-border) !important;
}



/* ==========================================
   WEEKLY SNAPSHOT - RESPONSIVE MODAL
   ========================================== */

@media (max-width: 760px) {

  #weeklyChangesModal {
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
  }


  #weeklyChangesModal
  > .house-expanded-content {

    width: 100vw !important;
    max-width: 100vw !important;

    height: 100dvh !important;
    max-height: 100dvh !important;

    margin: 0 !important;

    border: none !important;
    border-radius: 0 !important;
  }


  #weeklyChangesContent {
    padding:
      16px
      14px
      calc(
        24px +
        env(
          safe-area-inset-bottom,
          0px
        )
      ) !important;
  }
}


/* ==========================================
   SCHOOL VALUES AND STUDENT SEARCH
   DESKTOP / IPAD / PHONE
   ========================================== */

/* iPad: keep House Values bar, but do not show the old dashboard search */
@media (min-width:781px) and (max-width:1370px) {

  body:not(.dashboard-behaviour-mode)
  #schoolValuesBar {
    display:flex !important;
    width:100% !important;
  }

  #schoolValuesBar > div {
    width:100% !important;
    flex-wrap:nowrap !important;
  }

  #desktopGlobalStudentSearch {
    display:none !important;
  }

}

/* Phones: never display the dashboard search bar */
@media (max-width:780px) {

  #schoolValuesBar {
    display:none !important;
  }

  #desktopGlobalStudentSearch {
    display:none !important;
  }

}


/* ==========================================
   PREMIUM LEADERBOARD REFINEMENTS
   Desktop only
   ========================================== */

@media (min-width: 1371px) {

  /* Compact desktop House leaderboard */
  #dashboard-section
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-item {
    min-height: 64px !important;
    padding: 7px 14px !important;
    column-gap: 12px !important;
    margin-bottom: 8px !important;

    grid-template-columns:
      60px
      minmax(170px, 0.62fr)
      minmax(250px, 1.7fr)
      125px !important;
  }

    /* Compact ranking boxes */
  #dashboard-section
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-rank {
    width: 50px !important;
    min-width: 50px !important;
    min-height: 46px !important;
    height: auto !important;
    padding: 5px !important;
    border-radius: 12px !important;
    gap: 3px !important;
  }

  /* Smaller ranking numbers */
  #dashboard-section
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-rank-number {
    font-size: 25px !important;
  }

  /* Slightly smaller scores */
  #dashboard-section
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-points .casino-counter {
    font-size: 32px !important;
  }

  /* Slimmer progress bars */
  #dashboard-section
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-bar-container {
    height: 14px !important;
  }

  /* Keep the score and pts label inside each House row */
  #dashboard-section
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-points {
    grid-column: 4 !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-right: 8px !important;
    box-sizing: border-box !important;
    justify-content: flex-end !important;
    white-space: nowrap !important;
  }

  /* Keep House name and gap message together */
  #dashboard-section
  #leaderboardBars.leaderboard-style-modern
  .leaderboard-house {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    column-gap: 9px !important;
    row-gap: 4px !important;
    min-width: 0 !important;
  }

  /* Close the gap between leaderboard and House Values */
  #dashboard-section
  .card:has(#leaderboardBars) {
    margin-bottom: 8px !important;
  }

  #dashboard-section
  #schoolValuesBar {
    margin-top: 0 !important;
    margin-bottom: 6px !important;
    padding-top: 0 !important;
  }

  /* Reserve clear space for the existing floating + button */
  #dashboard-section
  #schoolValuesBar > div {
    padding-right: 76px !important;
    box-sizing: border-box !important;
  }

  /* Prevent the Assembly Mode action from shrinking */
  #dashboard-section
  #schoolValuesBar
  .dashboard-projector-role-button {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }

}

/* ==========================================
   IPAD LEADERBOARD FOOTER
   Compact spacing and left-aligned Show More
   ========================================== */

@media (min-width:781px) and (max-width:1370px) {

  #dashboard-section
  .leaderboard-footer-controls {
    flex-direction:row !important;
    justify-content:flex-start !important;
    align-items:center !important;
    min-height:36px !important;
    margin:6px 0 0 0 !important;
    padding:0 !important;
  }

  #dashboard-section
  .leaderboard-footer-controls
  button[onclick*="toggleLeaderboardExpand"] {
    margin:0 !important;
  }

  #dashboard-section
  .card:has(#leaderboardBars) {
    padding-bottom:12px !important;
  }

}

/* ==========================================
   TRACKEDU DASHBOARD CONTROL ORGANISATION
   Desktop and iPad
   ========================================== */

@media (min-width:781px) {

  /* Leaderboard footer:
     Show More | House Values | Total Points */
  #dashboard-section
  #leaderboardBars
  .trackedu-leaderboard-footer {
    display:flex !important;
    flex-direction:row-reverse !important;
    align-items:center !important;
    justify-content:space-between !important;
    gap:12px !important;
    width:100% !important;
    margin:8px 0 0 !important;
    padding:4px 0 !important;
    min-height:42px !important;
  }

  /* House Values no longer occupies a separate toolbar */
  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  #leaderboardBars
  #schoolValuesBar {
    display:flex !important;
    flex:1 1 auto !important;
    justify-content:center !important;
    align-items:center !important;
    width:auto !important;
    min-width:0 !important;
    height:auto !important;
    margin:0 !important;
    padding:0 !important;
    background:transparent !important;
    border:0 !important;
  }

  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  #leaderboardBars
  #schoolValuesBar > div {
    display:flex !important;
    align-items:center !important;
    justify-content:center !important;
    flex-wrap:wrap !important;
    gap:6px !important;
    width:auto !important;
    min-width:0 !important;
    padding:0 !important;
    margin:0 !important;
    background:transparent !important;
    border:0 !important;
    border-radius:0 !important;
    box-shadow:none !important;
  }

  /* Total Points remains visible on iPad */
  #dashboard-section
  #leaderboardBars
  #schoolHousePointsTotal {
    display:inline-flex !important;
    flex:0 0 auto !important;
    margin-left:0 !important;
    min-width:0 !important;
  }

  /* Show More remains a compact button */
  #dashboard-section
  #leaderboardBars
  .trackedu-leaderboard-footer
  > button {
    flex:0 0 auto !important;
    margin:0 !important;
    white-space:nowrap !important;
  }

  /* House Highlights:
     Activities beside Edit Houses & Badges */
  #dashboard-section
  .card:has(#houseOverview)
  > .card-header {
    display:flex !important;
    align-items:center !important;
    justify-content:space-between !important;
    flex-direction:row !important;
    flex-wrap:wrap !important;
    gap:10px !important;
  }

  #dashboard-section
  .card:has(#houseOverview)
  > .card-header
  > .card-title {
    width:auto !important;
    flex:1 1 auto !important;
    min-width:140px !important;
    margin:0 !important;
  }

  #trackeduHighlightsActions {
    display:flex;
    align-items:center;
    justify-content:flex-end;
    flex-wrap:wrap;
    gap:8px;
    margin-left:auto;
  }

  #trackeduHighlightsActions
  #dashboardStartChallengeBtn {
    min-height:34px !important;
  }

  #trackeduHighlightsActions
  .dashboard-projector-role-button {
    min-height:34px !important;
    flex-shrink:0 !important;
    white-space:nowrap !important;
  }
}

/* School Absences button: dark mode */
:is(body.dark-mode, body.house-display-dark, [data-theme="dark"])
#schoolTodayAbsencesBtn {
  background: #1e293b !important;
  border-color: #475569 !important;
  color: #f8fafc !important;
}

:is(body.dark-mode, body.house-display-dark, [data-theme="dark"])
#schoolTodayAbsencesBtn:hover {
  background: #334155 !important;
  border-color: #60a5fa !important;
}

:is(body.dark-mode, body.house-display-dark, [data-theme="dark"])
#schoolTodayAbsencesBtn i {
  color: #60a5fa !important;
}

/* Live Challenges menu: dark mode */
/* Live Challenges button: dark mode */
body.house-display-dark #dashboardStartChallengeBtn {
  background:#1e293b !important;
  border:1px solid #6d28d9 !important;
  color:#c4b5fd !important;
  box-shadow:none !important;
}

body.house-display-dark #dashboardStartChallengeBtn:hover {
  background:#312451 !important;
  border-color:#8b5cf6 !important;
  color:#ddd6fe !important;
}

body.house-display-dark #dashboardStartChallengeBtn:focus-visible {
  outline:2px solid #a78bfa !important;
  outline-offset:2px;
}

body.house-display-dark #dashboardLiveChallengeMenu {
  background:#172337 !important;
  border-color:#475569 !important;
  color:#f1f5f9 !important;
}

body.house-display-dark
#dashboardLiveChallengeMenu > div:first-child {
  border-bottom-color:#334155 !important;
}

body.house-display-dark
#dashboardLiveChallengeMenu > div:first-child > div:first-child {
  color:#f8fafc !important;
}

body.house-display-dark
#dashboardLiveChallengeMenu > div:first-child > div:last-child {
  color:#cbd5e1 !important;
}

body.house-display-dark
#dashboardLiveChallengeMenuContent .ted-live-challenge-saved-item {
  background:#1e293b !important;
  border-color:#475569 !important;
}

body.house-display-dark
#dashboardLiveChallengeMenuContent
.ted-live-challenge-saved-item > div:first-child > div:first-child {
  color:#f8fafc !important;
}

body.house-display-dark
#dashboardLiveChallengeMenuContent
.ted-live-challenge-saved-item > div:first-child > div:last-child {
  color:#cbd5e1 !important;
}

body.house-display-dark
#dashboardLiveChallengeMenuContent > div:first-child:not(.ted-live-challenge-saved-item) {
  color:#cbd5e1 !important;
}

body.house-display-dark
#dashboardLiveChallengeMenuContent > button:last-child {
  background:#312451 !important;
  border-color:#6d28d9 !important;
  color:#ddd6fe !important;
}

body.house-display-dark
#dashboardLiveChallengeMenuContent > button:last-child:hover {
  background:#44316b !important;
}

/* Existing iPad layout */
@media (min-width:781px) and (max-width:1370px) {
}

/* iPad: allow House Values to wrap instead of overflowing */
@media (min-width:781px) and (max-width:1370px) {

  #dashboard-section
  #leaderboardBars
  .trackedu-leaderboard-footer {
    flex-wrap:wrap !important;
    row-gap:8px !important;
  }

  #dashboard-section
  #leaderboardBars
  #schoolValuesBar {
    flex:1 1 250px !important;
  }

  #trackeduHighlightsActions {
    display:flex !important;
    align-items:center !important;
    justify-content:flex-end !important;
    flex-wrap:nowrap !important;
    gap:8px !important;
    width:auto !important;
    margin-left:auto !important;
  }

  #trackeduHighlightsActions
  > .desktop-only {
    display:block !important;
  }

  #trackeduHighlightsActions
  #dashboardStartChallengeBtn {
    font-size:10px !important;
    padding:6px 11px !important;
    flex-shrink:0 !important;
  }

  #trackeduHighlightsActions
  .dashboard-projector-nondesktop {
    font-size:10px !important;
    padding:6px 11px !important;
    flex-shrink:0 !important;
  }

  #trackeduHighlightsActions
  .dashboard-house-manage-wrap {
    display:block !important;
    flex-shrink:0 !important;
  }

  #trackeduHighlightsActions
  .dashboard-house-manage-menu > summary {
    min-height:34px !important;
    padding:0 11px !important;
    font-size:10px !important;
    gap:7px !important;
  }
}

/* Keep the correct Assembly button on each device */
@media (min-width:1371px) {
  #trackeduHighlightsActions
  .dashboard-projector-nondesktop {
    display:none !important;
  }
}

@media (min-width:781px) and (max-width:1370px) {
  #trackeduHighlightsActions
  .desktop-only.dashboard-projector-role-button {
    display:none !important;
  }
}

/* ==========================================
   LEADERBOARD FOOTER - CENTRED ACTIONS
   ========================================== */

@media (min-width:781px) {

  #dashboard-section
  #leaderboardBars
  .trackedu-leaderboard-footer {
    display:grid !important;

    grid-template-columns:
      minmax(0,1fr)
      auto
      minmax(0,1fr) !important;

    align-items:center !important;
    column-gap:12px !important;
    row-gap:10px !important;

    width:100% !important;
    overflow:visible !important;
  }

  /* Centre: Show more Houses */
  #dashboard-section
  #leaderboardBars
  .trackedu-leaderboard-footer
  > button[onclick*="toggleLeaderboardExpand"] {
    grid-column:2;
    grid-row:1;
    justify-self:center;
  }

  /* Centre: editing and challenge controls */
  #dashboard-section
  #leaderboardBars
  #dashboardLeaderboardActions {
    grid-column:2;
    grid-row:1;

    display:flex !important;
    align-items:center;
    justify-content:center;

    gap:8px;
    min-width:0;
    white-space:nowrap;
    position:relative;
  }

  /* Keep Start Challenge visible on iPad */
  #dashboard-section
  #leaderboardBars
  #dashboardLeaderboardActions
  > .desktop-only {
    display:block !important;
  }

  /* Right: Total Points */
  #dashboard-section
  #leaderboardBars
  #schoolHousePointsTotal {
    grid-column:3;
    grid-row:1;

    justify-self:end;
    margin-left:0 !important;
  }

  /* The old House Values area must not
     take up a grid column. */
  #dashboard-section
  #leaderboardBars
  .trackedu-leaderboard-footer
  > #schoolValuesBar {
    position:absolute !important;
    width:0 !important;
    height:0 !important;
    margin:0 !important;
    padding:0 !important;
  }

  /* Allow both dropdown menus to open
     above the House Highlights card. */
  #dashboard-section
  .card:has(#leaderboardBars) {
    position:relative;
    z-index:3;
    overflow:visible !important;
  }

  #dashboard-section
  .card:has(#houseOverview) {
    position:relative;
    z-index:1;
  }

  /* Remove the empty old actions area */
  #trackeduHighlightsActions:empty {
    display:none !important;
  }
}

/* Narrow iPads: move the two controls to
   a centred second line if space is tight. */
@media (min-width:781px) and (max-width:979px) {

  #dashboard-section
  #leaderboardBars
  .trackedu-leaderboard-footer {
    grid-template-columns:
      minmax(0,1fr)
      auto !important;
  }

  #dashboard-section
  #leaderboardBars
  #schoolHousePointsTotal {
    grid-column:2;
    grid-row:1;
  }

  #dashboard-section
  #leaderboardBars
  #dashboardLeaderboardActions {
    grid-column:1 / -1;
    grid-row:2;
    justify-self:center;
  }
}

/* ==========================================
   BEHAVIOUR MODE
   Hide House Points toolbar completely
   ========================================== */

body.dashboard-behaviour-mode
#schoolValuesBar {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

/* ==========================================
   REASON SELECTOR - MOBILE
   ========================================== */
@media (max-width: 600px) {

  /* Stop this modal from ever creating horizontal scroll */
  #reasonSelectorModal {
    overflow-x: hidden !important;
  }


  #reasonSelectorModal
  > .house-expanded-content {
    width: 100vw !important;
    max-width: 100vw !important;

    min-width: 0 !important;

    padding:
      52px
      14px
      calc(
        24px +
        env(
          safe-area-inset-bottom,
          0px
        )
      ) !important;

    margin: 0 !important;

    border-radius: 0 !important;

    overflow-x: hidden !important;
    overflow-y: auto !important;

    box-sizing: border-box !important;
  }


  /* Modal heading */
  #reasonSelectorModal
  > .house-expanded-content
  > h3 {
    padding-right: 34px !important;

    margin-bottom: 14px !important;

    font-size: 18px !important;
    line-height: 1.25 !important;
  }


  /* Quick-selection heading */
  #reasonSelectorModal
  .form-group
  > .form-label {
    min-width: 0 !important;
  }


  #reasonSelectorModal
  .form-group
  > .form-label
  span {
    white-space: normal !important;
    text-align: right !important;
  }


  /* Quick reason area */
  #reasonSelectorModal
  #modalReasonChips {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    padding: 8px !important;
    gap: 8px !important;

    overflow-x: hidden !important;

    box-sizing: border-box !important;
  }


  /* Prevent generated reason buttons from forcing width */
  #reasonSelectorModal
  #modalReasonChips
  button {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    white-space: normal !important;

    text-align: left !important;

    box-sizing: border-box !important;
  }


  /* My Reasons */
  #teacherSavedReasonsSection {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    margin-top: 14px !important;

    padding: 14px !important;

    box-sizing: border-box !important;

    overflow: visible !important;
  }


  #teacherSavedReasonsSection
  > div:first-child {
    width: 100% !important;

    margin-bottom: 10px !important;

    font-size: 13px !important;

    line-height: 1.3 !important;

    white-space: normal !important;
  }


  #teacherSavedReasonsList {
    display: grid !important;

    grid-template-columns:
      1fr !important;

    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    gap: 8px !important;
  }


  /*
   * MY REASONS - MOBILE
   *
   * Normal award shortcuts can be full width.
   * Edit/delete icon buttons must remain compact.
   */

  #teacherSavedReasonsList
  > button {
    display: flex !important;

    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    min-height: 44px !important;

    align-items: center !important;
    justify-content: space-between !important;

    gap: 10px !important;

    padding:
      10px
      12px !important;

    border-radius: 12px !important;

    white-space: normal !important;

    overflow-wrap: normal !important;
    word-break: normal !important;

    text-align: left !important;

    font-size: 13px !important;
    line-height: 1.3 !important;

    box-sizing: border-box !important;
  }


  #teacherSavedReasonsList
  > button
  > span:last-child {
    flex:
      0
      0
      auto !important;

    margin-left: auto !important;
  }


  /*
   * EDIT MODE ROW
   */
  #teacherSavedReasonsList
  > div {
    display: flex !important;

    align-items: center !important;

    width: 100% !important;

    gap: 6px !important;

    padding: 7px !important;

    box-sizing: border-box !important;
  }


  /*
   * Reason text/points area should take
   * all remaining space.
   */
  #teacherSavedReasonsList
  > div
  > div:first-child {
    flex:
      1
      1
      auto !important;

    min-width: 0 !important;

    padding:
      6px
      8px !important;
  }


  /*
   * Pencil + bin stay as proper small icon buttons.
   */
  #teacherSavedReasonsList
  > div
  > button {
    flex:
      0
      0
      34px !important;

    width: 34px !important;
    max-width: 34px !important;
    min-width: 34px !important;

    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;

    margin: 0 !important;

    padding: 0 !important;

    display: inline-flex !important;

    align-items: center !important;
    justify-content: center !important;

    gap: 0 !important;

    border-radius: 9px !important;

    font-size: 12px !important;

    text-align: center !important;

    box-sizing: border-box !important;
  }


  /* Custom Reason card */
  #reasonSelectorModal
  .custom-reason-grid {
    display: grid !important;

    grid-template-columns:
      minmax(0, 1fr)
      96px !important;

    gap: 10px !important;

    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }


  /* Reason text gets its own full row */
  #reasonSelectorModal
  #modalCustomReason {
    grid-column: 1 / -1 !important;

    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    box-sizing: border-box !important;
  }


  /* Category + points share second row */
  #reasonSelectorModal
  #modalCustomCategory {
    grid-column: 1 !important;

    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    font-size: 14px !important;

    box-sizing: border-box !important;
  }


  #reasonSelectorModal
  #modalCustomPoints {
    grid-column: 2 !important;

    width: 96px !important;
    max-width: 96px !important;
    min-width: 0 !important;

    box-sizing: border-box !important;
  }


  /* Save-to-My-Reasons line */
  #reasonSelectorModal
  #saveTeacherReasonCheckbox {
    flex: 0 0 auto !important;
  }


  #reasonSelectorModal
  #saveTeacherReasonCheckbox
  + span {
    white-space: nowrap !important;
  }
}


@media (max-width: 780px) {

  #upgradeRequestModal {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
  }

  #upgradeRequestModal > div {
    width: 100vw !important;
    max-width: 100vw !important;

    height: 100dvh !important;
    max-height: 100dvh !important;

    margin: 0 !important;

    padding: 22px 18px 28px !important;

    border-radius: 0 !important;

    overflow-y: auto !important;
    overflow-x: hidden !important;

    box-shadow: none !important;

    -webkit-overflow-scrolling: touch;
  }

  #upgradeRequestModal form {
    width: 100% !important;
  }

  #upgradeRequestModal
  form
  > div:first-child {
    grid-template-columns: 1fr !important;
  }

}


/* ==========================================
   HOUSE POINTS DISPLAY THEME
   Dark default, optional Light
   ========================================== */

/* LIGHT MODE */
body:not(.house-display-dark)
#dashboard-section {
  background: #f8fafc;
}

body:not(.house-display-dark)
#dashboard-section
.card:has(#leaderboardBars),
body:not(.house-display-dark)
#dashboard-section
.card:has(#houseOverview) {
  background: #ffffff;
}


/* ==========================================
   DARK DASHBOARD
   ========================================== */

body.house-display-dark {
  background: #070d18 !important;
}

body.house-display-dark
.app-container,
body.house-display-dark
.main-content {
  background: #070d18 !important;
}

body.house-display-dark
#dashboard-section {
  background: #0b1220 !important;
}


/* ==========================================
   DARK APP HEADER
   ========================================== */

body.house-display-dark.active-section-dashboard
.header {
  background: rgba(15,23,42,0.98) !important;

  border-bottom-color:
    rgba(255,255,255,0.08) !important;

  box-shadow:
    0 1px 3px
    rgba(0,0,0,0.28) !important;
}


body.house-display-dark.active-section-dashboard
.header::after {
  background:
    linear-gradient(
      90deg,
      transparent,
      rgba(52,211,153,0.55),
      transparent
    ) !important;
}


/* Header school identity */
body.house-display-dark.active-section-dashboard
.header
.school-name-header {
  color: #ffffff !important;
  background: #1e293b !important;
  border: 1px solid rgba(255,255,255,0.16) !important;
  box-shadow: none !important;
}


/* TrackEDU update banner */
body.house-display-dark.active-section-dashboard
.housepoints-trackedu-update {
  background: #111827 !important;

  border-color:
    rgba(255,255,255,0.10) !important;

  color: #cbd5e1 !important;
}


body.house-display-dark.active-section-dashboard
.housepoints-update-copy,
body.house-display-dark.active-section-dashboard
.housepoints-update-copy strong {
  color: #e2e8f0 !important;
}


body.house-display-dark.active-section-dashboard
.housepoints-update-kicker {
  color: #94a3b8 !important;
}


/* ==========================================
   DARK DESKTOP SIDEBAR
   ========================================== */

/* Dark announcement strip */
body.house-display-dark.active-section-dashboard
.announcement-bar {
  background: #1c1917 !important;

  border-bottom-color:
    rgba(245,158,11,0.28) !important;

  box-shadow:
    0 1px 3px
    rgba(0,0,0,0.22) !important;
}


body.house-display-dark.active-section-dashboard
.announcement-content {
  color: #e7e5e4 !important;
}


body.house-display-dark.active-section-dashboard
.announcement-title {
  color: #fbbf24 !important;
}


body.house-display-dark.active-section-dashboard
.announcement-icon {
  color: #f59e0b !important;
}


/* Existing sidebar dark mode */
body.house-display-dark
.sidebar {
  background: #111827 !important;

  border-right-color:
    rgba(255,255,255,0.08) !important;

  box-shadow:
    2px 0 14px
    rgba(0,0,0,0.24) !important;
}


body.house-display-dark
.sidebar .nav-item {
  color: #cbd5e1 !important;
}


body.house-display-dark
.sidebar .nav-item i {
  color: #94a3b8;
}


body.house-display-dark
.sidebar .nav-item:hover {
  background: #1e293b !important;
  color: #ffffff !important;
}


body.house-display-dark
.sidebar .nav-item:hover i {
  color: #ffffff;
}


body.house-display-dark
.sidebar .nav-item.active {
  background: #1e293b !important;

  color: #60a5fa !important;

  border-color:
    rgba(96,165,250,0.32) !important;
}


body.house-display-dark
.sidebar .nav-item.active i {
  color: #60a5fa !important;
}

/* ==========================================
   DARK MODE - STUDENT AND HOUSE NAVIGATION
   ========================================== */

body.house-display-dark
#student-management-link,
body.house-display-dark
#navItemHouses {
  background:transparent !important;
  color:#cbd5e1 !important;
  border-color:transparent !important;
}

body.house-display-dark
#student-management-link span,
body.house-display-dark
#navItemHouses span {
  color:#e2e8f0 !important;
}

body.house-display-dark
#student-management-link:hover,
body.house-display-dark
#navItemHouses:hover {
  background:#1e293b !important;
  border-color:#334155 !important;
  color:#ffffff !important;
}

body.house-display-dark
#student-management-link:hover span,
body.house-display-dark
#navItemHouses:hover span {
  color:#ffffff !important;
}

body.house-display-dark
#student-management-link.active,
body.house-display-dark
#navItemHouses.active {
  background:#1e293b !important;
  border-color:#3b82f6 !important;
  color:#93c5fd !important;
}

body.house-display-dark
#student-management-link.active span,
body.house-display-dark
#navItemHouses.active span {
  color:#93c5fd !important;
}

body.house-display-dark
#student-management-link i {
  color:#60a5fa !important;
}

body.house-display-dark
#navItemHouses i {
  color:#fbbf24 !important;
}

/* ==========================================
   DARK MODE - ANNOUNCEMENT EDIT BUTTON
   ========================================== */

body.house-display-dark
#dashboardAnnouncementEditBtn {
  background:#1e293b !important;
  color:#e2e8f0 !important;
  border-color:#475569 !important;
  box-shadow:none !important;
}

body.house-display-dark
#dashboardAnnouncementEditBtn:hover {
  background:#334155 !important;
  color:#ffffff !important;
  border-color:#64748b !important;
}

body.house-display-dark
#dashboardAnnouncementEditBtn i {
  color:inherit !important;
}

body.house-display-dark
#dashboardAnnouncementEditBtn:focus-visible {
  outline:2px solid #60a5fa !important;
  outline-offset:2px;
}


body.house-display-dark
.sidebar-title {
  color: #64748b !important;
}


body.house-display-dark
.sidebar-title:hover {
  background: #1e293b !important;
  color: #cbd5e1 !important;
}


body.house-display-dark
.logo-normal {
  background: transparent !important;

  border-color:
    transparent !important;
}


body.house-display-dark
#dashboard-section
.card:has(#leaderboardBars),
body.house-display-dark
#dashboard-section
.card:has(#houseOverview) {
  background: #111827 !important;

  border-color:
    rgba(255,255,255,0.10) !important;

  box-shadow:
    0 8px 24px
    rgba(0,0,0,0.28) !important;
}


body.house-display-dark
#dashboard-section
.card-title {
  color: #f8fafc !important;
}


body.house-display-dark
#leaderboardBars
.leaderboard-item {
  background:
    rgba(255,255,255,0.035) !important;

  border:
    1px solid
    rgba(255,255,255,0.05) !important;
}


body.house-display-dark
#leaderboardBars
.leaderboard-bar-container {
  background: #334155 !important;
}


body.house-display-dark
#leaderboardBars
.leaderboard-points
span:last-child {
  color: #cbd5e1 !important;
}


body.house-display-dark
#houseOverview
.house-card {
  background: #1e293b !important;

  border-color:
    rgba(255,255,255,0.10) !important;

  color: #f8fafc !important;
}


body.house-display-dark
#houseOverview
.house-name {
  color: #f8fafc !important;
}


body.house-display-dark
#houseOverview
.house-motto {
  color: #cbd5e1 !important;
}


body.house-display-dark
#houseOverview
.stat-label {
  color: #94a3b8 !important;
}


body.house-display-dark
#houseOverview
.stat-value {
  color: #f8fafc !important;
}


/* House Standings stats panel */
#houseOverview
.house-overview-stats-row {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}


#houseOverview
.house-overview-stat-label {
  color: #64748b;
}


#houseOverview
.house-overview-member-value {
  color: #1e293b;
}


body.house-display-dark
#houseOverview
.house-overview-stats-row {
  background: #111827 !important;

  border-color:
    rgba(255,255,255,0.10) !important;
}


body.house-display-dark
#houseOverview
.house-overview-stat-label {
  color: #94a3b8 !important;
}


body.house-display-dark
#houseOverview
.house-overview-member-value {
  color: #f8fafc !important;
}


/* ==========================================
   DARK DASHBOARD POLISH
   Better surface hierarchy + contrast
   Dark mode only
   ========================================== */


/* ------------------------------------------
   PILOT IMPACT / CONTINUE TRACKEDU CARD
   ------------------------------------------ */

body.house-display-dark
#pilotImpactDashboardCard {
  background:
    linear-gradient(
      135deg,
      #111827,
      #172033
    ) !important;

  border-color:
    rgba(96, 165, 250, 0.24) !important;

  box-shadow:
    0 8px 22px
    rgba(0, 0, 0, 0.20) !important;
}


body.house-display-dark
#pilotImpactDashboardCard:hover {
  border-color:
    rgba(96, 165, 250, 0.42) !important;

  box-shadow:
    0 10px 28px
    rgba(0, 0, 0, 0.28) !important;
}


body.house-display-dark
#pilotImpactDashboardTitle {
  color: #f8fafc !important;
}


body.house-display-dark
#pilotImpactDashboardMessage {
  color: #94a3b8 !important;
}


body.house-display-dark
#pilotImpactDashboardDay {
  background: #1e293b !important;

  color: #93c5fd !important;

  border-color:
    rgba(96, 165, 250, 0.28) !important;
}


/* ------------------------------------------
   HOUSE VALUES BAR
   ------------------------------------------ */

body.house-display-dark
#schoolValuesBar > div {
  background:
    rgba(30, 41, 59, 0.92) !important;

  border-color:
    rgba(255, 255, 255, 0.10) !important;

  box-shadow:
    0 2px 8px
    rgba(0, 0, 0, 0.18) !important;
}


body.house-display-dark
#schoolValuesBar > div > span {
  color: #94a3b8 !important;
}


body.house-display-dark
#schoolValuesDisplay > span {
  background: #111827 !important;

  color: #e2e8f0 !important;

  border-color:
    rgba(255, 255, 255, 0.10) !important;

  box-shadow: none !important;
}


/* House total badge */

body.house-display-dark
.dashboard-house-total {
  background:#10271d !important;
  border-color:#245c3d !important;
  color:#bbf7d0 !important;

  box-shadow:none !important;
}


body.house-display-dark
.dashboard-house-total i {
  color:#4ade80 !important;
}


body.house-display-dark
.dashboard-house-total span {
  color:#d1fae5 !important;
}

body.house-display-dark
#houseDisplayThemeBtn {
  background:#172337 !important;
  border-color:#334155 !important;
  color:#f8fafc !important;

  box-shadow:none !important;
}


body.house-display-dark
#houseDisplayThemeBtn:hover {
  background:#1e2d44 !important;
  border-color:#475569 !important;
}

/* ==========================================
   TRACKEDU DARK MODE - MISSING CONTROLS
   Scoped to the existing dark theme
   ========================================== */

/* 1. Edit Houses & Badges dropdown */

body.house-display-dark
.dashboard-house-manage-menu > summary {
  background:#1e293b !important;
  color:#e2e8f0 !important;
  border-color:#475569 !important;
  box-shadow:none !important;
}

body.house-display-dark
.dashboard-house-manage-menu > summary:hover {
  background:#334155 !important;
  color:#ffffff !important;
}

body.house-display-dark
.dashboard-house-manage-options {
  background:#111827 !important;
  border-color:#334155 !important;
  box-shadow:0 12px 28px rgba(0,0,0,.35) !important;
}

body.house-display-dark
.dashboard-house-manage-options
.dashboard-house-manage-item.admin-visible {
  background:transparent !important;
  color:#e2e8f0 !important;
}

body.house-display-dark
.dashboard-house-manage-options
.dashboard-house-manage-item.admin-visible span {
  color:inherit !important;
}

body.house-display-dark
.dashboard-house-manage-options
.dashboard-house-manage-item.admin-visible i {
  color:#94a3b8 !important;
}

body.house-display-dark
.dashboard-house-manage-options
.dashboard-house-manage-item.admin-visible:hover {
  background:#263449 !important;
  color:#ffffff !important;
}

/* Hide duplicate House Points total beside leaderboard actions.
   House Points are now reported in School Activity. */
#dashboard-section #leaderboardBars #schoolHousePointsTotal {
  display: none !important;
}

/* 2. Total Points */

body.house-display-dark
#schoolHousePointsTotal {
  background:transparent !important;
  border-color:transparent !important;
  color:#f8fafc !important;
  box-shadow:none !important;
}

body.house-display-dark
#schoolHousePointsTotalValue {
  color:#f8fafc !important;
}

body.house-display-dark
#schoolHousePointsTotal > span:last-child,
body.house-display-dark
#schoolHousePointsTotal > span:last-child > span {
  color:#cbd5e1 !important;
}

body.house-display-dark
#schoolHousePointsTotal > span[aria-hidden="true"] {
  background:#263449 !important;
  color:#cbd5e1 !important;
}

/* 3. School Management sidebar */

body.house-display-dark
#sidebarSchoolManagementGroup > summary {
  background:transparent !important;
  color:#cbd5e1 !important;
  border-color:transparent !important;
}

body.house-display-dark
#sidebarSchoolManagementGroup > summary:hover,
body.house-display-dark
#sidebarSchoolManagementGroup[open] > summary {
  background:#1e293b !important;
  color:#ffffff !important;
}

body.house-display-dark
#sidebarSchoolManagementGroup > summary i {
  color:#94a3b8 !important;
}

body.house-display-dark
#sidebarSchoolManagementGroup
.sidebar-nav-group-items {
  border-left-color:#334155 !important;
}

/* 4. Install TrackEDU app sidebar card */

body.house-display-dark
#sidebarInstallTeacherApp > button {
  background:#172337 !important;
  border-color:#334155 !important;
  color:#e2e8f0 !important;
  box-shadow:none !important;
}

body.house-display-dark
#sidebarInstallTeacherApp > button:hover {
  background:#1e2d44 !important;
  border-color:#475569 !important;
}

body.house-display-dark
#sidebarInstallTeacherApp > button > div:last-child > div:first-child {
  color:#f8fafc !important;
}

body.house-display-dark
#sidebarInstallTeacherApp > button > div:last-child > div:last-child {
  color:#94a3b8 !important;
}

/* 5. Header student search */

body.house-display-dark
#desktopGlobalStudentSearch > div,
body.house-display-dark
#desktopGlobalStudentSearchInput {
  background:#172337 !important;
  border-color:#334155 !important;
  color:#f8fafc !important;
}

body.house-display-dark
#desktopGlobalStudentSearchInput::placeholder {
  color:#94a3b8 !important;
  opacity:1;
}

body.house-display-dark
#desktopGlobalStudentSearchInput:focus {
  border-color:#60a5fa !important;
  outline-color:#60a5fa !important;
}

body.house-display-dark
#desktopGlobalStudentSearchResults {
  background:#111827 !important;
  border-color:#334155 !important;
  color:#e2e8f0 !important;
}

body.house-display-dark
#desktopGlobalStudentSearchResults
button,
body.house-display-dark
#desktopGlobalStudentSearchResults
[role="option"] {
  color:#e2e8f0 !important;
}

body.house-display-dark
#desktopGlobalStudentSearchResults
button:hover,
body.house-display-dark
#desktopGlobalStudentSearchResults
[role="option"]:hover {
  background:#263449 !important;
}

/* 6. Administrator notification bell */

body.house-display-dark
#adminNotificationBell {
  background:#172337 !important;
  color:#e2e8f0 !important;
  border-color:#334155 !important;
  box-shadow:none !important;
}

body.house-display-dark
#adminNotificationBell:hover {
  background:#263449 !important;
  color:#ffffff !important;
  border-color:#475569 !important;
}

/* 7. Behaviour filter toolbar */

body.house-display-dark
#dashboardBehaviourFilters select,
body.house-display-dark
#dashboardBehaviourFilters button {
  background:#1e293b !important;
  color:#e2e8f0 !important;
  border-color:#475569 !important;
  box-shadow:none !important;
}

body.house-display-dark
#dashboardBehaviourFilters select:focus,
body.house-display-dark
#dashboardBehaviourFilters button:focus-visible {
  outline-color:#60a5fa !important;
  border-color:#60a5fa !important;
}

body.house-display-dark
#dashboardBehaviourFilters button:hover {
  background:#334155 !important;
  color:#ffffff !important;
}

body.house-display-dark
#dashboardBehaviourFilters select option {
  background:#1e293b;
  color:#f8fafc;
}

/* 8. House Points / Behaviour segmented switch */

body.house-display-dark
#dashboardOverviewSwitch {
  background:#111827 !important;
  border-color:#334155 !important;
  box-shadow:none !important;
}

body.house-display-dark
#dashboardOverviewSwitch
.dashboard-overview-switch-btn:not(.active) {
  background:transparent !important;
  color:#cbd5e1 !important;
  border-color:transparent !important;
}

body.house-display-dark
#dashboardOverviewSwitch
.dashboard-overview-switch-btn:not(.active):hover {
  background:#263449 !important;
  color:#ffffff !important;
}

body.house-display-dark
#dashboardOverviewSwitch
#dashboardHousePointsModeBtn.active {
  background:#2563eb !important;
  color:#ffffff !important;
  border-color:#2563eb !important;
}

body.house-display-dark
#dashboardOverviewSwitch
#dashboardBehaviourModeBtn.active {
  background:#7c3aed !important;
  color:#ffffff !important;
  border-color:#7c3aed !important;
}

body.house-display-dark
#dashboardOverviewSwitch
.dashboard-overview-switch-btn.active i {
  color:#ffffff !important;
}

/* Existing Edit House Values dark-mode styling */

body.house-display-dark
#editSchoolValuesBtn {
  background: #111827 !important;

  color: #93c5fd !important;

  border-color:
    rgba(255, 255, 255, 0.12) !important;

  box-shadow: none !important;
}


/* ------------------------------------------
   STANDINGS SECTION
   ------------------------------------------ */

body.house-display-dark
#dashboard-section
.card:has(#houseOverview) {
  background: #111827 !important;

  border-color:
    rgba(148, 163, 184, 0.16) !important;

  box-shadow:
    0 10px 30px
    rgba(0, 0, 0, 0.24) !important;
}


/* Slightly separate each House card
   from the main Standings surface */

body.house-display-dark
#houseOverview
.house-card {
  background: #1e293b !important;

  border-color:
    rgba(148, 163, 184, 0.18) !important;

  box-shadow:
    0 8px 20px
    rgba(0, 0, 0, 0.22) !important;
}


body.house-display-dark
#houseOverview
.house-card:hover {
  border-color:
    rgba(148, 163, 184, 0.30) !important;
}


/* House names */

body.house-display-dark
#houseOverview
.house-card h3 {
  color: #f8fafc !important;
}


/* Motto */

body.house-display-dark
#houseOverview
.house-motto,
body.house-display-dark
#houseOverview
.house-card p {
  color: #94a3b8 !important;
}


/* Stats inset */

body.house-display-dark
#houseOverview
.house-overview-stats-row {
  background: #111827 !important;

  border-color:
    rgba(148, 163, 184, 0.15) !important;
}


body.house-display-dark
#houseOverview
.house-overview-stat-label {
  color: #94a3b8 !important;
}


body.house-display-dark
#houseOverview
.house-overview-member-value {
  color: #f8fafc !important;
}


/* ------------------------------------------
   HOUSE CARD PROGRESS
   ------------------------------------------ */

body.house-display-dark
#houseOverview
.house-card
div[style*="font-size: 9px"][style*="color: #94a3b8"] {
  color: #94a3b8 !important;
}


body.house-display-dark
#houseOverview
.house-card
div[style*="height: 4px"][style*="background: #e2e8f0"] {
  background: #475569 !important;
}


/* Captain divider */

body.house-display-dark
#houseOverview
.house-card
div[style*="border-top: 1px solid #f1f5f9"] {
  border-top-color:
    rgba(148, 163, 184, 0.18) !important;
}


/* ------------------------------------------
   CAPTAINS
   Current dark mode incorrectly forces
   these chips back to a light background
   ------------------------------------------ */

body.house-display-dark
#houseOverview
.house-card-captain-chip {
  background: #111827 !important;

  color: #e2e8f0 !important;

  border-color:
    rgba(148, 163, 184, 0.18) !important;

  box-shadow: none !important;
}


body.house-display-dark
#houseOverview
.house-card-no-captains {
  color: #94a3b8 !important;
}


/* ------------------------------------------
   HOUSE HIGHLIGHTS - ADMIN MANAGE MENU
   ------------------------------------------ */

.dashboard-house-manage-wrap {
  display:none;
  position:relative;
  flex-shrink:0;
}

/* Hide House editing controls in Behaviour mode */
body.dashboard-behaviour-mode
#dashboard-section
.dashboard-house-manage-wrap {
  display: none !important;
}

/* Desktop and iPad: show only for authorised administrators */
@media (min-width:781px) {
  .dashboard-house-manage-wrap:has(.admin-visible) {
    display:block !important;
  }
}

.dashboard-house-manage-menu {
  position:relative;
}

.dashboard-house-manage-menu > summary {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  height:34px;
  min-height:34px;
  padding:7px 13px;
  border:1px solid #cbd5e1;
  border-radius:10px;
  background:#ffffff;
  color:#334155;
  font-family:inherit;
  font-size:12px;
  font-weight:800;
  white-space:nowrap;
  box-sizing:border-box;
  cursor:pointer;
  list-style:none;
  user-select:none;
}

.dashboard-house-manage-menu > summary::-webkit-details-marker {
  display:none;
}

.dashboard-house-manage-menu > summary:hover {
  background:#f8fafc;
  border-color:#94a3b8;
}

.dashboard-house-manage-menu > summary:focus-visible {
  outline:3px solid #bfdbfe;
  outline-offset:2px;
}

.dashboard-house-manage-menu > summary
.fa-chevron-down {
  font-size:10px;
  transition:transform .2s ease;
}

.dashboard-house-manage-menu[open] > summary
.fa-chevron-down {
  transform:rotate(180deg);
}

/* ==========================================
   HOUSE VALUES - MENU RELOCATION
   Keep the original container available to
   existing Dashboard JavaScript, without
   leaving an empty space in the footer.
   ========================================== */

#dashboard-section #schoolValuesBar {
  position:absolute !important;
  width:0 !important;
  height:0 !important;
  min-height:0 !important;
  padding:0 !important;
  margin:0 !important;
  border:0 !important;
  overflow:hidden !important;
  pointer-events:none !important;
}

/* ==========================================
   HOUSE MANAGE DROPDOWN - CLEAN SAAS MENU
   ========================================== */

.dashboard-house-manage-options {
  position:absolute;
  top:calc(100% + 6px);
  right:0;
  z-index:200;

  display:flex;
  flex-direction:column;
  gap:2px;

  width:260px;
  padding:6px;

  background:#ffffff;
  border:1px solid #e2e8f0;
  border-radius:12px;

  box-shadow:
    0 10px 28px rgba(15,23,42,.12);
}

/* Hidden until existing admin logic authorises the item */
.dashboard-house-manage-options
.dashboard-house-manage-item {
  display:none !important;
}

/* Only previously authorised items become visible */
.dashboard-house-manage-options
.dashboard-house-manage-item.admin-visible {
  display:flex !important;
  align-items:center !important;
  justify-content:flex-start !important;

  gap:11px !important;

  width:100% !important;
  min-width:0 !important;
  min-height:40px !important;
  height:auto !important;

  margin:0 !important;
  padding:10px 12px !important;

  appearance:none;
  -webkit-appearance:none;

  border:0 !important;
  border-radius:8px !important;

  background:transparent !important;
  color:#334155 !important;

  box-shadow:none !important;
  transform:none !important;

  font-family:inherit !important;
  font-size:13px !important;
  font-weight:650 !important;
  line-height:1.3 !important;
  text-align:left !important;

  white-space:nowrap;
  cursor:pointer;

  transition:
    background .15s ease,
    color .15s ease;
}

.dashboard-house-manage-options
.dashboard-house-manage-item.admin-visible i {
  display:inline-flex;
  align-items:center;
  justify-content:center;

  width:18px;
  min-width:18px;

  color:#64748b !important;
  font-size:15px !important;
}

.dashboard-house-manage-options
.dashboard-house-manage-item.admin-visible span {
  display:block;
  flex:1;

  color:inherit !important;
  text-align:left !important;
  font-size:13px !important;
  font-weight:650 !important;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.dashboard-house-manage-options
.dashboard-house-manage-item.admin-visible:hover {
  background:#f1f5f9 !important;
  color:#1d4ed8 !important;
}

.dashboard-house-manage-options
.dashboard-house-manage-item.admin-visible:hover i {
  color:#2563eb !important;
}

.dashboard-house-manage-options
.dashboard-house-manage-item.admin-visible:focus-visible {
  outline:2px solid #2563eb !important;
  outline-offset:-2px;
}


/* ------------------------------------------
   STANDINGS ADMIN BUTTONS
   ------------------------------------------ */

body.house-display-dark
#dashboardManageHousesBtn,
body.house-display-dark
#dashboardHouseBadgesBtn,
body.house-display-dark
#dashboardStudentBadgesBtn {
  background: #1e293b !important;

  color: #e2e8f0 !important;

  border-color:
    rgba(148, 163, 184, 0.24) !important;

  box-shadow: none !important;
}


body.house-display-dark
#dashboardManageHousesBtn:hover,
body.house-display-dark
#dashboardHouseBadgesBtn:hover,
body.house-display-dark
#dashboardStudentBadgesBtn:hover {
  background: #334155 !important;

  color: #ffffff !important;

  border-color:
    rgba(148, 163, 184, 0.38) !important;
}


/* ------------------------------------------
   LEADERBOARD ROWS
   Give rows more separation from container
   ------------------------------------------ */

body.house-display-dark
#leaderboardBars
.leaderboard-item {
  background:
    rgba(255, 255, 255, 0.055) !important;

  border-color:
    rgba(148, 163, 184, 0.12) !important;
}


body.house-display-dark
#leaderboardBars
.leaderboard-bar-container {
  background: #475569 !important;
}


/* ------------------------------------------
   SHOW ALL HOUSES
   ------------------------------------------ */

body.house-display-dark
#leaderboardBars
button[onclick^="toggleLeaderboardExpand"] {
  background:#172337 !important;

  color:#cbd5e1 !important;

  border-color:#334155 !important;

  box-shadow:none !important;
}


body.house-display-dark
#leaderboardBars
button[onclick^="toggleLeaderboardExpand"]:hover {
  background: #334155 !important;

  color: #ffffff !important;

  border-color:
    rgba(148, 163, 184, 0.32) !important;
}


/* ==========================================
   PROJECTOR LIGHT MODE
   ========================================== */

#fullscreenLeaderboard:not(.house-display-dark) {
  background:
    #f8fafc !important;

  color: #1e293b !important;
}


#fullscreenLeaderboard:not(.house-display-dark)
.leaderboard-fullscreen-header {
  background:
    rgba(255,255,255,0.96) !important;
}


#fullscreenLeaderboard:not(.house-display-dark)
.hero-house-card {
  background: #f8fafc !important;
}


#fullscreenLeaderboard:not(.house-display-dark)
.hero-section {
  background: #ffffff !important;
}


#fullscreenLeaderboard:not(.house-display-dark)
.hero-captain-row {
  background: #f8fafc !important;

  border-top:
    1px solid
    #e2e8f0 !important;

  border-right:
    1px solid
    #e2e8f0 !important;

  border-bottom:
    1px solid
    #e2e8f0 !important;
}


#fullscreenLeaderboard:not(.house-display-dark)
.hero-captain-name {
  color: #1e293b !important;
}


#fullscreenLeaderboard:not(.house-display-dark)
.hero-captain-role {
  color: #64748b !important;
}

#fullscreenLeaderboard.house-display-dark
.hero-captain-row {
  background:
    rgba(255,255,255,0.08) !important;

  border-top:
    1px solid
    rgba(255,255,255,0.08) !important;

  border-right:
    1px solid
    rgba(255,255,255,0.08) !important;

  border-bottom:
    1px solid
    rgba(255,255,255,0.08) !important;
}


#fullscreenLeaderboard.house-display-dark
.hero-captain-name {
  color: #f8fafc !important;
}


#fullscreenLeaderboard.house-display-dark
.hero-captain-role {
  color: #cbd5e1 !important;
}

#fullscreenLeaderboard:not(.house-display-dark)
.hero-projector-motto {
  color: #475569 !important;

  border-bottom:
    1px solid
    #cbd5e1 !important;
}


/* ==========================================
   PROJECTOR DARK MODE
   ========================================== */

#fullscreenLeaderboard.house-display-dark {
  background:
    #0f172a !important;

  color: #f8fafc !important;
}


#fullscreenLeaderboard.house-display-dark
.leaderboard-fullscreen-header {
  background:
    rgba(15,23,42,0.96) !important;

  border-bottom:
    1px solid
    rgba(255,255,255,0.10);
}


#fullscreenLeaderboard.house-display-dark
.leaderboard-brand {
  background: #1e293b !important;

  border:
    1px solid
    rgba(255,255,255,0.12) !important;

  box-shadow: none !important;
}


#fullscreenLeaderboard.house-display-dark
.leaderboard-brand-title {
  color: #f8fafc !important;
}


#fullscreenLeaderboard.house-display-dark
.hero-house-card {
  background: #111827 !important;

  color: #f8fafc !important;
}


#fullscreenLeaderboard.house-display-dark
.hero-section {
  background: #1e293b !important;

  color: #f8fafc !important;
}


#fullscreenLeaderboard.house-display-dark
.hero-section h4 {
  color: #f8fafc !important;
}


#fullscreenLeaderboard.house-display-dark
.hero-row {
  background:
    rgba(255,255,255,0.07) !important;

  border:
    1px solid
    rgba(255,255,255,0.08) !important;
}


#fullscreenLeaderboard.house-display-dark
.hero-who,
#fullscreenLeaderboard.house-display-dark
.hero-pts {
  color: #f8fafc !important;
}


/* Motto */
#fullscreenLeaderboard.house-display-dark
.hero-projector-motto {
  color: #e2e8f0 !important;
  background: #1e293b !important;

  border:
    1px solid
    rgba(255,255,255,0.08) !important;

  border-radius: 12px !important;

  padding:
    10px
    18px !important;
}


/* Secondary labels */
#fullscreenLeaderboard.house-display-dark
.hero-section
span[style*="color: #64748b"],
#fullscreenLeaderboard.house-display-dark
.hero-section
div[style*="color: #64748b"] {
  color: #94a3b8 !important;
}


/* Class ranking number and points */
#fullscreenLeaderboard.house-display-dark
.hero-section
div[style*="color: #1e293b"] {
  color: #f8fafc !important;
}


/* Percentage pill */
#fullscreenLeaderboard.house-display-dark
.hero-row
div[style*="background:"]
div[style*="color: #1e293b"] {
  color: #f8fafc !important;
}


#fullscreenLeaderboard.house-display-dark
.hero-points {
  background:
    rgba(255,255,255,0.07) !important;
}


#fullscreenLeaderboard.house-display-dark
.hero-gap-gauge {
  background:
    rgba(255,255,255,0.10) !important;

  color: #f8fafc !important;
}

@media (max-width: 780px) {
  #houseDisplayThemeBtn,
  #projectorThemeBtn {
    display: none !important;
  }
}

#houseOverview
.house-card-captain-chip {
  background: #f8fafc;
  color: #1e293b;

  border:
    1px solid
    #e2e8f0;

  box-shadow:
    0 2px 4px
    rgba(0,0,0,0.05);
}


#houseOverview
.house-card-no-captains {
  color: #64748b;
}


body.house-display-dark
#houseOverview
.house-card-captain-chip {
  background: #f8fafc !important;
  color: #1e293b !important;

  border-color:
    #e2e8f0 !important;
}


body.house-display-dark
#houseOverview
.house-card-no-captains {
  color: #cbd5e1 !important;
}


@media (max-width: 780px) {

  #houseDisplayThemeBtn,
  #projectorThemeBtn {
    display: none !important;
  }

}



.trackedu-pd-example {
  margin: 6px 0 22px;

  padding: 20px;

  background: #f8fafc;

  border: 1px solid #dbeafe;
  border-radius: 16px;
}

.trackedu-pd-example-label {
  margin-bottom: 5px;

  color: #2563eb;

  font-size: 8px;
  font-weight: 850;

  letter-spacing: 0.12em;
}

.trackedu-pd-example > strong {
  display: block;

  margin-bottom: 14px;

  color: #0f172a;

  font-size: 15px;
  font-weight: 850;
}

.trackedu-pd-example-flow {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 10px;
}

.trackedu-pd-example-flow > span {
  flex: 1;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 7px;

  padding: 10px 8px;

  background: #ffffff;

  border: 1px solid #e2e8f0;
  border-radius: 10px;

  color: #334155;

  font-size: 10px;
  line-height: 1.3;
  font-weight: 750;

  text-align: center;
}

.trackedu-pd-example-flow > span i {
  color: #2563eb;
}

.trackedu-pd-flow-arrow {
  color: #94a3b8;

  font-size: 10px;
}


/* ==========================================
   PD REAL-WORLD SHOWCASE
   ========================================== */

.trackedu-pd-showcase {
  display: grid;

  grid-template-columns:
    minmax(0, 1.45fr)
    minmax(300px, 0.85fr);

  gap: 16px;

  margin: 16px 0 20px;
}


/* PHYSICAL BOARD */

.trackedu-pd-board-example {
  overflow: hidden;

  background: #ffffff;

  border: 1px solid #dbe3ec;
  border-radius: 14px;

  box-shadow:
    0 4px 14px rgba(15, 23, 42, 0.05);
}

.trackedu-pd-board-image-button {
  position: relative;

  display: block;

  width: 100%;

  padding: 0;

  overflow: hidden;

  background: #f8fafc;

  border: none;

  cursor: zoom-in;

  font-family: inherit;
}

.trackedu-pd-board-image-button img {
  display: block;

  width: 100%;
  height: 230px;

  object-fit: cover;
  object-position: center;

  background: #f8fafc;

  transition:
    transform 0.35s ease,
    filter 0.35s ease;
}

.trackedu-pd-board-image-overlay {
  position: absolute;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  background:
    linear-gradient(
      180deg,
      rgba(15, 23, 42, 0.02),
      rgba(15, 23, 42, 0.34)
    );

  opacity: 0;

  transition:
    opacity 0.25s ease;
}

.trackedu-pd-board-view-pill {
  display: inline-flex;
  align-items: center;

  gap: 7px;

  padding: 9px 13px;

  background: rgba(255, 255, 255, 0.94);

  border: 1px solid rgba(255, 255, 255, 0.80);
  border-radius: 999px;

  box-shadow:
    0 8px 24px rgba(15, 23, 42, 0.16);

  color: #0f172a;

  font-size: 10px;
  line-height: 1;
  font-weight: 850;

  transform: translateY(5px);

  transition:
    transform 0.25s ease;
}

.trackedu-pd-board-image-button:hover img {
  transform: scale(1.025);
  filter: brightness(0.94);
}

.trackedu-pd-board-image-button:hover
.trackedu-pd-board-image-overlay {
  opacity: 1;
}

.trackedu-pd-board-image-button:hover
.trackedu-pd-board-view-pill {
  transform: translateY(0);
}

.trackedu-pd-board-caption {
  display: flex;
  flex-direction: column;

  gap: 3px;

  padding: 12px 14px;
}

.trackedu-pd-board-caption strong {
  color: #0f172a;

  font-size: 11px;
  font-weight: 850;
}

.trackedu-pd-board-caption span {
  color: #64748b;

  font-size: 10px;
  line-height: 1.45;
}


/* CHALLENGE EXAMPLES */

.trackedu-pd-challenge-examples {
  display: grid;

  grid-template-rows:
    repeat(2, minmax(0, 1fr));

  gap: 12px;
}

.trackedu-pd-challenge-card {
  display: flex;
  align-items: flex-start;

  gap: 11px;

  padding: 14px;

  background: #ffffff;

  border: 1px solid #dbe3ec;
  border-radius: 14px;

  box-shadow:
    0 4px 14px rgba(15, 23, 42, 0.04);
}

.trackedu-pd-challenge-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #eff6ff;

  border-radius: 11px;

  font-size: 18px;
}

.trackedu-pd-challenge-card strong {
  display: block;

  margin-bottom: 4px;

  color: #0f172a;

  font-size: 11px;
  line-height: 1.25;
  font-weight: 850;
}

.trackedu-pd-challenge-card p {
  margin: 0 0 7px 0;

  color: #64748b;

  font-size: 9.5px;
  line-height: 1.45;
}

.trackedu-pd-challenge-tag {
  display: inline-block;

  color: #2563eb;

  font-size: 8px;
  line-height: 1.3;
  font-weight: 800;
}


/* CONNECT PHYSICAL + DIGITAL */

.trackedu-pd-connect-heading {
  margin: 2px 0 10px;

  color: #334155;

  font-size: 10px;
  line-height: 1.2;
  font-weight: 850;

  text-transform: uppercase;
  letter-spacing: 0.06em;
}


/* RESPONSIVE */

@media (max-width: 900px) {

  .trackedu-pd-showcase {
    grid-template-columns: 1fr;
  }

  .trackedu-pd-board-example img {
    height: auto;
    max-height: 340px;

    object-fit: contain;
  }

  .trackedu-pd-challenge-examples {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));

    grid-template-rows: none;
  }

}

@media (max-width: 650px) {

  .trackedu-pd-challenge-examples {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 800px) {

  .trackedu-pd-example-flow {
    flex-direction: column;
    align-items: stretch;
  }

  .trackedu-pd-flow-arrow {
    transform: rotate(90deg);
    align-self: center;
  }

}


.trackedu-board-preview {
  position: fixed;
  inset: 0;

  z-index: 1200000;

  display: none;
  align-items: center;
  justify-content: center;

  padding: 28px;

  background: rgba(15, 23, 42, 0.88);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.trackedu-board-preview.show {
  display: flex;
}

.trackedu-board-preview-content {
  width: min(94vw, 1400px);

  max-height: 90vh;

  overflow: hidden;

  background: #ffffff;

  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;

  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.38);
}

.trackedu-board-preview-content img {
  display: block;

  width: 100%;

  max-height: calc(90vh - 78px);

  object-fit: contain;

  background: #0f172a;
}

.trackedu-board-preview-caption {
  display: flex;
  flex-direction: column;

  gap: 3px;

  padding: 14px 18px;
}

.trackedu-board-preview-caption strong {
  color: #0f172a;

  font-size: 12px;
  font-weight: 850;
}

.trackedu-board-preview-caption span {
  color: #64748b;

  font-size: 10px;
  line-height: 1.45;
}

.trackedu-board-preview-close {
  position: fixed;

  top: 22px;
  right: 22px;

  width: 42px;
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 2;

  background: rgba(255, 255, 255, 0.94);

  border: none;
  border-radius: 50%;

  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.18);

  color: #0f172a;

  font-size: 15px;

  cursor: pointer;
}

@media (max-width: 700px) {

  .trackedu-board-preview {
    padding: 12px;
  }

  .trackedu-board-preview-content {
    width: 100%;

    border-radius: 16px;
  }

  .trackedu-board-preview-close {
    top: 14px;
    right: 14px;
  }

}


/* Student Access: desktop only */
@media (max-width: 1370px) {
  .desktop-student-access-only {
    display: none !important;
  }
}

@media (min-width: 1371px) {
  .desktop-student-access-only {
    display: block;
  }
}


/* ==========================================
   PILOT IMPACT DASHBOARD CARD
   Desktop only
   Hide on phones + iPads/tablets
   ========================================== */

@media (max-width: 1370px) {

  #pilotImpactDashboardCard {
    display: none !important;
  }

}

@media (max-width: 600px) {
  #planSelectorModal {
    padding: 0 !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
  }

  #planSelectorModal .modal-content {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }

  #planSelectorModal button[onclick="closePlanSelector()"] {
    position: fixed !important;
    top: 12px !important;
    right: 12px !important;
    z-index: 100 !important;
  }

  #planSelectorMarketingHeader {
    padding: 8px 20px 16px 20px !important;
  }
}


  .live-race-shell {
    display: grid;
    grid-template-columns:
      minmax(0, 1fr)
      clamp(300px, 24vw, 380px);
    gap: 18px;
    width: 100%;
    min-height: 0;
    align-items: start;
  }


  .live-race-main {
    min-width: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  }


  .live-race-kicker {
    color: #7c3aed;
    font-size: 10px;
    font-weight: 950;
    letter-spacing: 1px;
    text-transform: uppercase;
  }


  .live-race-title {
    margin: 4px 0 2px 0;
    color: #0f172a;
    font-size: clamp(26px, 3.5vw, 44px);
    font-weight: 950;
    line-height: 1.03;
  }


  .live-race-subtitle {
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
  }


  .live-race-track {
    margin-top: 16px;
    display: grid;
    gap: 10px;
  }


  .live-race-lane {
    position: relative;
    min-height: 70px;
    display: grid;
    grid-template-columns:
      120px
      minmax(0, 1fr)
      64px;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #f8fafc;
    overflow: hidden;
  }


  .live-race-house {
    min-width: 0;
  }


  .live-race-house-name {
    color: #0f172a;
    font-size: 14px;
    font-weight: 950;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }


  .live-race-house-round {
    margin-top: 3px;
    color: #64748b;
    font-size: 9px;
    font-weight: 800;
  }


  .live-race-road {
    position: relative;
    height: 34px;
    border-radius: 999px;
    background:
      repeating-linear-gradient(
        90deg,
        rgba(148, 163, 184, 0.38) 0,
        rgba(148, 163, 184, 0.38) 2px,
        transparent 2px,
        transparent 13%
      ),
      #ffffff;
    border: 1px solid #cbd5e1;
    overflow: visible;
  }


  .live-race-progress {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    border-radius: 999px;
    opacity: 0.16;
    transition: width 0.55s ease;
  }


  .live-race-runner {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 4px solid currentColor;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
    font-size: 16px;
    font-weight: 950;
    transition: left 0.55s ease;
    z-index: 2;
  }


  .live-race-finish-line {
    position: absolute;
    right: 6px;
    top: -5px;
    bottom: -5px;
    width: 18px;
    border-radius: 3px;
    background:
      conic-gradient(
        #0f172a 25%,
        #ffffff 0 50%,
        #0f172a 0 75%,
        #ffffff 0
      )
      0 0 /
      9px 9px;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
  }


  .live-race-place {
    text-align: center;
    color: #475569;
    font-size: 10px;
    font-weight: 900;
  }


  .live-race-place.finished {
    color: #7c3aed;
    font-size: 14px;
  }


  .live-race-side {
    align-self: start;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }


  .live-race-winner {
    margin-top: 12px;
    margin-bottom: 4px;
    padding: 14px;
    border-radius: 15px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    text-align: center;
    font-weight: 950;
  }


  .live-race-side-link {
    margin: 0 auto 10px auto;
    padding: 0;
    border: none;
    background: transparent;
    color: #475569;
    font-family: inherit;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }


  .live-race-side-link:hover {
    color: #7c3aed;
  }


  .live-race-shell.compact .live-race-track {
    gap: 8px;
  }


  .live-race-shell.compact .live-race-lane {
    min-height: 60px;
    grid-template-columns:
      100px
      minmax(0, 1fr)
      52px;
    padding: 8px 9px;
  }


  .live-race-shell.compact .live-race-road {
    height: 30px;
  }


  .live-race-shell.compact .live-race-runner {
    width: 30px;
    height: 30px;
    font-size: 14px;
    border-width: 3px;
  }


  .live-race-shell.compact .live-race-house-name {
    font-size: 12px;
  }


  .live-race-shell.compact .live-race-house-round {
    font-size: 8px;
  }


  .live-race-shell.extra-compact .live-race-track {
    gap: 7px;
  }


  .live-race-shell.extra-compact .live-race-lane {
    min-height: 54px;
    grid-template-columns:
      92px
      minmax(0, 1fr)
      50px;
    padding: 7px 8px;
  }


  .live-race-shell.extra-compact .live-race-road {
    height: 26px;
  }


  .live-race-shell.extra-compact .live-race-runner {
    width: 26px;
    height: 26px;
    font-size: 13px;
    border-width: 3px;
  }


  .live-race-shell.extra-compact .live-race-house-name {
    font-size: 11px;
  }


  .live-race-shell.extra-compact .live-race-house-round {
    font-size: 8px;
  }


  @media (max-width: 1100px) {

    .live-race-shell {
      grid-template-columns:
        minmax(0, 1fr)
        280px;
    }

  }


  @media (max-width: 900px) {

    .live-race-shell {
      grid-template-columns: 1fr;
    }

    .live-race-side {
      order: -1;
    }

    .live-race-lane {
      grid-template-columns:
        95px
        minmax(0, 1fr)
        58px;
    }

  }


  @media (max-width: 640px) {

    .live-race-main {
      padding: 14px;
    }

    .live-race-title {
      font-size: 30px;
    }

    .live-race-lane {
      min-height: 58px;
      grid-template-columns:
        82px
        minmax(0, 1fr)
        48px;
      gap: 8px;
      padding: 8px;
    }

    .live-race-road {
      height: 28px;
    }

    .live-race-runner {
      width: 28px;
      height: 28px;
      font-size: 13px;
      border-width: 3px;
    }

  }


    .live-race-side {
    min-width: 0;
    text-align: center;
  }


  .live-race-side::before {
    content: 'HOUSE CONTROLLERS';
    display: block;
    margin-bottom: 4px;
    color: #7c3aed;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 1px;
  }


    .live-race-lane,
  .live-display-race-lane {
    transition:
      transform 0.25s ease,
      box-shadow 0.25s ease,
      border-color 0.25s ease,
      background 0.25s ease;
  }


  .live-race-lane.race-advanced,
  .live-display-race-lane.race-advanced {
    animation:
      liveRaceAdvancePulse
      0.9s
      ease;
  }


  .live-race-lane.race-final-lap,
  .live-display-race-lane.race-final-lap {
    animation:
      liveRaceFinalPulse
      1.05s
      ease;
  }


  .live-race-lane.race-advanced
  .live-race-runner,
  .live-display-race-lane.race-advanced
  .live-display-race-marker {
    animation:
      liveRaceRunnerBounce
      0.75s
      ease;
  }


  .live-race-lane.race-final-lap
  .live-race-runner,
  .live-display-race-lane.race-final-lap
  .live-display-race-marker {
    animation:
      liveRaceWinnerBounce
      1s
      ease;
  }


  @keyframes liveRaceAdvancePulse {

    0% {
      transform: scale(1);
    }

    35% {
      transform: scale(1.012);
      box-shadow:
        0 0 0 3px rgba(139, 92, 246, 0.18),
        0 8px 24px rgba(15, 23, 42, 0.14);
    }

    100% {
      transform: scale(1);
    }

  }


  @keyframes liveRaceFinalPulse {

    0% {
      transform: scale(1);
    }

    30% {
      transform: scale(1.018);
      box-shadow:
        0 0 0 4px rgba(251, 191, 36, 0.30),
        0 10px 28px rgba(251, 191, 36, 0.20);
    }

    60% {
      transform: scale(1.008);
    }

    100% {
      transform: scale(1);
    }

  }


  @keyframes liveRaceRunnerBounce {

    0%,
    100% {
      transform:
        translate(-50%, -50%)
        scale(1);
    }

    45% {
      transform:
        translate(-50%, -62%)
        scale(1.16);
    }

  }


  @keyframes liveRaceWinnerBounce {

    0%,
    100% {
      transform:
        translate(-50%, -50%)
        scale(1);
    }

    30% {
      transform:
        translate(-50%, -68%)
        scale(1.28)
        rotate(-5deg);
    }

    55% {
      transform:
        translate(-50%, -45%)
        scale(1.16)
        rotate(5deg);
    }

    75% {
      transform:
        translate(-50%, -56%)
        scale(1.22);
    }

  }


  .live-challenge-confetti-piece {
    position: fixed;
    top: -18px;
    z-index: 200500;
    pointer-events: none;
    border-radius: 2px;
    animation:
      liveChallengeConfettiFall
      2.4s
      cubic-bezier(0.2, 0.8, 0.25, 1)
      forwards;
  }


  @keyframes liveChallengeConfettiFall {

    0% {
      transform:
        translateY(0)
        rotate(0deg);
      opacity: 1;
    }

    100% {
      transform:
        translateY(105vh)
        rotate(760deg);
      opacity: 0;
    }

  }


  @media (
    prefers-reduced-motion:
    reduce
  ) {

    .live-race-lane,
    .live-display-race-lane,
    .live-race-runner,
    .live-display-race-marker,
    .live-challenge-confetti-piece {
      animation: none !important;
      transition: none !important;
    }

  }




  /* ==========================================
   HOUSE WORD HUNT - STUDENT PORTAL
   ========================================== */

.house-word-hunt-student-hub {
  margin-top: 1rem;
  padding: 2rem;
  background:
    radial-gradient(
      circle at center,
      #083344 0%,
      #020617 100%
    );
  border-color: #22d3ee;
}

.house-word-hunt-card {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 22px;
  border-radius: 24px;
  border: 1px solid rgba(34,211,238,0.35);
  background:
    linear-gradient(
      145deg,
      rgba(8,51,68,0.95),
      rgba(15,23,42,0.98)
    );
}

.house-word-hunt-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.house-word-hunt-title {
  color: #ffffff;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.2;
}

.house-word-hunt-meta {
  margin-top: 5px;
  color: #94a3b8;
  font-size: 0.8rem;
}

.house-word-hunt-house-pill {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(34,211,238,0.12);
  border: 1px solid rgba(34,211,238,0.35);
  color: #67e8f9;
  font-size: 0.75rem;
  font-weight: 800;
}

.house-word-hunt-words {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
}

.house-word-hunt-word {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.10);
  color: #cbd5e1;
  font-size: 0.72rem;
  font-weight: 800;
}

.house-word-hunt-word.found {
  background: rgba(16,185,129,0.18);
  border-color: rgba(16,185,129,0.45);
  color: #6ee7b7;
  text-decoration: line-through;
}

.house-word-hunt-grid {
  width: min(100%, 560px);
  margin: 18px auto;
  display: grid;
  gap: 4px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.house-word-hunt-cell {
  aspect-ratio: 1 / 1;
  min-width: 0;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: #f8fafc;
  font-family: 'Outfit', sans-serif;
  font-weight: 900;
  font-size: clamp(0.72rem, 2.4vw, 1rem);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.house-word-hunt-cell.selected {
  background: #0891b2;
  border-color: #67e8f9;
  color: white;
}

.house-word-hunt-cell.found {
  background: rgba(16,185,129,0.25);
  border-color: #34d399;
  color: #a7f3d0;
}

.house-word-hunt-help {
  text-align: center;
  color: #94a3b8;
  font-size: 0.75rem;
  line-height: 1.5;
}

.house-word-hunt-progress {
  margin-top: 18px;
}

.house-word-hunt-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
}

.house-word-hunt-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #22d3ee;
  transition: width 0.3s ease;
}

.house-word-hunt-progress-text {
  margin-top: 7px;
  text-align: center;
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 700;
}


/* iPad */
@media (min-width: 768px) and (max-width: 1370px) {

  .house-word-hunt-card {
    max-width: 700px;
    padding: 22px;
  }

  .house-word-hunt-grid {
    width: min(100%, 600px);
    gap: 5px;
  }

  .house-word-hunt-cell {
    border-radius: 9px;
  }

}


/* Mobile */
@media (max-width: 767px) {

  .house-word-hunt-student-hub {
    padding: 1rem !important;
  }

  .house-word-hunt-card {
    padding: 16px 12px;
    border-radius: 20px;
  }

  .house-word-hunt-top {
    flex-direction: column;
    gap: 10px;
  }

  .house-word-hunt-house-pill {
    align-self: flex-start;
  }

  .house-word-hunt-title {
    font-size: 1.15rem;
  }

  .house-word-hunt-grid {
    width: 100%;
    gap: 3px;
  }

  .house-word-hunt-cell {
    border-radius: 6px;
    font-size: clamp(0.68rem, 3.7vw, 0.9rem);
  }

  .house-word-hunt-word {
    font-size: 0.68rem;
    padding: 5px 8px;
  }

}



/* House detail admin shortcuts: never appear on tablet or mobile. */
#expandedHouseView .house-v2-admin-shortcut {
  display: none !important;
}

@media (min-width: 1371px) {
  #expandedHouseView .house-v2-admin-shortcut {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 29px;
    padding: 5px 10px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    font-family: inherit;
    font-size: 11px;
    font-weight: 800;
    font-style: normal;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
  }

  /* Keep the selected-student strip compact on desktop */
#reasonSelectorModal
#reasonAwardControls {
  max-width: 1080px !important;
}


/* Single student needs an even tighter strip */
#reasonSelectorModal.reason-single-student
#reasonAwardControls {
  max-width: 820px !important;
}


/* Do not let the calculation stretch unnecessarily */
#reasonSelectorModal.reason-single-student
#reasonAwardPreview {
  flex:
    1
    1
    auto !important;

  max-width:
    430px !important;
}

#reasonSelectorModal
#reasonAwardControls {
  margin-top: 8px !important;
}

#reasonSelectorModal.reason-single-student
#reasonAwardPreview {
  max-width: 380px !important;
}

  #expandedHouseView .house-v2-admin-shortcut:hover {
    background: #dbeafe;
    border-color: #93c5fd;
  }

  #expandedHouseView .house-v2-admin-shortcut:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
  }

  #expandedHouseView .house-v2-admin-shortcut-motto {
    margin-left: 9px;
    vertical-align: middle;
  }

  #expandedHouseView .house-v2-admin-shortcut-badges {
    margin-top: 10px;
  }
}

.house-v2-milestone-row {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.house-v2-current-achievement {
  display: flex;
  align-items: center;
  gap: 14px;
}

.house-v2-achievement-progress {
  width: 100%;
  padding-top: 17px;
  border-top: 1px solid #e2e8f0;
}

.house-v2-certificate-btn {
  align-self: flex-start;
}

@media (max-width: 768px) {
  .house-v2-certificate-btn {
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    flex: 0 0 42px !important;
    border-radius: 12px !important;
  }

  .house-v2-certificate-btn .house-v2-certificate-label {
    display: none !important;
  }

  .house-v2-certificate-btn i {
    font-size: 17px !important;
    line-height: 1 !important;
    margin: 0 !important;
  }
}


/* ==========================================
   HOUSE ACHIEVEMENT - MOBILE PROGRESS
   ========================================== */

.house-v2-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.house-v2-progress-icon {
  flex: 0 0 auto;
  font-size: 22px;
  line-height: 1;
}

.house-v2-progress-track {
  flex: 1 1 auto;
  min-width: 0;
  height: 9px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.house-v2-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s ease;
}


@media (max-width: 680px) {

  .house-v2-milestone-row {
    display: grid !important;

    grid-template-columns:
      minmax(0, 1fr)
      auto !important;

    gap:
      14px
      10px !important;

    align-items: end !important;
  }

  .house-v2-current-achievement {
    grid-column: 1 / -1;
  }

  .house-v2-achievement-progress {
    grid-column: 1;

    min-width: 0;

    padding-top: 14px !important;
  }

  .house-v2-progress-row {
    display: block;
    width: 100%;
  }

  .house-v2-progress-icon {
    display: none;
  }

  .house-v2-progress-track {
    display: block;

    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;

    height: 10px;
  }

  .house-v2-certificate-btn {
    grid-column: 2;

    align-self: end !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;

    padding: 0 !important;

    border-radius: 12px !important;

    gap: 0 !important;

    font-size: 0 !important;

    white-space: nowrap;
    overflow: hidden;
  }

  .house-v2-certificate-btn i {
    font-size: 15px !important;
    margin: 0 !important;
    line-height: 1 !important;
  }

}


/* ==========================================
   HOUSE ACHIEVEMENT - IMPROVED MOBILE LAYOUT
   ========================================== */

@media (max-width: 680px) {

  .house-v2-milestone .house-v2-milestone-row {
    display: grid !important;
    grid-template-columns: 48px minmax(0, 1fr) 42px !important;
    column-gap: 12px !important;
    row-gap: 18px !important;
    align-items: center !important;
  }

  .house-v2-milestone .house-v2-current-achievement {
    display: contents !important;
  }

  .house-v2-milestone .house-v2-current-achievement > div:first-child {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  .house-v2-milestone .house-v2-current-achievement > div:nth-child(2) {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
  }

  .house-v2-milestone .house-v2-achievement-progress {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    padding-top: 14px !important;
  }

  .house-v2-milestone .house-v2-certificate-btn {
    grid-column: 3 !important;
    grid-row: 1 !important;

    justify-self: end !important;
    align-self: center !important;

    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;

    padding: 0 !important;
    margin: 0 !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .house-v2-milestone .house-v2-certificate-label {
    display: none !important;
  }

}

/* Existing desktop layout */
@media (min-width: 1371px) {

  .house-v2-milestone-row {
    display: grid;
    grid-template-columns:
      auto
      minmax(360px, 1fr)
      auto;

    align-items: center;
    gap: 28px;
  }

  .house-v2-current-achievement {
    min-width: 320px;
  }

  .house-v2-achievement-progress {
    min-width: 0;
    width: 100%;
    padding-top: 0;
    border-top: none;
    padding-left: 28px;
    border-left: 1px solid #e2e8f0;
  }

  .house-v2-certificate-btn {
    align-self: center;
  }

}



/* ==========================================
   STAFF ACCESS OVERVIEW - MOBILE
   ========================================== */

@media (max-width: 680px) {

  #staffAccessOverview {
    padding: 14px 14px 12px !important;
  }

  #staffAccessOverview
  > div:first-child {
    margin-bottom: 9px !important;
  }

  .staff-access-cards {
    display: flex !important;

    width: 100%;

    gap: 8px !important;

    overflow-x: auto !important;
    overflow-y: hidden !important;

    padding-bottom: 4px;

    scroll-snap-type: x proximity;

    -webkit-overflow-scrolling: touch;

    scrollbar-width: none;
  }

  .staff-access-cards::-webkit-scrollbar {
    display: none;
  }

  .staff-access-cards > div {
    flex: 0 0 150px !important;

    width: 150px !important;
    min-width: 150px !important;

    padding: 10px 11px !important;

    border-radius: 12px !important;

    scroll-snap-align: start;
  }

  .staff-access-cards
  > div
  > div:first-child {
    gap: 7px !important;
    margin-bottom: 6px !important;
  }

  .staff-access-cards
  > div
  > div:first-child
  > div:first-child {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;

    border-radius: 8px !important;

    font-size: 12px !important;
  }

  #staffAccessSystemAdminCount,
  #staffAccessAuthorizedCount,
  #staffAccessStaffCount,
  #staffAccessGoogleCount {
    font-size: 20px !important;
  }

  .staff-access-cards
  > div
  > div:nth-child(2) {
    font-size: 10px !important;
    line-height: 1.2 !important;
  }

  .staff-access-cards
  > div
  > div:nth-child(3) {
    margin-top: 1px !important;
    font-size: 8px !important;
    line-height: 1.25 !important;
  }

}


/* ==========================================
   STAFF FILTERS - MOBILE HORIZONTAL ROW
   ========================================== */

@media (max-width: 680px) {

  .staff-filter-shell {
    padding:
      12px
      14px !important;

    overflow-x: hidden;
  }

  .staff-filter-row {
    display: flex !important;

    width: 100%;

    gap: 8px !important;

    overflow-x: auto !important;
    overflow-y: hidden !important;

    padding-bottom: 3px;

    scroll-snap-type: x proximity;

    -webkit-overflow-scrolling: touch;

    scrollbar-width: none;
  }

  .staff-filter-row::-webkit-scrollbar {
    display: none;
  }

  .staff-filter-search {
    flex:
      0
      0
      210px !important;

    width: 210px !important;
    min-width: 210px !important;

    scroll-snap-align: start;
  }

  .staff-filter-select {
    flex:
      0
      0
      150px !important;

    width: 150px !important;
    min-width: 150px !important;

    scroll-snap-align: start;
  }

  #staffSearchInput {
    height: 40px !important;

    padding:
      0
      12px
      0
      38px !important;

    font-size: 13px !important;

    line-height: 40px !important;
  }

  .staff-filter-search
  > i {
    left: 13px !important;
    font-size: 13px !important;
  }

  #staffListHouseFilter,
  #staffListRoleFilter {
    height: 40px !important;

    font-size: 13px !important;

    padding:
      0
      30px
      0
      11px !important;
  }

}



/* ==========================================
   STAFF DIRECTORY HEADER - MOBILE
   ========================================== */

@media (max-width: 680px) {

  .staff-directory-header {
    padding:
      11px
      14px !important;

    flex-wrap: nowrap !important;

    min-height: 58px;
  }

  .staff-directory-header h2 {
    flex: 1 1 auto;

    min-width: 0;

    font-size: 17px !important;

    gap: 8px !important;

    white-space: nowrap;
  }

  .staff-directory-header h2 i {
    font-size: 17px !important;
  }

  .staff-directory-header-actions {
    gap: 7px !important;
  }

  .staff-directory-profile-btn {
    width: 36px !important;
    height: 36px !important;

    min-width: 36px !important;

    padding: 0 !important;

    border-radius: 50% !important;

    justify-content: center !important;
  }

  .staff-directory-profile-btn i {
    font-size: 13px !important;
    margin: 0 !important;
  }

  .staff-directory-profile-label {
    display: none !important;
  }

  .staff-directory-close-btn {
    width: 36px !important;
    height: 36px !important;

    min-width: 36px !important;

    font-size: 14px !important;
  }

}




/* ==========================================
   REASONS + ADJUST BUTTON LABELS
   Desktop + iPad
   ========================================== */

/* Default */
#selectionToolbar
.reason-award-toolbar-label,
#selectionToolbar
.adjust-toolbar-label {
  display: none;
}


/* iPad / tablet */
@media (min-width: 769px) and (max-width: 1370px) {

  #selectionToolbar
  .action-group
  .reason-award-toolbar-btn,
  #selectionToolbar
  .action-group
  .adjust-toolbar-btn {
    width: auto !important;
    min-width: 0 !important;

    height: 40px !important;

    padding:
      0
      11px !important;

    margin: 0 !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    gap: 5px !important;

    flex:
      0
      0
      auto !important;

    color: #ffffff !important;

    border-radius: 10px !important;

    white-space: nowrap !important;
  }


  #selectionToolbar
  .reason-award-toolbar-btn {
    background: #f59e0b !important;

    box-shadow:
      0
      3px
      8px
      rgba(245,158,11,0.24) !important;
  }


  #selectionToolbar
  .adjust-toolbar-btn {
    background: #8b5cf6 !important;

    box-shadow:
      0
      3px
      8px
      rgba(139,92,246,0.24) !important;
  }


  #selectionToolbar
  .reason-award-toolbar-label,
  #selectionToolbar
  .adjust-toolbar-label {
    display: inline !important;

    font-size: 11px !important;
    font-weight: 800 !important;

    line-height: 1 !important;
  }

}


/* Desktop */
@media (min-width: 1371px) {

  #selectionToolbar
  .action-group
  .reason-award-toolbar-btn,
  #selectionToolbar
  .action-group
  .adjust-toolbar-btn {
    width: auto !important;
    min-width: 0 !important;

    height: 44px !important;
    min-height: 44px !important;

    padding:
      0
      14px !important;

    margin: 0 !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    gap: 7px !important;

    flex:
      0
      0
      auto !important;

    color: #ffffff !important;

    border: none !important;

    border-radius: 12px !important;

    white-space: nowrap !important;

    transform: none !important;
  }


  #selectionToolbar
  .reason-award-toolbar-btn {
    background: #f59e0b !important;

    box-shadow:
      0
      4px
      10px
      rgba(245,158,11,0.28) !important;
  }


  #selectionToolbar
  .adjust-toolbar-btn {
    background: #8b5cf6 !important;

    box-shadow:
      0
      4px
      10px
      rgba(139,92,246,0.28) !important;
  }


  #selectionToolbar
  .reason-award-toolbar-btn i,
  #selectionToolbar
  .adjust-toolbar-btn i {
    font-size: 15px !important;
  }


  #selectionToolbar
  .reason-award-toolbar-label,
  #selectionToolbar
  .adjust-toolbar-label {
    display: inline !important;

    font-size: 12px !important;
    font-weight: 800 !important;

    line-height: 1 !important;
  }


  #selectionToolbar
  .reason-award-toolbar-btn:hover,
  #selectionToolbar
  .adjust-toolbar-btn:hover {
    transform: translateY(-1px) !important;
  }

}


@media (max-width: 800px) {

  #recognitionIntegrationModal
  .integration-card
  #recognitionBehaviorContextEnabled {
    max-width:100%;
  }

}

@media (max-width: 800px) {

  #recognitionIntegrationModal
  .integration-card > div[style*="grid-template-columns:repeat(2"] {
    grid-template-columns:1fr !important;
  }

}

#studentRecognitionModal
.recognition-profile-timeline-v2
.recognition-timeline-item-v2 {
  padding:
    9px
    12px;
}


#studentRecognitionModal
.recognition-profile-timeline-v2
.recognition-timeline-inline {
  column-gap:6px;
  row-gap:4px;
}

#studentRecognitionModal
.recognition-profile-timeline-v2
.recognition-timeline-teacher,
#studentRecognitionModal
.recognition-profile-timeline-v2
.recognition-timeline-date {
  color:#64748b;

  font-size:10px;
  font-weight:650;
}


/* ==========================================
   DASHBOARD HOUSE POINTS / BEHAVIOUR SWITCH
   ========================================== */

.dashboard-overview-switch {
  display:none;

  align-items:center;
  gap:3px;

  padding:3px;

  border:1px solid #cbd5e1;
  border-radius:999px;

  background:#f8fafc;
}


@media (min-width:781px) {

  .dashboard-overview-switch {
    display:inline-flex;
  }

}


.dashboard-overview-switch-btn {
  min-height:28px;

  padding:
    0
    11px;

  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;

  border:0;
  border-radius:999px;

  background:transparent;
  color:#64748b;

  font-family:inherit;
  font-size:10px;
  font-weight:800;

  cursor:pointer;

  transition:
    background .18s ease,
    color .18s ease,
    box-shadow .18s ease;
}


.dashboard-overview-switch-btn:hover {
  color:#1d4ed8;
}


/* House Points: blue */
#dashboardHousePointsModeBtn.active {
  background:#2563eb;
  color:#ffffff;
  box-shadow:0 2px 6px rgba(37,99,235,.24);
}

/* Incidents: purple */
#dashboardBehaviourModeBtn.active {
  background:#7c3aed;
  color:#ffffff;
  box-shadow:0 2px 6px rgba(124,58,237,.24);
}

/* Rewards Store: green */
#dashboardOverviewSwitch #dashboardRewardsStoreModeBtn.active {
  background:#16a34a !important;
  color:#ffffff !important;
  box-shadow:0 2px 6px rgba(22,163,74,.24);
}

#dashboardOverviewSwitch .dashboard-overview-switch-btn.active i {
  color:#ffffff;
}

/* Student Activity: navy blue */
#dashboardOverviewSwitch #dashboardStudentActivityModeBtn.active {
  background:#1e3a8a !important;
  color:#ffffff !important;
  box-shadow:0 2px 8px rgba(30,58,138,.24);
}

#dashboardOverviewSwitch #dashboardStudentActivityModeBtn.active:hover {
  background:#172554 !important;
}

/* Student Activity: premium navy panel, matching School Store */

.ted-student-activity {
  width:100%;
  min-width:0;
  padding:18px;
  border:1px solid #d1def0;
  border-radius:16px;
  background:linear-gradient(
    145deg,
    #e5edfa 0%,
    #edf3fc 100%
  );
  color:#172554;
  box-shadow:0 3px 16px rgba(30,58,138,.045);
}

/* Dark mode: deep navy panel */

body.house-display-dark
#dashboard-section .ted-student-activity {
  background:linear-gradient(
    145deg,
    #101c31 0%,
    #172337 100%
  ) !important;
  border-color:#334155 !important;
  color:#e2e8f0;
}

/* Mobile and tablet */

@media (max-width:780px) {
  .ted-student-activity {
    padding:13px;
    border-radius:14px;
  }
}

/* Student Activity: light navy background */
body.dashboard-student-activity-mode
#dashboard-section .card:has(#dashboardStudentActivityOverview) {
  background:#e3ebf8 !important;
  border-color:#b8cbe8 !important;
  color:#0f172a !important;
}

/* Keep the header background consistent */
body.dashboard-student-activity-mode
#dashboard-section .card:has(#dashboardStudentActivityOverview)
.card-header {
  background:transparent !important;
}

/* Student Activity: dark mode */
body.house-display-dark.dashboard-student-activity-mode
#dashboard-section .card:has(#dashboardStudentActivityOverview) {
  background:#0f172a !important;
  border-color:#334155 !important;
  color:#f8fafc !important;
}

.ted-student-activity-period {
  display:inline-flex;
  align-items:center;
  gap:4px;
  padding:4px;
  margin-bottom:18px;
  border:1px solid #c4d6f0;
  border-radius:11px;
  background:#ffffff;
  box-shadow:0 2px 8px rgba(30,58,138,.04);
}

.ted-student-activity-period-btn {
  min-height:34px;
  padding:7px 16px;
  border:0;
  border-radius:8px;
  background:transparent;
  color:#1e3a8a;
  font-family:inherit;
  font-size:12px;
  font-weight:800;
  cursor:pointer;
}

.ted-student-activity-period-btn.active {
  background:#1e3a8a;
  color:#ffffff;
  box-shadow:0 2px 6px rgba(30,58,138,.18);
}

.ted-student-activity-period-btn:focus-visible {
  outline:3px solid #60a5fa;
  outline-offset:2px;
}

body.house-display-dark .ted-student-activity-period {
  background:#172337;
  border-color:#475569;
}

body.house-display-dark .ted-student-activity-period-btn {
  color:#bfdbfe;
}

body.house-display-dark .ted-student-activity-period-btn.active {
  background:#3b82f6;
  color:#ffffff;
}

.ted-student-activity-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(190px,1fr));
  gap:12px;
  margin-bottom:16px;
}

.ted-student-activity-card {
  min-width:0;
  padding:15px 16px;
  border:1px solid #d8e3f2;
  border-radius:12px;
  background:#ffffff;
  box-shadow:0 3px 12px rgba(30,58,138,.045);
  transition:border-color .18s ease, box-shadow .18s ease;
}

.ted-student-activity-card:hover {
  border-color:#93b4e8;
  box-shadow:0 5px 16px rgba(30,58,138,.08);
}

.ted-student-activity-label {
  color:#64748b;
  font-size:12px;
  font-weight:700;
}

.ted-student-activity-value {
  margin-top:8px;
  color:#0f172a;
  font-size:28px;
  font-weight:900;
}

.ted-student-activity-detail {
  margin-top:6px;
  color:#64748b;
  font-size:12px;
  line-height:1.5;
}

.ted-student-activity h3 {
  margin:0 0 12px;
  color:#0f172a;
  font-size:16px;
}

/* Student Activity: improved light-mode cards */
#dashboard-section .ted-student-activity-card {
  border-color:#e2e8f0;
  background:#ffffff;
  box-shadow:0 4px 16px rgba(15,23,42,.05);
}

#dashboard-section .ted-student-activity-grid
.ted-student-activity-card {
  border-top:3px solid #3b82f6;
}

#dashboard-section .ted-student-activity-value {
  color:#1e3a8a;
}

/* Student Activity: dark mode */
body.house-display-dark
#dashboard-section .ted-student-activity-card {
  background:#172337 !important;
  border-color:#334155 !important;
  box-shadow:0 4px 16px rgba(0,0,0,.15) !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-grid
.ted-student-activity-card {
  border-top-color:#60a5fa !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-card h3,
body.house-display-dark
#dashboard-section .ted-student-activity-row {
  color:#f1f5f9 !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-value {
  color:#93c5fd !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-label,
body.house-display-dark
#dashboard-section .ted-student-activity-detail {
  color:#cbd5e1 !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-row {
  border-bottom-color:#334155 !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity {
  color:#e2e8f0;
}

.ted-student-activity-row {
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:10px 0;
  border-bottom:1px solid #e2e8f0;
  font-size:13px;
}

.ted-student-activity-row:last-child {
  border-bottom:0;
}

/* ==========================================
   STUDENT ACTIVITY: REFINED DASHBOARD
   ========================================== */

/* Keep the outer dashboard clean */
body:not(.house-display-dark)
#dashboard-section .card:has(#dashboardStudentActivityOverview) {
  background:#ffffff !important;
}

/* Soft, neutral background */
body:not(.house-display-dark)
#dashboard-section .ted-student-activity {
  padding:20px !important;
  background:#f3f5f9 !important;
  border:1px solid #e1e6ef !important;
  border-radius:16px !important;
  box-shadow:none !important;
}

/* Balanced spacing */
#dashboard-section .ted-student-activity-grid {
  gap:12px;
  margin-bottom:14px;
}

/* Clean white cards */
body:not(.house-display-dark)
#dashboard-section .ted-student-activity-card {
  padding:18px 20px !important;
  background:#ffffff !important;
  border:1px solid #e2e8f0 !important;
  border-radius:12px !important;
  box-shadow:0 2px 8px rgba(15,23,42,.035) !important;
}

/* Coloured Student Portal summary cards */
body:not(.house-display-dark)
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(1) {
  border-top:3px solid #16a34a !important;
}

body:not(.house-display-dark)
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(2) {
  border-top:3px solid #9333ea !important;
}

body:not(.house-display-dark)
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(3) {
  border-top:3px solid #2563eb !important;
}

body:not(.house-display-dark)
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(4) {
  border-top:3px solid #d97706 !important;
}

/* Keep other Student Portal cards neutral */
body:not(.house-display-dark)
#dashboard-section .ted-student-activity-results
.ted-student-activity-card {
  border-top:1px solid #e2e8f0 !important;
}

/* Clear, restrained labels */
#dashboard-section .ted-student-activity-label {
  color:#64748b;
  font-size:12px;
  font-weight:750;
  letter-spacing:.01em;
}

/* Strong statistic values */
body:not(.house-display-dark)
#dashboard-section .ted-student-activity-value {
  margin-top:10px;
  color:#172554 !important;
  font-size:34px;
  line-height:1.15;
  font-weight:850;
  letter-spacing:-.04em;
}

/* Supporting text */
#dashboard-section .ted-student-activity-detail {
  font-size:12px;
  line-height:1.5;
}

/* Bottom section headings */
body:not(.house-display-dark)
#dashboard-section .ted-student-activity-card h3 {
  color:#1e293b;
  font-size:15px;
  font-weight:800;
  line-height:1.4;
}

/* Today's date selector */
body:not(.house-display-dark)
#dashboard-section .ted-student-activity-period {
  background:#ffffff;
  border:1px solid #dbe2ec;
  border-radius:10px;
  box-shadow:none;
}

/* Mobile */
@media (max-width:780px) {
  #dashboard-section .ted-student-activity {
    padding:13px !important;
  }

  #dashboard-section .ted-student-activity-card {
    padding:15px !important;
  }
}

/* Dark mode */
body.house-display-dark
#dashboard-section .ted-student-activity {
  background:#101827 !important;
  border-color:#334155 !important;
  box-shadow:none !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-card {
  background:#1e293b !important;
  border-color:#334155 !important;
  box-shadow:none !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(1) {
  border-top:3px solid #4ade80 !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(2) {
  border-top:3px solid #c084fc !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(3) {
  border-top:3px solid #60a5fa !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(4) {
  border-top:3px solid #fbbf24 !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-results
.ted-student-activity-card {
  border-top:1px solid #334155 !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-value {
  color:#bfdbfe !important;
}

/* ==========================================
   STUDENT ACTIVITY: HOUSE SUMMARY
   ========================================== */

#dashboard-section .ted-activity-house-mini {
  display:flex;
  flex-wrap:wrap;
  align-items:flex-start;
  gap:6px;
  margin-top:13px;
  padding-top:12px;
  border-top:1px solid #e2e8f0;
  min-width:0;
}

#dashboard-section .ted-activity-house-chip {
  display:inline-flex;
  align-items:center;
  gap:6px;
  min-width:0;
  max-width:100%;
  padding:5px 8px;
  border:1px solid #e2e8f0;
  border-radius:7px;
  background:#f8fafc;
  color:#475569;
  font-size:11px;
  line-height:1.4;
  font-weight:650;
}

#dashboard-section .ted-activity-house-dot {
  width:8px;
  height:8px;
  min-width:8px;
  border-radius:50%;
}

#dashboard-section .ted-activity-house-name {
  min-width:0;
  overflow-wrap:anywhere;
}

#dashboard-section .ted-activity-house-chip strong {
  color:#172554;
  font-size:12px;
  font-weight:850;
  font-variant-numeric:tabular-nums;
}

body.house-display-dark
#dashboard-section .ted-activity-house-mini {
  border-top-color:#475569;
}

body.house-display-dark
#dashboard-section .ted-activity-house-chip {
  background:#263449;
  border-color:#475569;
  color:#e2e8f0;
}

body.house-display-dark
#dashboard-section .ted-activity-house-chip strong {
  color:#f1f5f9;
}

/* ==========================================
   STUDENT ACTIVITY: HOUSE FILTER AND COMPARISON
   ========================================== */

/* Student Portal: filters left, Student App right */
#dashboard-section .ted-activity-controls {
  display:flex;
  align-items:center;
  justify-content:flex-start;
  flex-wrap:wrap;
  gap:12px;
  margin-bottom:16px;
}

#dashboard-section .ted-student-activity-app-btn {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  margin-left:auto;
  min-height:36px;
  padding:8px 14px;
  border:1px solid #bfdbfe;
  border-radius:10px;
  background:#eff6ff;
  color:#1e3a8a;
  font-family:inherit;
  font-size:12px;
  font-weight:800;
  white-space:nowrap;
  cursor:pointer;
}

#dashboard-section .ted-student-activity-app-btn:hover {
  background:#dbeafe;
  box-shadow:0 3px 10px rgba(30,58,138,.12);
}

#dashboard-section .ted-student-activity-app-btn:focus-visible {
  outline:3px solid #60a5fa;
  outline-offset:3px;
}

body.house-display-dark
#dashboard-section .ted-student-activity-app-btn {
  background:#1e3a8a;
  border-color:#3b82f6;
  color:#dbeafe;
}

@media (max-width:600px) {
  #dashboard-section .ted-student-activity-app-btn {
    margin-left:0;
  }
}

#dashboard-section .ted-activity-controls
.ted-student-activity-period {
  margin-bottom:0;
}

#dashboard-section .ted-activity-house-filter {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:10px;
  margin:0;
}

@media (max-width:600px) {
  #dashboard-section .ted-activity-controls {
    gap:10px;
  }
}

#dashboard-section .ted-activity-house-filter label {
  font-size:13px;
  font-weight:750;
  color:#475569;
}

#dashboard-section .ted-activity-house-filter select {
  min-width:160px;
  max-width:100%;
  padding:9px 12px;
  border:1px solid #cbd5e1;
  border-radius:9px;
  background:#fff;
  color:#1e293b;
  font-size:13px;
  font-weight:650;
}

#dashboard-section .ted-activity-compare {
  margin-top:14px;
  margin-bottom:14px;
  border:1px solid #dbe2ec;
  border-radius:11px;
  background:#fff;
  overflow:hidden;
}

#dashboard-section .ted-activity-compare summary {
  padding:15px 17px;
  cursor:pointer;
  color:#1e293b;
  font-size:14px;
  font-weight:800;
}

#dashboard-section .ted-activity-compare summary:focus-visible {
  outline:2px solid #2563eb;
  outline-offset:-3px;
}

#dashboard-section .ted-activity-compare-scroll {
  overflow-x:auto;
  border-top:1px solid #e2e8f0;
}

#dashboard-section .ted-activity-compare table {
  width:100%;
  min-width:670px;
  border-collapse:collapse;
  font-size:12px;
  text-align:left;
}

#dashboard-section .ted-activity-compare th,
#dashboard-section .ted-activity-compare td {
  padding:12px 14px;
  border-bottom:1px solid #e2e8f0;
}

#dashboard-section .ted-activity-compare thead th {
  background:#f8fafc;
  color:#475569;
  font-weight:800;
  white-space:nowrap;
}

#dashboard-section .ted-activity-compare tbody th {
  font-weight:750;
  color:#1e293b;
}

#dashboard-section .ted-activity-compare tbody td {
  color:#334155;
  font-variant-numeric:tabular-nums;
}

#dashboard-section .ted-compare-house {
  display:inline-flex;
  align-items:center;
  gap:8px;
  white-space:nowrap;
}

body.house-display-dark
#dashboard-section .ted-activity-house-filter label {
  color:#cbd5e1;
}

body.house-display-dark
#dashboard-section .ted-activity-house-filter select,
body.house-display-dark
#dashboard-section .ted-activity-compare {
  background:#1e293b;
  border-color:#475569;
  color:#f1f5f9;
}

body.house-display-dark
#dashboard-section .ted-activity-compare summary,
body.house-display-dark
#dashboard-section .ted-activity-compare tbody th,
body.house-display-dark
#dashboard-section .ted-activity-compare tbody td {
  color:#f1f5f9;
}

body.house-display-dark
#dashboard-section .ted-activity-compare thead th {
  background:#263449 !important;
  color:#cbd5e1 !important;
}

body.house-display-dark
#dashboard-section .ted-activity-compare table {
  background:#1e293b !important;
  color:#e2e8f0 !important;
}

body.house-display-dark
#dashboard-section .ted-activity-compare tbody tr {
  background:#1e293b !important;
}

body.house-display-dark
#dashboard-section .ted-activity-compare tbody tr:nth-child(even) {
  background:#243247 !important;
}

body.house-display-dark
#dashboard-section .ted-activity-compare tbody th,
body.house-display-dark
#dashboard-section .ted-activity-compare tbody td {
  background:transparent !important;
  color:#e2e8f0 !important;
  border-bottom-color:#334155 !important;
}

body.house-display-dark
#dashboard-section .ted-activity-compare-scroll {
  border-top-color:#334155 !important;
}

body.house-display-dark
#dashboard-section .ted-activity-compare th,
body.house-display-dark
#dashboard-section .ted-activity-compare td,
body.house-display-dark
#dashboard-section .ted-activity-compare-scroll {
  border-color:#475569;
}

/* ==========================================
   STUDENT PORTAL: SUMMARY CARD COLOURS
   ========================================== */

/* Coloured top borders */
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(1) {
  border-top-color:#16a34a !important;
}

#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(2) {
  border-top-color:#9333ea !important;
}

#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(3) {
  border-top-color:#2563eb !important;
}

#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(4) {
  border-top-color:#d97706 !important;
}

/* Small icons beside each heading */
#dashboard-section .ted-student-activity-stats
.ted-student-activity-label::before {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:24px;
  height:24px;
  margin-right:8px;
  border-radius:7px;
  font-size:13px;
  vertical-align:middle;
}

#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(1)
.ted-student-activity-label::before {
  content:"✓";
  background:#dcfce7;
  color:#15803d;
}

#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(2)
.ted-student-activity-label::before {
  content:"?";
  background:#f3e8ff;
  color:#7e22ce;
}

#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(3)
.ted-student-activity-label::before {
  content:"⌕";
  background:#dbeafe;
  color:#1d4ed8;
  font-size:19px;
}

#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(4)
.ted-student-activity-label::before {
  content:"★";
  background:#fef3c7;
  color:#b45309;
}

/* Keep the lower results panel neutral */
#dashboard-section .ted-student-activity-results
.ted-student-activity-card {
  border-top:1px solid #e2e8f0 !important;
}

/* Dark mode */
body.house-display-dark
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(1) {
  border-top-color:#4ade80 !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(2) {
  border-top-color:#c084fc !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(3) {
  border-top-color:#60a5fa !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-stats
.ted-student-activity-card:nth-child(4) {
  border-top-color:#fbbf24 !important;
}

body.house-display-dark
#dashboard-section .ted-student-activity-results
.ted-student-activity-card {
  border-top-color:#334155 !important;
}

/* ==========================================
   STUDENT ACTIVITY: RESPONSIVE RESULTS
   ========================================== */

/* Four compact summary cards */
#dashboard-section .ted-student-activity-stats {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:12px;
  align-items:start;
}

/* Mystery Word Winners panel */
#dashboard-section .ted-student-activity-results {
  display:grid;
  grid-template-columns:minmax(0,1fr);
  gap:12px;
  align-items:start;
}

/* Never stretch result cards */
#dashboard-section .ted-student-activity-results
.ted-student-activity-card {
  min-width:0;
  height:auto;
  min-height:125px;
  align-self:start;
}

/* Clean section headings */
#dashboard-section .ted-student-activity-results h3 {
  margin:0 0 16px;
  font-size:14px;
  line-height:1.4;
  font-weight:800;
}

/* Winner details */
#dashboard-section .ted-activity-winner {
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:12px;
  min-width:0;
}

/* Winner's name */
#dashboard-section .ted-activity-winner-name {
  max-width:100%;
  color:#172554;
  font-size:19px;
  line-height:1.35;
  font-weight:850;
  letter-spacing:-.025em;
  overflow-wrap:anywhere;
}

/* House and Class on one line when space allows */
#dashboard-section .ted-activity-winner-meta {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:7px;
  width:100%;
}

/* Small, elegant badges */
#dashboard-section .ted-activity-winner-badge {
  display:inline-flex;
  align-items:center;
  gap:7px;
  max-width:100%;
  min-width:0;
  padding:7px 10px;
  border:1px solid #dbe4f0;
  border-radius:8px;
  background:#f8fafc;
  color:#334155;
  font-size:12px;
  line-height:1.4;
  font-weight:750;
  overflow-wrap:anywhere;
}

#dashboard-section .ted-activity-winner-badge i {
  flex-shrink:0;
  color:#64748b;
  font-size:11px;
}

/* House rankings */
#dashboard-section .ted-student-activity-results
.ted-student-activity-card:has(.ted-student-activity-row) {
  max-height:340px;
  overflow-y:auto;
  scrollbar-width:thin;
}

/* Individual House rows */
#dashboard-section .ted-student-activity-row {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:6px 12px;
  padding:11px 0;
  font-size:12px;
  line-height:1.5;
}

#dashboard-section .ted-student-activity-row span {
  min-width:0;
  overflow-wrap:anywhere;
}

#dashboard-section .ted-student-activity-row strong {
  color:#172554;
  font-weight:800;
  white-space:normal;
}

/* Mystery Word winner history */
#dashboard-section .ted-mystery-winners {
  display:flex;
  flex-direction:column;
  gap:0;
  min-width:0;
}

#dashboard-section .ted-mystery-winner-count {
  color:#64748b;
  font-size:12px;
  font-weight:700;
  padding-bottom:7px;
}

#dashboard-section .ted-mystery-winner-row {
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  padding:11px 0;
  border-bottom:1px solid #e2e8f0;
  min-width:0;
}

#dashboard-section .ted-mystery-winner-info {
  display:flex;
  flex-direction:column;
  gap:4px;
  min-width:0;
}

#dashboard-section .ted-mystery-winner-info strong {
  color:#172554;
  font-size:13px;
  font-weight:800;
  line-height:1.4;
  overflow-wrap:anywhere;
}

#dashboard-section .ted-mystery-winner-info span,
#dashboard-section .ted-mystery-winner-row time {
  color:#64748b;
  font-size:11px;
  line-height:1.4;
}

#dashboard-section .ted-mystery-winner-row time {
  flex-shrink:0;
  white-space:nowrap;
}

#dashboard-section .ted-mystery-more summary {
  padding:12px 0 3px;
  color:#1d4ed8;
  font-size:12px;
  font-weight:800;
  cursor:pointer;
}

#dashboard-section .ted-mystery-more summary:hover {
  text-decoration:underline;
}

body.house-display-dark
#dashboard-section .ted-mystery-winner-info strong {
  color:#f1f5f9;
}

body.house-display-dark
#dashboard-section .ted-mystery-winner-row {
  border-bottom-color:#475569;
}

body.house-display-dark
#dashboard-section .ted-mystery-winner-info span,
body.house-display-dark
#dashboard-section .ted-mystery-winner-row time,
body.house-display-dark
#dashboard-section .ted-mystery-winner-count {
  color:#cbd5e1;
}

body.house-display-dark
#dashboard-section .ted-mystery-more summary {
  color:#93c5fd;
}

/* ==========================================
   STUDENT PORTAL: MYSTERY WORD WINNERS
   ========================================== */

body:not(.house-display-dark)
#dashboard-section .ted-mystery-history-card {
  background:#ffffff !important;
  border:1px solid #e2e8f0 !important;
  border-top:3px solid #eab308 !important;
  padding:16px 20px !important;
}

#dashboard-section .ted-mystery-history-header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:10px;
  margin-bottom:8px;
}

#dashboard-section .ted-mystery-history-header h3 {
  margin:0;
}

#dashboard-section .ted-mystery-history-badge {
  display:inline-flex;
  align-items:center;
  padding:6px 11px;
  border-radius:999px;
  background:#fef9c3;
  color:#854d0e;
  font-size:12px;
  font-weight:800;
  white-space:nowrap;
}

#dashboard-section .ted-mystery-history-card
.ted-mystery-winner-row {
  align-items:center;
  padding:9px 0;
}

#dashboard-section .ted-mystery-history-card
.ted-mystery-winner-row:last-child {
  border-bottom:0;
}

#dashboard-section .ted-mystery-history-card
.ted-mystery-winner-info strong {
  font-size:15px;
  font-weight:850;
  line-height:1.35;
}

#dashboard-section .ted-mystery-history-card
.ted-mystery-winner-info span {
  font-size:12px;
}

/* Dark mode */
body.house-display-dark
#dashboard-section .ted-mystery-history-card {
  border-top:3px solid #facc15 !important;
}

body.house-display-dark
#dashboard-section .ted-mystery-history-badge {
  background:#713f12;
  color:#fef08a;
}

/* Tablet */
@media (max-width:1100px) {
  #dashboard-section .ted-student-activity-stats {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  #dashboard-section .ted-student-activity-results {
    grid-template-columns:minmax(0,1fr);
  }
}

/* Phone */
@media (max-width:700px) {
  #dashboard-section .ted-student-activity-stats {
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:9px;
  }

  #dashboard-section .ted-student-activity-results {
    grid-template-columns:minmax(0,1fr);
    gap:10px;
  }

  #dashboard-section .ted-student-activity-stats
  .ted-student-activity-card {
    padding:13px !important;
  }

  #dashboard-section .ted-student-activity-value {
    font-size:28px !important;
  }

  #dashboard-section .ted-activity-winner-name {
    font-size:18px;
  }
}

/* Very narrow phones */
@media (max-width:380px) {
  #dashboard-section .ted-student-activity-stats {
    grid-template-columns:minmax(0,1fr);
  }
}

/* Dark mode */
body.house-display-dark
#dashboard-section .ted-activity-winner-name,
body.house-display-dark
#dashboard-section .ted-student-activity-row strong {
  color:#f1f5f9 !important;
}

body.house-display-dark
#dashboard-section .ted-activity-winner-badge {
  background:#263449;
  border-color:#475569;
  color:#e2e8f0;
}

body.house-display-dark
#dashboard-section .ted-activity-winner-badge i {
  color:#93c5fd;
}

/* Student Activity: Student Voice Poll */

#dashboard-section .ted-activity-poll {
  padding:20px !important;
  margin-bottom:14px;
  min-width:0;
}

#dashboard-section .ted-activity-poll-header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:10px;
  margin-bottom:12px;
}

#dashboard-section .ted-activity-poll-header h3 {
  margin:0;
  font-size:15px;
  font-weight:800;
  line-height:1.4;
}

#dashboard-section .ted-activity-poll-total {
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  background:#e9eef8;
  color:#1e3a8a;
  font-size:12px;
  font-weight:800;
}

#dashboard-section .ted-activity-poll-question {
  margin:0 0 18px;
  color:#172554;
  font-size:16px;
  line-height:1.5;
  font-weight:750;
  overflow-wrap:anywhere;
}

#dashboard-section .ted-activity-poll-options {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
}

#dashboard-section .ted-activity-poll-option {
  min-width:0;
}

#dashboard-section .ted-activity-poll-option-head {
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  flex-wrap:wrap;
  gap:5px 10px;
  margin-bottom:9px;
  color:#334155;
  font-size:12px;
  line-height:1.5;
}

#dashboard-section .ted-activity-poll-option-head span {
  min-width:0;
  overflow-wrap:anywhere;
}

#dashboard-section .ted-activity-poll-option-head strong {
  color:#172554;
  font-weight:800;
  white-space:nowrap;
}

#dashboard-section .ted-activity-poll-track {
  height:9px;
  overflow:hidden;
  border-radius:999px;
  background:#e2e8f0;
}

#dashboard-section .ted-activity-poll-fill {
  height:100%;
  border-radius:999px;
  background:#3b82f6;
  transition:width .2s ease;
}

@media (max-width:900px) {
  #dashboard-section .ted-activity-poll-options {
    grid-template-columns:minmax(0,1fr);
  }
}

body.house-display-dark
#dashboard-section .ted-activity-poll-question,
body.house-display-dark
#dashboard-section .ted-activity-poll-option-head,
body.house-display-dark
#dashboard-section .ted-activity-poll-option-head strong {
  color:#e2e8f0;
}

body.house-display-dark
#dashboard-section .ted-activity-poll-total {
  background:#263b59;
  color:#bfdbfe;
}

body.house-display-dark
#dashboard-section .ted-activity-poll-track {
  background:#334155;
}

/* ==========================================
   STUDENT PORTAL: PINK STUDENT VOICE POLL
   ========================================== */

/* Soft pink card */
body:not(.house-display-dark)
#dashboard-section .ted-student-activity-card.ted-activity-poll {
  background:#fffafc !important;
  border:1px solid #fce7f3 !important;
  box-shadow:0 2px 10px rgba(236,72,153,.04) !important;
}

/* Pink heading icon */
body:not(.house-display-dark)
#dashboard-section .ted-activity-poll-header h3 i {
  color:#db2777;
}

/* Vote count badge */
body:not(.house-display-dark)
#dashboard-section .ted-activity-poll-total {
  background:#fce7f3;
  color:#9d174d;
}

/* Voting bars */
body:not(.house-display-dark)
#dashboard-section .ted-activity-poll-track {
  background:#f3e8ef;
}

body:not(.house-display-dark)
#dashboard-section .ted-activity-poll-fill {
  background:#ec4899;
}

/* Dark mode */
body.house-display-dark
#dashboard-section .ted-student-activity-card.ted-activity-poll {
  background:#321d32 !important;
  border:1px solid #831843 !important;
  box-shadow:none !important;
}

body.house-display-dark
#dashboard-section .ted-activity-poll-header h3 i {
  color:#f9a8d4;
}

body.house-display-dark
#dashboard-section .ted-activity-poll-total {
  background:#831843;
  color:#fce7f3;
}

body.house-display-dark
#dashboard-section .ted-activity-poll-track {
  background:#50334d;
}

body.house-display-dark
#dashboard-section .ted-activity-poll-fill {
  background:#f472b6;
}

body.dashboard-student-activity-mode #schoolValuesBar,
body.dashboard-student-activity-mode #dashboardLeaderboardActions,
body.dashboard-student-activity-mode #dashboardStartChallengeBtn,
body.dashboard-student-activity-mode #dashboardAnnouncementAssemblyBtn,
body.dashboard-student-activity-mode #tedWeeklyRecognitionSummary,
body.dashboard-student-activity-mode #dashboard-section .dashboard-house-manage-wrap {
  display:none !important;
}

@media (max-width:780px) {
  .ted-student-activity-grid {
    grid-template-columns:1fr;
  }
}


.dashboard-expand-view-btn {
  min-height:34px;

  padding:
    0
    12px;

  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;

  border:
    1px solid
    #cbd5e1;

  border-radius:999px;

  background:#ffffff;
  color:#475569;

  font-family:inherit;
  font-size:10px;
  font-weight:800;

  white-space:nowrap;

  cursor:pointer;

  transition:
    background .18s ease,
    color .18s ease,
    border-color .18s ease,
    box-shadow .18s ease;
}


.dashboard-expand-view-btn:hover {
  background:#f8fafc;
  color:#2563eb;
  border-color:#93c5fd;
}

/* Compact Expand / Restore icon button */
#dashboardExpandViewBtn {
  position:relative;
  width:36px;
  min-width:36px;
  height:36px;
  min-height:36px;
  padding:0;
  flex:0 0 36px;
  border-radius:12px;
  overflow:visible;
}

#dashboardExpandViewBtn > i {
  font-size:14px;
}

/* Temporary label shown beneath icon after clicking */
.dashboard-expand-flash-label {
  position:absolute;
  top:calc(100% + 7px);
  left:50%;
  transform:translateX(-50%);
  z-index:100;

  width:max-content;
  padding:6px 10px;
  border-radius:8px;

  background:#0f172a;
  color:#ffffff;

  font-size:11px;
  font-weight:700;
  line-height:1.3;
  white-space:nowrap;

  pointer-events:none;

  animation:dashboardExpandLabelFlash 1.5s ease forwards;
}

@keyframes dashboardExpandLabelFlash {
  0%   { opacity:0; }
  12%  { opacity:1; }
  65%  { opacity:1; }
  100% { opacity:0; visibility:hidden; }
}

@media (prefers-reduced-motion:reduce) {
  .dashboard-expand-flash-label {
    animation:none;
    opacity:0;
    visibility:hidden;
  }
}


body.dashboard-sidebar-collapsed
.dashboard-expand-view-btn {
  background:#eff6ff;
  color:#1d4ed8;
  border-color:#93c5fd;

  box-shadow:
    0 2px 6px
    rgba(37,99,235,.12);
}


/* ==========================================
   DASHBOARD DARK MODE - HEADER CONTROLS
   ========================================== */

body.house-display-dark
#teacherOfWeekBtn {
  background:#2a2114 !important;
  border-color:#6b4f1d !important;
  color:#fcd34d !important;
}


body.house-display-dark
#teacherOfWeekBtn i {
  color:#f59e0b !important;
}


body.house-display-dark
#weeklyChangesBtn {
  background:#172337 !important;
  border-color:#27476d !important;
  color:#93c5fd !important;
}


body.house-display-dark
#weeklyChangesBtn i {
  color:#60a5fa !important;
}


body.house-display-dark
#sharePublicHouseBoardBtn {
  background:#211d3b !important;
  border-color:#5146a8 !important;
  color:#c4b5fd !important;
}


body.house-display-dark
#sharePublicHouseBoardBtn i {
  color:#a78bfa !important;
}


body.house-display-dark
.dashboard-expand-view-btn {
  background:#172337 !important;
  border-color:#334155 !important;
  color:#e2e8f0 !important;

  box-shadow:none !important;
}


body.house-display-dark
.dashboard-expand-view-btn:hover {
  background:#1e2d44 !important;
  border-color:#475569 !important;
  color:#ffffff !important;
}


body.house-display-dark.dashboard-sidebar-collapsed
.dashboard-expand-view-btn {
  background:#1e3a5f !important;
  border-color:#3b82f6 !important;
  color:#bfdbfe !important;
}


/* ==========================================
   BEHAVIOUR OVERVIEW
   ========================================== */

.dashboard-behaviour-overview {
  display:flex;
  flex-direction:column;
  padding-top:4px;
}

/* Duplicate summary is no longer displayed */
.dashboard-behaviour-overview
> .dashboard-behaviour-intro {
  display:none !important;
}

/* 1. Incidents and outstanding actions */
.dashboard-behaviour-overview
> .dashboard-behaviour-summary {
  order:1;
  width:100%;
}

/* 2. Students requiring action and recent incidents */
.dashboard-behaviour-overview
> .dashboard-behaviour-grid {
  order:2;
  width:100%;
  margin-bottom:10px;
}

/* 3. School-year points heading */
.dashboard-behaviour-overview
> .dashboard-behaviour-year-heading {
  order:3;
  width:100%;
}

/* 4. School-year points cards */
.dashboard-behaviour-overview
> .dashboard-behaviour-impact {
  order:4;
  width:100%;
  margin-bottom:16px;
}

/* 5. Behaviour records and settings */
.dashboard-behaviour-overview
> .dashboard-behaviour-footer-actions {
  order:5;
  width:100%;
}

/* Keep incident history focused on the incidents */
.dashboard-behaviour-overview
.dashboard-behaviour-activity-followup {
  display:none !important;
}


.dashboard-behaviour-summary {
  display:grid;

  grid-template-columns:
    repeat(
      2,
      minmax(0,1fr)
    );

  gap:12px;

  margin-bottom:16px;
}

.dashboard-behaviour-repeat-notice {
  display:flex;
  align-items:center;
  gap:7px;

  margin-top:12px;
  padding:9px 11px;

  border:1px solid #fed7aa;
  border-radius:9px;

  background:#fff7ed;
  color:#9a3412;

  font-size:12px;
  font-weight:700;
  line-height:1.4;
}

.dashboard-behaviour-repeat-notice i {
  flex:0 0 auto;
  margin-right:0;
  font-size:12px;
}

@media (max-width:600px) {
  .dashboard-behaviour-summary {
    grid-template-columns:1fr;
  }
}


/* School-year Recognition + Needs Work + Behaviour impact */
.dashboard-behaviour-impact {
  display:grid;

  grid-template-columns:
    repeat(
      3,
      minmax(0,1fr)
    );

  gap:10px;

  margin-bottom:12px;
}


.dashboard-behaviour-impact-card {
  min-width:0;

  display:flex;
  align-items:center;
  gap:12px;

  padding:11px 14px;

  border:1px solid #dbe3ec;
  border-radius:12px;

  background:#ffffff;

  box-shadow:
    0 2px 7px
    rgba(15,23,42,.03);
}


.dashboard-behaviour-impact-icon {
  width:34px;
  height:34px;

  flex:0 0 34px;

  display:flex;
  align-items:center;
  justify-content:center;

  border-radius:10px;

  font-size:14px;
}


.dashboard-behaviour-impact-card.positive
.dashboard-behaviour-impact-icon {
  background:#dcfce7;
  color:#16a34a;
}


.dashboard-behaviour-impact-card.needs-work
.dashboard-behaviour-impact-icon {
  background:#ffedd5;
  color:#ea580c;
}


.dashboard-behaviour-impact-card.deduction
.dashboard-behaviour-impact-icon {
  background:#fee2e2;
  color:#dc2626;
}


.dashboard-behaviour-impact-copy {
  min-width:0;
  flex:1;
}


.dashboard-behaviour-impact-label {
  color:#475569;

  font-size:11px;
  font-weight:800;
  line-height:1.25;
}


.dashboard-behaviour-impact-period {
  margin-top:2px;

  color:#94a3b8;

  font-size:9px;
  font-weight:700;
}


.dashboard-behaviour-impact-value {
  flex:0 0 auto;

  color:#0f172a;

  font-size:21px;
  font-weight:900;
  line-height:1;
}


.dashboard-behaviour-impact-card.positive
.dashboard-behaviour-impact-value {
  color:#15803d;
}


.dashboard-behaviour-impact-card.needs-work
.dashboard-behaviour-impact-value {
  color:#ea580c;
}


.dashboard-behaviour-impact-card.deduction
.dashboard-behaviour-impact-value {
  color:#dc2626;
}


body.house-display-dark
.dashboard-behaviour-impact-card {
  background:#0f172a;
  border-color:#334155;
}


body.house-display-dark
.dashboard-behaviour-impact-label {
  color:#cbd5e1;
}


body.house-display-dark
.dashboard-behaviour-impact-value {
  color:#f8fafc;
}


.dashboard-behaviour-stat {
  min-width:0;

  padding:14px 16px;

  border:1px solid #dbe3ec;
  border-radius:12px;

  background:#ffffff;

  box-shadow:
    0 2px 7px
    rgba(15,23,42,.04);
}


.dashboard-behaviour-stat-top {
  display:flex;
  align-items:center;
  gap:9px;

  margin-bottom:8px;
}


.dashboard-behaviour-stat-icon {
  width:32px;
  height:32px;

  flex:0 0 32px;

  display:flex;
  align-items:center;
  justify-content:center;

  border-radius:9px;

  background:#ede9fe;
  color:#7c3aed;

  font-size:14px;
}


.dashboard-behaviour-stat-label {
  color:#475569;

  font-size:13px;
  font-weight:800;
  line-height:1.3;
}


.dashboard-behaviour-stat-value {
  color:#0f172a;

  font-size:32px;
  font-weight:900;
  line-height:1;
}


.dashboard-behaviour-stat-detail {
  margin-top:7px;

  color:#64748b;

  font-size:10px;
  font-weight:700;
}

/* ==========================================
   BEHAVIOUR - COMPACT CLICKABLE SUMMARY
   ========================================== */

.dashboard-behaviour-summary
.dashboard-behaviour-stat {
  position:relative;

  min-height:100px;
  padding:12px 74px 12px 14px;

  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  gap:0;
}

.dashboard-behaviour-summary
.dashboard-behaviour-stat-top {
  display:flex;
  align-items:center;
  gap:9px;

  min-height:32px;
  margin-bottom:0;
}

.dashboard-behaviour-summary
.dashboard-behaviour-stat-label {
  font-size:13px;
  font-weight:800;
  line-height:1.3;
}

.dashboard-behaviour-summary
.dashboard-behaviour-stat-value {
  position:absolute;
  top:13px;
  right:16px;

  margin:0;
  font-size:30px;
  line-height:1;
  text-align:right;
}

.dashboard-behaviour-summary
.dashboard-behaviour-stat-detail {
  margin-top:9px;
  font-size:11px;
  line-height:1.4;
}

/* Repeat incidents - compact supporting text */
.dashboard-behaviour-summary
.dashboard-behaviour-repeat-notice {
  display:flex;
  align-items:center;
  gap:6px;

  margin-top:5px;
  padding:0;

  border:0;
  border-radius:0;
  background:transparent;

  color:#9a3412;
  font-size:11px;
  font-weight:700;
  line-height:1.4;
}

.dashboard-behaviour-summary
.dashboard-behaviour-repeat-notice i {
  margin:0;
  font-size:11px;
}

/* Interactive states */
.dashboard-behaviour-stat-link {
  cursor:pointer;

  transition:
    border-color .16s ease,
    background .16s ease,
    box-shadow .16s ease;
}

.dashboard-behaviour-stat-link:hover {
  border-color:#a78bfa;
  background:#faf9ff;
  box-shadow:0 3px 12px rgba(124,58,237,.08);
}

.dashboard-behaviour-stat-link:focus-visible {
  outline:3px solid #a78bfa;
  outline-offset:3px;
}

.dashboard-behaviour-stat-link:active {
  transform:translateY(1px);
}

/* Maintain readable spacing on smaller screens */
@media (max-width:600px) {
  .dashboard-behaviour-summary
  .dashboard-behaviour-stat {
    min-height:98px;
    padding-right:62px;
  }

  .dashboard-behaviour-summary
  .dashboard-behaviour-stat-value {
    right:12px;
    font-size:27px;
  }

  .dashboard-behaviour-summary
  .dashboard-behaviour-stat-label {
    font-size:12px;
  }
}


body.house-display-dark
.dashboard-behaviour-stat-detail {
  color:#94a3b8 !important;
}

.dashboard-behaviour-activity-followup {
  margin-top:3px !important;

  color:#7c3aed !important;

  font-size:9px !important;
  font-weight:800 !important;
}


body.house-display-dark
.dashboard-behaviour-activity-followup {
  color:#c4b5fd !important;
}

.dashboard-behaviour-grid {
  display:grid;

  grid-template-columns:
    minmax(0,1.55fr)
    minmax(320px,.75fr);

  gap:14px;

  align-items:stretch;
}

.dashboard-behaviour-grid > .dashboard-behaviour-panel {
  height:100%;
  align-self:stretch;
}

.dashboard-behaviour-grid > .dashboard-behaviour-side {
  height:100%;
  display:flex;
  flex-direction:column;
}

.dashboard-behaviour-grid > .dashboard-behaviour-side
.dashboard-behaviour-panel {
  flex:1 1 auto;
}

.dashboard-behaviour-grid > .dashboard-behaviour-side
.dashboard-behaviour-context {
  flex:0 0 auto;
}


.dashboard-behaviour-panel {
  min-width:0;

  padding:16px;

  border:1px solid #dbe3ec;
  border-radius:14px;

  background:#ffffff;

  box-shadow:
    0 2px 7px
    rgba(15,23,42,.035);
}

.dashboard-behaviour-panel.dashboard-behaviour-no-followup {
  padding:13px 16px;
}

.dashboard-behaviour-no-followup
.dashboard-behaviour-panel-header {
  margin-bottom:3px;
}

.dashboard-behaviour-no-followup
.dashboard-behaviour-student-list {
  display:block;
}

.dashboard-behaviour-no-followup
.dashboard-behaviour-student-list > div {
  padding:7px 0 !important;
  text-align:left !important;
  font-size:12px !important;
  color:#64748b !important;
}


#dashboardBehaviourFilters
.dashboard-behaviour-advanced-filter {
  display:none !important;
}


#dashboardBehaviourFilters.advanced-open
.dashboard-behaviour-advanced-filter {
  display:inline-block !important;
}


/* ==========================================
   CLEAN BEHAVIOUR DASHBOARD TOOLBAR
   ========================================== */

.card-header:has(#dashboardBehaviourFilters) {
  grid-template-columns:
    minmax(0,1fr)
    auto !important;

  align-items:start !important;
  column-gap:16px !important;
  row-gap:10px !important;
}

.card-header:has(#dashboardBehaviourFilters)
> div:first-child {
  min-width:0 !important;
  display:flex !important;
  flex-wrap:wrap !important;
  align-items:center !important;
  align-content:start !important;
  gap:12px !important;
}

.card-header:has(#dashboardBehaviourFilters)
#dashboardOverviewTitle {
  flex:0 0 auto;
  width:auto;
  margin:0 8px 0 0 !important;
  white-space:nowrap;
  font-size:17px;
  line-height:1.3;
}

.card-header:has(#dashboardBehaviourFilters)
#dashboardBehaviourFilters {
  width:100%;
  min-width:0;
  justify-content:flex-start !important;
  gap:8px !important;
}

#dashboardBehaviourTimeFilter {
  order:1;
}

#dashboardBehaviourClassFilter {
  order:2;
}

#dashboardBehaviourMoreFiltersBtn {
  order:3;
  min-height:38px;
  height:38px !important;
  border-radius:10px !important;
}

#dashboardBehaviourCategoryFilter {
  order:4;
}

#dashboardBehaviourTierFilter {
  order:5;
}

#dashboardBehaviourFilters.advanced-open
.dashboard-behaviour-advanced-filter {
  min-height:38px;
  height:38px !important;
  font-size:12px !important;
  border-radius:10px !important;
}

/* ==========================================
   BEHAVIOUR FILTERS - SINGLE SAAS TOOLBAR
   ========================================== */

.card-header:has(#dashboardBehaviourFilters)
> div:first-child {
  min-width:0 !important;
  width:100% !important;
}

.card-header:has(#dashboardBehaviourFilters)
#dashboardBehaviourFilters {
  display:flex;
  flex-wrap:nowrap !important;
  align-items:center !important;
  justify-content:flex-start !important;

  width:100% !important;
  max-width:100% !important;
  min-width:0 !important;

  gap:8px !important;

  overflow-x:auto;
  overflow-y:hidden;

  scrollbar-width:thin;
  padding:2px 0 5px;
}

#dashboardBehaviourFilters::before,
#dashboardBehaviourFilters::after {
  content:none !important;
  display:none !important;
}

#dashboardBehaviourFilters > select,
#dashboardBehaviourFilters > button {
  box-sizing:border-box !important;

  height:38px !important;
  min-height:38px !important;

  margin:0 !important;

  border-radius:10px !important;

  font-family:inherit !important;
  font-size:12px !important;
  font-weight:700 !important;

  white-space:nowrap !important;
  flex-shrink:0 !important;
}

#dashboardBehaviourTimeFilter {
  order:1;
  width:135px !important;
  min-width:135px !important;
}

#dashboardBehaviourClassFilter {
  order:2;
  width:190px !important;
  min-width:190px !important;
}

#dashboardBehaviourMoreFiltersBtn {
  order:3;
  width:133px !important;
  min-width:133px !important;

  justify-content:center !important;

  padding:0 10px !important;
}

#dashboardBehaviourCategoryFilter {
  order:4;
  width:128px !important;
  min-width:128px !important;
}

#dashboardBehaviourTierFilter {
  order:5;
  width:112px !important;
  min-width:112px !important;
}

#dashboardBehaviourFilters
.dashboard-behaviour-advanced-filter {
  display:none !important;
}

#dashboardBehaviourFilters.advanced-open
.dashboard-behaviour-advanced-filter {
  display:block !important;
}

/* Wider screens: comfortable proportions */
@media (min-width:1500px) {
  #dashboardBehaviourTimeFilter {
    width:150px !important;
  }

  #dashboardBehaviourClassFilter {
    width:210px !important;
  }

  #dashboardBehaviourMoreFiltersBtn {
    width:140px !important;
  }

  #dashboardBehaviourCategoryFilter {
    width:140px !important;
  }

  #dashboardBehaviourTierFilter {
    width:120px !important;
  }
}

.card-header:has(#dashboardBehaviourFilters)
> div:last-child {
  align-self:start;
  min-width:0;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.card-header:has(#dashboardBehaviourFilters)
.dashboard-overview-switch {
  flex-shrink:0;
}

@media (max-width:1100px) {
  .card-header:has(#dashboardBehaviourFilters) {
    grid-template-columns:minmax(0,1fr) !important;
  }

  .card-header:has(#dashboardBehaviourFilters)
  > div:last-child {
    justify-self:start !important;
    justify-content:flex-start !important;
  }
}


.dashboard-behaviour-panel-header {

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;

  margin-bottom:13px;
}


.dashboard-behaviour-panel-header strong {
  color:#0f172a;

  font-size:16px;
  font-weight:900;
  line-height:1.25;
}


.dashboard-behaviour-panel-header strong i {
  margin-right:5px;
}


.dashboard-behaviour-panel-header span {
  color:#64748b;

  font-size:10px;
  font-weight:750;
}


.dashboard-behaviour-student-list {
  display:grid;

  grid-template-columns:
    repeat(
      2,
      minmax(0,1fr)
    );

  gap:10px;
}


@media (min-width:781px) and (max-width:1100px) {

  /* ==========================================
     BEHAVIOUR DASHBOARD - IPAD / TABLET
     ========================================== */


  /* ------------------------------------------
     STUDENTS NEEDING ATTENTION
     Show 3 visible cards on iPad
     and let the rest scroll horizontally
     ------------------------------------------ */

  .dashboard-behaviour-student-list {
    display:flex !important;

    align-items:flex-start !important;

    gap:10px !important;

    width:100% !important;
    min-width:0 !important;

    overflow-x:auto !important;
    overflow-y:hidden !important;

    padding:
      0 0 8px 0 !important;

    scroll-snap-type:
      x mandatory;

    scroll-behavior:
      smooth;

    overscroll-behavior-x:
      contain;

    -webkit-overflow-scrolling:
      touch;

    scrollbar-width:
      thin;
  }


  .dashboard-behaviour-student-list
  > .dashboard-behaviour-student {
    flex:
      0 0
      calc(
        (
          100% - 20px
        ) / 3
      ) !important;

    width:
      calc(
        (
          100% - 20px
        ) / 3
      ) !important;

    min-width:0 !important;

    height:auto !important;
    min-height:0 !important;

    align-self:flex-start !important;

    scroll-snap-align:start;
  }


  /* ------------------------------------------
     RECENT ACTIVITY
     3 columns visible × 2 rows
     Horizontal paging through more activity
     ------------------------------------------ */

  .dashboard-behaviour-activity-list {
    display:grid !important;

    grid-template-rows:
      repeat(
        2,
        minmax(0,auto)
      ) !important;

    grid-auto-flow:
      column !important;

    grid-auto-columns:
      calc(
        (
          100% - 20px
        ) / 3
      ) !important;

    column-gap:
      10px !important;

    row-gap:
      10px !important;

    width:
      100% !important;

    max-height:
      none !important;

    overflow-x:
      auto !important;

    overflow-y:
      hidden !important;

    padding:
      0 0 8px 0 !important;

    scroll-snap-type:
      x mandatory;

    scroll-behavior:
      smooth;

    overscroll-behavior-x:
      contain;

    -webkit-overflow-scrolling:
      touch;

    scrollbar-width:
      thin;
  }


  /*
   * Each set of six begins a new horizontal
   * snap position:
   *
   * 1  3  5     → swipe →
   * 2  4  6
   *
   * 7  9  11
   * 8  10 12
   */
  .dashboard-behaviour-activity-item:nth-child(6n + 1) {
    scroll-snap-align:
      start;
  }


  .dashboard-behaviour-student {
    gap:7px !important;

    padding:11px !important;

    border-radius:11px !important;

    height:auto !important;
    min-height:150px !important;

    justify-content:flex-start !important;
  }


  .dashboard-behaviour-view-student {
    margin-top:8px !important;
  }


  .dashboard-behaviour-student-name strong {
    font-size:12px !important;
  }


  .dashboard-behaviour-student-name span {
    margin-top:2px !important;

    font-size:9px !important;
  }


  .dashboard-behaviour-tier {
    min-width:68px !important;

    padding:5px 9px !important;

    font-size:8px !important;
  }


  .dashboard-behaviour-latest {
    font-size:9px !important;
  }


  .dashboard-behaviour-actions {
    gap:4px !important;

    min-height:0 !important;
  }


  .dashboard-behaviour-action-badge,
  .dashboard-behaviour-recognition-badge {
    padding:4px 6px !important;

    font-size:8px !important;
  }


  .dashboard-behaviour-view-student {
    min-height:30px !important;

    padding:6px 8px !important;

    font-size:9px !important;
  }


  .dashboard-behaviour-activity-item {
    width:100% !important;
    min-width:0 !important;

    height:auto !important;
    min-height:96px !important;

    align-self:stretch !important;

    gap:8px !important;

    padding:10px !important;

    border-radius:10px !important;

    box-sizing:border-box !important;
  }


  .dashboard-behaviour-activity-icon {
    width:28px !important;
    height:28px !important;

    flex:0 0 28px !important;

    font-size:10px !important;
  }


  .dashboard-behaviour-activity-copy strong {
    font-size:10px !important;
  }


  .dashboard-behaviour-activity-meta {
    gap:5px !important;

    margin-top:4px !important;
  }


  .dashboard-behaviour-activity-severity {
    padding:3px 6px !important;

    font-size:8px !important;
  }


  .dashboard-behaviour-activity-time {
    font-size:9px !important;
  }


  .dashboard-behaviour-activity-followup {
    margin-top:5px !important;

    font-size:8px !important;

    line-height:1.35 !important;
  }

}


.dashboard-behaviour-student {
  min-width:0;

  display:flex;
  flex-direction:column;
  align-items:stretch;

  gap:10px;

  padding:14px;

  border:1px solid #e2e8f0;
  border-radius:12px;

  background:#f8fafc;

  transition:
    background .16s ease,
    border-color .16s ease,
    transform .16s ease;
}


.dashboard-behaviour-student-card-top {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:8px;
}


.dashboard-behaviour-latest {
  color:#64748b;

  font-size:10px;
  font-weight:650;
  line-height:1.4;
}


.dashboard-behaviour-latest i {
  margin-right:4px;
  color:#94a3b8;
}


.dashboard-behaviour-latest strong {
  color:#334155;
  font-weight:850;
}


.dashboard-behaviour-actions {
  display:flex;
  align-items:flex-start;
  gap:6px;
  flex-wrap:wrap;

  min-height:25px;
}


.dashboard-behaviour-action-badge,
.dashboard-behaviour-recognition-badge {
  display:inline-flex;
  align-items:center;
  gap:5px;

  padding:5px 8px;

  border-radius:999px;

  font-size:9px;
  font-weight:850;
  line-height:1.2;
}


.dashboard-behaviour-action-badge.parent {
  background:#fff7ed;
  border:1px solid #fed7aa;
  color:#c2410c;
}


.dashboard-behaviour-action-badge.reflection {
  background:#f5f3ff;
  border:1px solid #ddd6fe;
  color:#6d28d9;
}


.dashboard-behaviour-recognition-badge.paused {
  background:#fef2f2;
  border:1px solid #fecaca;
  color:#b91c1c;
}


.dashboard-behaviour-recognition-badge.limited {
  background:#fffbeb;
  border:1px solid #fde68a;
  color:#92400e;
}


.dashboard-behaviour-view-student {
  width:100%;

  margin-top:auto;
  padding:8px 10px;

  display:flex;
  align-items:center;
  justify-content:center;
  gap:6px;

  border:1px solid #ddd6fe;
  border-radius:9px;

  background:#ffffff;
  color:#6d28d9;

  font-family:inherit;
  font-size:10px;
  font-weight:850;

  cursor:pointer;
}


.dashboard-behaviour-view-student:hover {
  background:#7c3aed;
  border-color:#7c3aed;
  color:#ffffff;
}


.dashboard-behaviour-student {
  min-width:0;

  display:flex;
  flex-direction:column;
  align-items:stretch;

  gap:10px;

  padding:14px;

  border:1px solid #e2e8f0;
  border-radius:12px;

  background:#f8fafc;

  transition:
    background .16s ease,
    border-color .16s ease,
    transform .16s ease;
}


.dashboard-behaviour-student:hover {
  background:#ffffff;
  border-color:#c4b5fd;
  transform:translateY(-1px);
}


.dashboard-behaviour-student-name {
  min-width:0;
}


.dashboard-behaviour-student-name strong {
  display:block;

  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;

  color:#0f172a;

  font-size:14px;
  font-weight:900;
  line-height:1.25;
}


.dashboard-behaviour-student-name span {
  display:block;

  margin-top:4px;

  color:#64748b;

  font-size:11px;
  font-weight:650;
}


.dashboard-behaviour-tier {
  display:inline-flex;
  align-items:center;
  justify-content:center;

  min-width:92px;

  padding:7px 14px;

  border-radius:999px;
  border:1px solid transparent;

  font-size:10px;
  font-weight:850;
  line-height:1;

  white-space:nowrap;
}

.dashboard-behaviour-tier.pre-tier-1 {
  background:#e8f0fe;
  border-color:#bfdbfe;
  color:#1d4ed8;
}

.dashboard-behaviour-tier.tier-1 {
  background:#ecfdf3;
  border-color:#bbf7d0;
  color:#15803d;
}

.dashboard-behaviour-tier.tier-2 {
  background:#fff7ed;
  border-color:#fcd34d;
  color:#b45309;
}

.dashboard-behaviour-tier.tier-3 {
  background:#fef2f2;
  border-color:#fecaca;
  color:#b91c1c;
}


.dashboard-behaviour-followup {
  padding:5px 9px;

  border-radius:999px;

  background:#ffedd5;
  color:#9a3412;

  border:1px solid #fed7aa;

  font-size:10px;
  font-weight:850;

  white-space:nowrap;
}


.dashboard-behaviour-side {
  display:flex;
  flex-direction:column;
  gap:12px;
}


.dashboard-behaviour-activity-list {
  display:flex;
  flex-direction:column;
  gap:8px;

  max-height:430px;
  overflow-y:auto;

  padding-right:4px;
}


.dashboard-behaviour-activity-item {
  display:flex;
  align-items:flex-start;
  gap:11px;

  padding:12px;

  border:1px solid #e2e8f0;
  border-radius:12px;

  background:#f8fafc;

  cursor:pointer;

  transition:
    background .16s ease,
    border-color .16s ease,
    transform .16s ease,
    box-shadow .16s ease;
}

.dashboard-behaviour-activity-item:hover {
  background:#ffffff;
  border-color:#cbd5e1;
  transform:translateY(-1px);
  box-shadow:0 4px 14px rgba(15,23,42,.06);
}


.dashboard-behaviour-activity-icon {
  width:36px;
  height:36px;

  flex:0 0 36px;

  display:flex;
  align-items:center;
  justify-content:center;

  border-radius:10px;

  font-size:13px;
}

.dashboard-behaviour-activity-icon.low {
  background:#eff6ff;
  color:#2563eb;
}

.dashboard-behaviour-activity-icon.medium {
  background:#fff7ed;
  color:#d97706;
}

.dashboard-behaviour-activity-icon.high {
  background:#fef2f2;
  color:#dc2626;
}


.dashboard-behaviour-activity-copy {
  min-width:0;
  flex:1;
}


.dashboard-behaviour-activity-copy strong {
  display:block !important;

  color:#0f172a !important;

  font-size:13px !important;
  font-weight:900 !important;
  line-height:1.25 !important;
}

.dashboard-behaviour-activity-meta {
  display:flex;
  align-items:center;
  gap:7px;
  flex-wrap:wrap;

  margin-top:5px;
}

.dashboard-behaviour-activity-severity {
  display:inline-flex;
  align-items:center;

  padding:4px 8px;

  border-radius:999px;
  border:1px solid transparent;

  font-size:10px;
  font-weight:850;
  line-height:1;
}

.dashboard-behaviour-activity-severity.low {
  background:#eff6ff;
  border-color:#bfdbfe;
  color:#1d4ed8;
}

.dashboard-behaviour-activity-severity.medium {
  background:#fff7ed;
  border-color:#fed7aa;
  color:#b45309;
}

.dashboard-behaviour-activity-severity.high {
  background:#fef2f2;
  border-color:#fecaca;
  color:#b91c1c;
}

.dashboard-behaviour-activity-time {
  color:#64748b;

  font-size:11px;
  font-weight:700;
  line-height:1.35;
}

.dashboard-behaviour-activity-followup {
  display:flex !important;
  align-items:flex-start;
  gap:7px;

  margin-top:7px !important;

  color:#7c3aed !important;

  font-size:10px !important;
  font-weight:800 !important;
  line-height:1.45 !important;
}

.dashboard-behaviour-activity-followup i {
  margin-top:1px;
}

.dashboard-behaviour-activity-arrow {
  flex:0 0 auto;

  color:#94a3b8;

  font-size:12px;

  padding-top:2px;
}


.dashboard-behaviour-context {
  display:flex;
  align-items:center;
  justify-content:center;
  gap:20px;
  flex-wrap:wrap;

  padding:12px 14px;

  border:1px solid #dbe3ec;
  border-radius:11px;

  background:#ffffff;

  color:#475569;

  font-size:11px !important;
  font-weight:750 !important;
}


.dashboard-behaviour-context span {
  font-size:11px !important;
  color:#475569 !important;
}


.dashboard-behaviour-context strong {
  color:#0f172a !important;

  font-size:14px !important;
  font-weight:900 !important;
}


.dashboard-behaviour-activity-list {
  display:flex;
  flex-direction:column;
  gap:7px;
}


.dashboard-behaviour-activity-item {
  display:flex;
  align-items:flex-start;
  gap:9px;

  padding:9px 10px;

  border:1px solid #eef2f7;
  border-radius:10px;

  background:#f8fafc;
}


.dashboard-behaviour-activity-icon {
  width:28px;
  height:28px;

  flex:0 0 28px;

  display:flex;
  align-items:center;
  justify-content:center;

  border-radius:8px;

  background:#f5f3ff;
  color:#7c3aed;

  font-size:11px;
}


.dashboard-behaviour-activity-copy {
  min-width:0;
  flex:1;
}


.dashboard-behaviour-activity-copy strong {
  display:block;

  color:#0f172a;

  font-size:10px;
  font-weight:850;
  line-height:1.3;
}


.dashboard-behaviour-activity-copy span {
  display:block;

  margin-top:2px;

  color:#64748b;

  font-size:9px;
  font-weight:650;
  line-height:1.35;
}


.dashboard-behaviour-context {
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  flex-wrap:wrap;

  padding:10px 12px;

  border:1px solid #e2e8f0;
  border-radius:10px;

  background:#f8fafc;

  color:#475569;

  font-size:9px;
  font-weight:750;
}


.dashboard-behaviour-context strong {
  color:#0f172a;
  font-size:11px;
  font-weight:900;
}


.dashboard-behaviour-severity-row {
  display:grid;

  grid-template-columns:
    58px
    1fr
    24px;

  align-items:center;
  gap:8px;

  margin-bottom:8px;

  color:#475569;

  font-size:10px;
  font-weight:700;
}


.dashboard-behaviour-bar {
  height:7px;

  overflow:hidden;

  border-radius:999px;

  background:#e2e8f0;
}


.dashboard-behaviour-bar > span {
  display:block;

  height:100%;

  border-radius:999px;

  background:#7c3aed;
}


.dashboard-behaviour-trend {
  height:82px;

  display:flex;
  align-items:flex-end;
  gap:5px;

  margin-top:10px;
}


.dashboard-behaviour-trend-day {
  flex:1;

  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-end;
  gap:4px;

  height:100%;
}


.dashboard-behaviour-trend-bar {
  width:100%;
  max-width:22px;

  min-height:3px;

  border-radius:
    5px
    5px
    2px
    2px;

  background:#7c3aed;
}


.dashboard-behaviour-trend-day small {
  color:#94a3b8;

  font-size:8px;
  font-weight:700;
}


/* ==========================================
   INCIDENTS & SUPPORT - PREMIUM COLOUR REFINEMENT
   ========================================== */

/* Incident summary: soft red */
body:not(.house-display-dark)
.dashboard-behaviour-summary
.dashboard-behaviour-stat:first-child {
  background:#fff7f7;
  border-color:#fecaca;
}

body:not(.house-display-dark)
.dashboard-behaviour-summary
.dashboard-behaviour-stat:first-child
.dashboard-behaviour-stat-icon {
  background:#fee2e2;
  color:#dc2626;
}

/* Follow-up summary: soft amber */
body:not(.house-display-dark)
.dashboard-behaviour-summary
.dashboard-behaviour-stat:nth-child(2) {
  background:#fffbeb;
  border-color:#fde68a;
}

body:not(.house-display-dark)
.dashboard-behaviour-summary
.dashboard-behaviour-stat:nth-child(2)
.dashboard-behaviour-stat-icon {
  background:#fef3c7;
  color:#d97706;
}

/* Keep hover and keyboard focus accessible */
body:not(.house-display-dark)
.dashboard-behaviour-summary
.dashboard-behaviour-stat-link:hover {
  filter:brightness(0.985);
  box-shadow:0 4px 14px rgba(15,23,42,.09);
}

/* Points Activity: subtle category backgrounds */
body:not(.house-display-dark)
.dashboard-behaviour-impact-card.positive {
  background:#f0fdf4;
  border-color:#bbf7d0;
}

body:not(.house-display-dark)
.dashboard-behaviour-impact-card.needs-work {
  background:#fff7ed;
  border-color:#fed7aa;
}

body:not(.house-display-dark)
.dashboard-behaviour-impact-card.deduction {
  background:#fef2f2;
  border-color:#fecaca;
}

/* Preserve a neutral layout for student follow-up panels */
body:not(.house-display-dark)
.dashboard-behaviour-panel {
  background:#ffffff;
  border-color:#dbe3ec;
}

/* Main action: strong TrackEDU purple */
.dashboard-behaviour-footer-actions
.dashboard-behaviour-open {
  background:#7c3aed;
  border-color:#7c3aed;
  color:#ffffff;
  font-size:12px;
  font-weight:850;
  box-shadow:0 3px 9px rgba(124,58,237,.15);
}

.dashboard-behaviour-footer-actions
.dashboard-behaviour-open:hover {
  background:#6d28d9;
  border-color:#6d28d9;
  color:#ffffff;
  box-shadow:0 5px 14px rgba(124,58,237,.22);
}

/* Secondary settings action remains neutral */
body:not(.house-display-dark)
.dashboard-behaviour-footer-actions
.dashboard-behaviour-settings {
  background:#ffffff;
  border-color:#cbd5e1;
  color:#475569;
}

body:not(.house-display-dark)
.dashboard-behaviour-footer-actions
.dashboard-behaviour-settings:hover {
  background:#f8fafc;
  border-color:#94a3b8;
  color:#334155;
}

/* Dark mode: preserve dark surfaces and purple action */
body.house-display-dark
.dashboard-behaviour-footer-actions
.dashboard-behaviour-open {
  background:#7c3aed !important;
  border-color:#7c3aed !important;
  color:#ffffff !important;
}

body.house-display-dark
.dashboard-behaviour-footer-actions
.dashboard-behaviour-open:hover {
  background:#6d28d9 !important;
  border-color:#6d28d9 !important;
}

.dashboard-behaviour-footer-actions {
  display:grid;
  grid-template-columns:1fr !important;
  gap:10px;

  width:100%;
  margin-top:14px;
}

/* ==========================================
   INCIDENTS TOOLBAR
   Filters left, View All Incidents right
   ========================================== */

#dashboard-section .ted-incidents-toolbar {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  width:100%;
  margin-bottom:16px;
  flex-wrap:wrap;
}

/* Only show the Incidents toolbar in Incidents mode */
body:not(.dashboard-behaviour-mode)
#dashboard-section .ted-incidents-toolbar {
  display:none !important;
}

/* Filters stay on the left */
#dashboard-section .ted-incidents-toolbar
#dashboardBehaviourFilters {
  display:flex;
  align-items:center;
  justify-content:flex-start !important;
  flex:1 1 auto;
  width:auto !important;
  min-width:0;
  gap:8px;
  flex-wrap:wrap;
}

/* View All Incidents stays on the far right */
#dashboard-section .ted-incidents-toolbar
.ted-incidents-open-right {
  display:inline-flex !important;
  align-items:center;
  justify-content:center;
  gap:8px;
  flex:0 0 auto;

  width:auto !important;
  min-height:38px;
  margin:0 0 0 auto !important;
  padding:8px 14px;

  border:1px solid #ddd6fe;
  border-radius:10px;
  background:#f5f3ff;
  color:#6d28d9;

  font-family:inherit;
  font-size:12px;
  font-weight:800;
  white-space:nowrap;
  cursor:pointer;
}

#dashboard-section .ted-incidents-toolbar
.ted-incidents-open-right:hover {
  background:#ede9fe;
  border-color:#c4b5fd;
}

#dashboard-section .ted-incidents-toolbar
.ted-incidents-open-right:focus-visible {
  outline:3px solid #a78bfa;
  outline-offset:2px;
}

/* Tablet and mobile */
@media (max-width:1100px) {
  #dashboard-section .ted-incidents-toolbar
  .ted-incidents-open-right {
    margin-left:auto !important;
  }
}


.dashboard-behaviour-open {
  width:100%;

  margin:0;
  padding:11px 14px;

  border:1px solid #a78bfa;
  border-radius:10px;

  background:#f5f3ff;
  color:#6d28d9;

  font-family:inherit;
  font-size:12px;
  font-weight:850;

  cursor:pointer;

  transition:
    background .16s ease,
    color .16s ease;
}


.dashboard-behaviour-open:hover {
  background:#7c3aed;
  color:#ffffff;
}


.dashboard-behaviour-settings {
  width:100%;

  margin:0;
  padding:11px 14px;

  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;

  border:1px solid #cbd5e1;
  border-radius:10px;

  background:#ffffff;
  color:#475569;

  font-family:inherit;
  font-size:11px;
  font-weight:850;

  cursor:pointer;

  transition:
    border-color .16s ease,
    background .16s ease,
    color .16s ease;
}


.dashboard-behaviour-settings:hover {
  border-color:#a78bfa;
  background:#faf5ff;
  color:#6d28d9;
}


/* ==========================================
   BEHAVIOUR OVERVIEW - PREMIUM REFINEMENT
   ========================================== */

/* Keep the normal dashboard background */
body.dashboard-behaviour-mode
#dashboard-section
.card:has(#dashboardBehaviourOverview) {
  border-top: 2px solid #ddd6fe;
}

/* Tighter spacing between sections */
body.dashboard-behaviour-mode
#dashboardBehaviourOverview
.dashboard-behaviour-summary {
  margin-bottom: 12px;
}

body.dashboard-behaviour-mode
#dashboardBehaviourOverview
.dashboard-behaviour-year-heading {
  margin: 12px 0 10px !important;
}

body.dashboard-behaviour-mode
#dashboardBehaviourOverview
.dashboard-behaviour-impact {
  margin-bottom: 12px;
}

body.dashboard-behaviour-mode
#dashboardBehaviourOverview
.dashboard-behaviour-grid {
  margin-bottom: 8px;
}

body.dashboard-behaviour-mode
#dashboardBehaviourOverview
.dashboard-behaviour-side {
  gap: 8px;
}

/* Compact empty incidents panel */
#dashboardBehaviourOverview
.dashboard-behaviour-panel:has(.dashboard-behaviour-empty-activity) {
  padding: 12px 16px;
}

/* Dark mode compatibility */
body.house-display-dark.dashboard-behaviour-mode
#dashboard-section
.card:has(#dashboardBehaviourOverview) {
  border-top-color: #6d28d9;
}

body.house-display-dark
.dashboard-behaviour-empty-activity {
  color: #cbd5e1 !important;
}

/* ==========================================
   DARK MODE - HEADER MENU BUTTON
   ========================================== */

body.house-display-dark
.header-actions .desktop-smart-menu-button {
  background:#172337 !important;
  color:#f8fafc !important;
  border-color:#334155 !important;
  box-shadow:none !important;
}

body.house-display-dark
.header-actions .desktop-smart-menu-button:hover {
  background:#263449 !important;
  border-color:#475569 !important;
}

body.house-display-dark
.header-actions .desktop-smart-menu-button i,
body.house-display-dark
.header-actions .desktop-smart-menu-button .btn-text {
  color:#f8fafc !important;
}

/* ==========================================
   DARK MODE - MENU PANEL
   Desktop, iPad and mobile
   ========================================== */

body.house-display-dark
#smartMenuDrawer {
  background:#111827 !important;
  border-color:#334155 !important;
  color:#f8fafc !important;
}

body.house-display-dark
.smart-menu-header {
  background:#111827 !important;
  border-bottom-color:#334155 !important;
}

body.house-display-dark
.smart-menu-header button {
  background:#1e293b !important;
  color:#e2e8f0 !important;
  border-color:#475569 !important;
}

body.house-display-dark
.smart-menu-header button:hover {
  background:#334155 !important;
  color:#ffffff !important;
}

body.house-display-dark
.smart-menu-header > div:first-child > div > div span {
  color:#94a3b8 !important;
}

body.house-display-dark
.smart-menu-grid {
  background:#111827 !important;
}

body.house-display-dark
.smart-menu-grid .smart-menu-item {
  background:transparent !important;
  color:#e2e8f0 !important;
}

body.house-display-dark
.smart-menu-grid .smart-menu-item:hover {
  background:#1e293b !important;
}

body.house-display-dark
.smart-menu-grid .smart-menu-item span {
  color:#e2e8f0 !important;
}

body.house-display-dark
.smart-menu-grid .smart-menu-item .icon-box {
  box-shadow:none !important;
}

/* Footer and account information */

body.house-display-dark
.smart-menu-profile-footer {
  background:#111827 !important;
  border-top-color:#334155 !important;
  color:#e2e8f0 !important;
}

body.house-display-dark
#smartMenuUserName {
  color:#f8fafc !important;
}

body.house-display-dark
#smartMenuLicenseContainer {
  color:#cbd5e1 !important;
}

/* Keep destructive Logout clearly identifiable */

body.house-display-dark
.smart-menu-desktop-logout span {
  color:#fca5a5 !important;
}

body.house-display-dark
.smart-menu-desktop-logout:hover {
  background:#451a24 !important;
}

/* ==========================================
   BEHAVIOUR DASHBOARD - DARK MODE
   ========================================== */

body.house-display-dark
.dashboard-behaviour-stat,
body.house-display-dark
.dashboard-behaviour-panel,
body.house-display-dark
.dashboard-behaviour-context {
  background:#111c2e !important;

  border-color:
    rgba(148,163,184,0.18) !important;

  box-shadow:
    0 4px 14px
    rgba(0,0,0,0.18) !important;
}


/* Top summary cards */

body.house-display-dark
.dashboard-behaviour-stat-label {
  color:#cbd5e1 !important;
}


body.house-display-dark
.dashboard-behaviour-stat-value {
  color:#f8fafc !important;
}


body.house-display-dark
.dashboard-behaviour-stat-icon {
  background:
    rgba(124,58,237,0.18) !important;

  color:#c4b5fd !important;

  border:
    1px solid
    rgba(167,139,250,0.18);
}


/* Panel headings */

body.house-display-dark
.dashboard-behaviour-panel-header strong {
  color:#f8fafc !important;
}


body.house-display-dark
.dashboard-behaviour-panel-header span {
  color:#94a3b8 !important;
}


/* Student follow-up rows */

body.house-display-dark
.dashboard-behaviour-student {
  background:#172337 !important;

  border-color:
    rgba(148,163,184,0.16) !important;
}


body.house-display-dark
.dashboard-behaviour-student:hover {
  background:#1e2d44 !important;

  border-color:
    rgba(167,139,250,0.50) !important;
}


body.house-display-dark
.dashboard-behaviour-student-name strong {
  color:#f8fafc !important;
}


body.house-display-dark
.dashboard-behaviour-student-name span {
  color:#aebed2 !important;
}


/* Tier badge */

body.house-display-dark
.dashboard-behaviour-tier.pre-tier-1 {
  background:rgba(59,130,246,0.16) !important;
  color:#bfdbfe !important;
  border-color:rgba(147,197,253,0.28) !important;
}

body.house-display-dark
.dashboard-behaviour-tier.tier-1 {
  background:rgba(34,197,94,0.16) !important;
  color:#bbf7d0 !important;
  border-color:rgba(134,239,172,0.26) !important;
}

body.house-display-dark
.dashboard-behaviour-tier.tier-2 {
  background:rgba(245,158,11,0.16) !important;
  color:#fde68a !important;
  border-color:rgba(252,211,77,0.26) !important;
}

body.house-display-dark
.dashboard-behaviour-tier.tier-3 {
  background:rgba(239,68,68,0.16) !important;
  color:#fecaca !important;
  border-color:rgba(252,165,165,0.26) !important;
}


/* Follow-up badge */

body.house-display-dark
.dashboard-behaviour-followup {
  background:
    rgba(234,88,12,0.16) !important;

  color:#fdba74 !important;

  border-color:
    rgba(251,146,60,0.28) !important;
}


/* Recent activity */

body.house-display-dark
.dashboard-behaviour-activity-item {
  background:#172337 !important;

  border-color:
    rgba(148,163,184,0.16) !important;
}

body.house-display-dark
.dashboard-behaviour-activity-item:hover {
  background:#1c2940 !important;
  border-color:rgba(148,163,184,0.26) !important;
}

body.house-display-dark
.dashboard-behaviour-activity-icon.low {
  background:rgba(59,130,246,0.16) !important;
  color:#bfdbfe !important;
}

body.house-display-dark
.dashboard-behaviour-activity-icon.medium {
  background:rgba(245,158,11,0.16) !important;
  color:#fde68a !important;
}

body.house-display-dark
.dashboard-behaviour-activity-icon.high {
  background:rgba(239,68,68,0.16) !important;
  color:#fecaca !important;
}

body.house-display-dark
.dashboard-behaviour-activity-copy strong {
  color:#f8fafc !important;
}

body.house-display-dark
.dashboard-behaviour-activity-time {
  color:#aebed2 !important;
}

body.house-display-dark
.dashboard-behaviour-activity-severity.low {
  background:rgba(59,130,246,0.16) !important;
  border-color:rgba(147,197,253,0.24) !important;
  color:#bfdbfe !important;
}

body.house-display-dark
.dashboard-behaviour-activity-severity.medium {
  background:rgba(245,158,11,0.16) !important;
  border-color:rgba(252,211,77,0.24) !important;
  color:#fde68a !important;
}

body.house-display-dark
.dashboard-behaviour-activity-severity.high {
  background:rgba(239,68,68,0.16) !important;
  border-color:rgba(252,165,165,0.24) !important;
  color:#fecaca !important;
}

body.house-display-dark
.dashboard-behaviour-activity-followup {
  color:#c4b5fd !important;
}

body.house-display-dark
.dashboard-behaviour-activity-arrow {
  color:#94a3b8 !important;
}


/* Today / this week footer */

body.house-display-dark
.dashboard-behaviour-context {
  color:#cbd5e1 !important;
}


body.house-display-dark
.dashboard-behaviour-context span {
  color:#cbd5e1 !important;
}


body.house-display-dark
.dashboard-behaviour-context strong {
  color:#f8fafc !important;
}


/* Open Behaviour & Support */

body.house-display-dark
.dashboard-behaviour-open {
  background:
    rgba(124,58,237,0.14) !important;

  border-color:
    rgba(167,139,250,0.42) !important;

  color:#c4b5fd !important;
}


body.house-display-dark
.dashboard-behaviour-open:hover {
  background:#7c3aed !important;
  border-color:#7c3aed !important;
  color:#ffffff !important;
}


body.house-display-dark
.dashboard-behaviour-settings {
  background:#111c2e !important;

  border-color:
    rgba(148,163,184,0.30) !important;

  color:#cbd5e1 !important;
}


body.house-display-dark
.dashboard-behaviour-settings:hover {
  background:
    rgba(124,58,237,0.14) !important;

  border-color:
    rgba(167,139,250,0.42) !important;

  color:#c4b5fd !important;
}


@media (min-width:781px) and (max-width:1100px) {

  .dashboard-behaviour-summary {
    grid-template-columns:
      repeat(
        2,
        minmax(0,1fr)
      ) !important;

    gap:12px !important;
  }


  .dashboard-behaviour-impact {
    grid-template-columns:
      repeat(
        3,
        minmax(0,1fr)
      ) !important;

    gap:10px !important;
  }


  .dashboard-behaviour-grid {
    grid-template-columns:
      1fr !important;

    gap:12px !important;
  }


  .dashboard-behaviour-stat {
    padding:13px 14px !important;

    min-height:108px !important;
  }


  .dashboard-behaviour-stat-top {
    margin-bottom:8px !important;
  }


  .dashboard-behaviour-stat-icon {
    width:32px !important;
    height:32px !important;

    flex:0 0 32px !important;
  }


  .dashboard-behaviour-stat-value {
    font-size:27px !important;
  }


  .dashboard-behaviour-impact-card {
    padding:9px 11px !important;

    gap:9px !important;

    min-height:58px !important;
  }


  .dashboard-behaviour-impact-icon {
    width:30px !important;
    height:30px !important;

    flex:0 0 30px !important;
  }


  .dashboard-behaviour-impact-label {
    font-size:9px !important;
  }


  .dashboard-behaviour-impact-period {
    font-size:8px !important;
  }


  .dashboard-behaviour-impact-value {
    font-size:18px !important;
  }


  .dashboard-behaviour-panel {
    padding:13px !important;
  }

}


@media (max-width:780px) {

  .dashboard-behaviour-overview {
    display:none !important;
  }

}




/* Show both leaderboard actions on iPads */
/* ==========================================
   IPAD - LEADERBOARD HEADING AND ACTIONS
   ONE HORIZONTAL ROW
   ========================================== */

@media (min-width:781px) and (max-width:1370px) {

  #dashboard-section
  .card-header:has(#dashboardOverviewTitle) {
    display:flex !important;
    flex-direction:column !important;
    align-items:stretch !important;
    gap:10px !important;
  }

  #dashboard-section
  .card-header:has(#dashboardOverviewTitle)
  > div:first-child {
    display:flex !important;
    flex-direction:row !important;
    flex-wrap:nowrap !important;
    align-items:center !important;
    justify-content:flex-start !important;
    gap:6px !important;
    width:100% !important;
    min-width:0 !important;
  }

  #dashboard-section
  #dashboardOverviewTitle {
    display:inline-flex !important;
    flex:0 0 auto !important;
    width:auto !important;
    margin:0 10px 0 0 !important;
    font-size:16px !important;
    white-space:nowrap !important;
  }

  #teacherOfWeekBtn,
  #weeklyChangesBtn,
  #sharePublicHouseBoardBtn {
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    flex:0 0 auto !important;
    width:auto !important;
    min-width:0 !important;
    margin:0 !important;
    padding:6px 9px !important;
    gap:5px !important;
    font-size:10px !important;
    white-space:nowrap !important;
  }

}

/* ==========================================
   IPAD PORTRAIT - COMPACT LEADERBOARD HEADER
   Two organised rows, no duplicate controls
   ========================================== */

@media (min-width:781px) and (max-width:1370px) and (orientation:portrait) {

  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  .card-header:has(#dashboardOverviewTitle) {
    display:grid !important;
    grid-template-columns:
      auto auto auto minmax(0,1fr) auto !important;
    grid-template-rows:auto auto !important;
    align-items:center !important;
    column-gap:7px !important;
    row-gap:6px !important;
    margin-bottom:10px !important;
  }

  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  .card-header:has(#dashboardOverviewTitle)
  > div:first-child,
  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  .card-header:has(#dashboardOverviewTitle)
  > div:last-child {
    display:contents !important;
  }

  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  #dashboardOverviewTitle {
    grid-column:1 / 5 !important;
    grid-row:1 !important;
    justify-self:start !important;
    margin:0 !important;
  }

  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  #dashboardOverviewSwitch {
    grid-column:5 !important;
    grid-row:1 !important;
    justify-self:end !important;
    margin:0 !important;
  }

  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  #teacherOfWeekBtn {
    grid-column:1 !important;
    grid-row:2 !important;
  }

  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  #weeklyChangesBtn {
    grid-column:2 !important;
    grid-row:2 !important;
  }

  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  #sharePublicHouseBoardBtn {
    grid-column:3 !important;
    grid-row:2 !important;
  }

  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  .card-header
  .dashboard-projector-nondesktop {
    grid-column:5 !important;
    grid-row:2 !important;
    justify-self:end !important;
    margin:0 !important;
    white-space:nowrap !important;
    padding:6px 10px !important;
    font-size:10px !important;
  }

  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  #teacherOfWeekBtn,
  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  #weeklyChangesBtn,
  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  #sharePublicHouseBoardBtn {
    padding:6px 8px !important;
    font-size:9px !important;
    min-width:0 !important;
    white-space:nowrap !important;
  }
}

/* ==========================================
   IPAD BEHAVIOUR OVERVIEW HEADER
   Title + mode switch on first row
   Behaviour filters on second row
   ========================================== */

@media (min-width:781px) and (max-width:1370px) {

  body.dashboard-behaviour-mode
  #dashboard-section
  .card-header:has(#dashboardBehaviourFilters) {
    display:grid !important;
    grid-template-columns:
      minmax(0,1fr)
      auto !important;
    grid-template-rows:
      auto
      auto !important;
    align-items:center !important;
    column-gap:12px !important;
    row-gap:10px !important;
    width:100% !important;
    margin-bottom:12px !important;
  }

  /* Allow existing controls to occupy the grid */
  body.dashboard-behaviour-mode
  #dashboard-section
  .card-header:has(#dashboardBehaviourFilters)
  > div:first-child,
  body.dashboard-behaviour-mode
  #dashboard-section
  .card-header:has(#dashboardBehaviourFilters)
  > div:last-child {
    display:contents !important;
  }

  /* First row: title on the left */
  body.dashboard-behaviour-mode
  #dashboard-section
  #dashboardOverviewTitle {
    grid-column:1 !important;
    grid-row:1 !important;
    justify-self:start !important;
    align-self:center !important;
    width:auto !important;
    margin:0 !important;
    white-space:nowrap !important;
  }

  /* First row: mode switch on the right */
  body.dashboard-behaviour-mode
  #dashboard-section
  #dashboardOverviewSwitch {
    grid-column:2 !important;
    grid-row:1 !important;
    justify-self:end !important;
    align-self:center !important;
    margin:0 !important;
    flex-shrink:0 !important;
  }

  /* Second row: all Behaviour filters */
  body.dashboard-behaviour-mode
  #dashboard-section
  #dashboardBehaviourFilters {
    grid-column:1 / -1 !important;
    grid-row:2 !important;

    display:flex !important;
    flex-direction:row !important;
    flex-wrap:wrap !important;
    align-items:center !important;
    justify-content:flex-start !important;

    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;

    gap:8px !important;
    margin:0 !important;
    padding:0 !important;

    overflow:visible !important;
  }

  /* Keep filter controls at sensible sizes */
  body.dashboard-behaviour-mode
  #dashboard-section
  #dashboardBehaviourFilters > select,
  body.dashboard-behaviour-mode
  #dashboard-section
  #dashboardBehaviourFilters > button {
    max-width:100% !important;
    height:36px !important;
    min-height:36px !important;
    flex-shrink:0 !important;
  }

  /* Advanced filters retain their existing toggle behaviour */
  body.dashboard-behaviour-mode
  #dashboard-section
  #dashboardBehaviourFilters
  .dashboard-behaviour-advanced-filter {
    display:none !important;
  }

  body.dashboard-behaviour-mode
  #dashboard-section
  #dashboardBehaviourFilters.advanced-open
  .dashboard-behaviour-advanced-filter {
    display:block !important;
  }
}

/* ==========================================
   LEADERBOARD - UPDATES & SHARING DROPDOWN
   ========================================== */

#dashboard-section .card:has(#dashboardInsightsMenu) {
  position: relative;
  overflow: visible !important;
  z-index: 10;
}

#dashboardInsightsMenu {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  z-index: 1000;
}

#dashboardInsightsMenu > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 34px;
  padding: 7px 13px;
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}

#dashboardInsightsMenu > summary::-webkit-details-marker {
  display: none;
}

#dashboardInsightsMenu[open] > summary {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

#dashboardInsightsMenu > summary .fa-chevron-down {
  font-size: 10px;
  transition: transform .15s ease;
}

#dashboardInsightsMenu[open] > summary .fa-chevron-down {
  transform: rotate(180deg);
}

#dashboardInsightsMenu .dashboard-insights-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 260px;
  max-width: calc(100vw - 32px);
  padding: 7px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 14px 35px rgba(15,23,42,.16);
  z-index: 50000;
}

#dashboard-section
#dashboardInsightsMenu
.dashboard-insights-options > button {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  width: 100% !important;
  min-height: 42px !important;
  padding: 11px 12px !important;
  margin: 0 !important;
  background: transparent !important;
  border: none !important;
  border-radius: 9px !important;
  color: #334155 !important;
  font-family: inherit !important;
  font-size: 12px !important;
  font-weight: 750 !important;
  text-align: left !important;
  white-space: nowrap !important;
  cursor: pointer;
}

#dashboard-section
#dashboardInsightsMenu
.dashboard-insights-options > button:hover {
  background: #f1f5f9 !important;
}

#dashboardInsightsMenu .dashboard-insights-options i {
  width: 17px;
  text-align: center;
  flex-shrink: 0;
}

/* Hide House-only sharing controls outside House Points */
body.dashboard-behaviour-mode #dashboardInsightsMenu,
body.dashboard-store-mode #dashboardInsightsMenu,
body.dashboard-student-activity-mode #dashboardInsightsMenu {
  display:none !important;
}

/* Student App button: hidden in other dashboard views */
#dashboardStudentAppBtn {
  display:none;
  align-items:center;
  justify-content:center;
  gap:9px;
  min-height:36px;
  padding:8px 14px;
  border:1px solid #bfdbfe;
  border-radius:10px;
  background:#eff6ff;
  color:#1e3a8a;
  font-family:inherit;
  font-size:12px;
  font-weight:800;
  white-space:nowrap;
  cursor:pointer;
  transition:background .18s ease,box-shadow .18s ease;
}

body.dashboard-student-activity-mode
#dashboardStudentAppBtn {
  display:none !important;
}

#dashboardStudentAppBtn:hover {
  background:#dbeafe;
  box-shadow:0 3px 10px rgba(30,58,138,.12);
}

#dashboardStudentAppBtn:focus-visible {
  outline:3px solid #60a5fa;
  outline-offset:3px;
}

/* Student App button: dark mode */
body.house-display-dark #dashboardStudentAppBtn {
  background:#1e3a8a !important;
  border-color:#3b82f6 !important;
  color:#dbeafe !important;
}

body.house-display-dark #dashboardStudentAppBtn:hover {
  background:#1d4ed8 !important;
}

/* iPad portrait: place the single dropdown below title */
@media (min-width:781px) and (max-width:1370px) and (orientation:portrait) {
  body:not(.dashboard-behaviour-mode)
  #dashboard-section
  #dashboardInsightsMenu {
    grid-column: 1 / 4 !important;
    grid-row: 2 !important;
    justify-self: start !important;
  }
}

/* Smaller screens */
@media (max-width:780px) {
  #dashboardInsightsMenu > summary {
    font-size: 11px;
    padding: 7px 9px;
  }
}

/* Dark mode */
body.house-display-dark #dashboardInsightsMenu > summary {
  background: #172337 !important;
  border-color: #475569 !important;
  color: #e2e8f0 !important;
}

body.house-display-dark
#dashboardInsightsMenu .dashboard-insights-options {
  background: #172337 !important;
  border-color: #475569 !important;
}

body.house-display-dark
#dashboard-section
#dashboardInsightsMenu
.dashboard-insights-options > button {
  color: #e2e8f0 !important;
}

body.house-display-dark
#dashboard-section
#dashboardInsightsMenu
.dashboard-insights-options > button:hover {
  background: #26364c !important;
}


/* Dashboard: group leaderboard header actions */
#dashboard-section
.card-header:has(#dashboardInsightsMenu) {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 10px !important;
}

#dashboard-section
.card-header:has(#dashboardInsightsMenu)
> div:first-child {
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
  min-width: 0 !important;
}

#dashboard-section
.card-header:has(#dashboardInsightsMenu)
> div:last-child {
  display: flex !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  justify-self: end !important;
  gap: 8px !important;
}

@media (max-width: 780px) {
  #dashboard-section
  .card-header:has(#dashboardInsightsMenu) {
    grid-template-columns: 1fr !important;
  }

  #dashboard-section
  .card-header:has(#dashboardInsightsMenu)
  > div:last-child {
    justify-self: start !important;
  }
}

#dashboard-section
#dashboardInsightsMenu + .dashboard-house-manage-wrap {
  margin-left: 0 !important;
  min-width: 0;
}

/* Edit Houses is only relevant to House Points */
body.dashboard-store-mode #dashboard-section
.dashboard-house-manage-wrap {
  display: none !important;
}

/* Start Challenge + Assembly Mode */
#dashboardLeaderboardActions {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
}

#dashboardLeaderboardActions
#dashboardAnnouncementAssemblyBtn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 34px !important;
  margin: 0 !important;
  flex-shrink: 0;
}

/* Rewards Store: hide House-only actions */
body.dashboard-store-mode #dashboardStartChallengeBtn,
body.dashboard-store-mode #dashboardAnnouncementAssemblyBtn,
body.dashboard-store-mode #trackeduHighlightsActions #dashboardStartChallengeBtn,
body.dashboard-store-mode #dashboardLeaderboardActions #dashboardAnnouncementAssemblyBtn {
  display: none !important;
}

/* Hide empty House action wrappers in Rewards Store */
body.dashboard-store-mode #dashboardLeaderboardActions {
  display: none !important;
}

@media (max-width: 780px) {
  #dashboardLeaderboardActions {
    width: 100%;
    justify-content: flex-end !important;
  }

  #dashboardLeaderboardActions
  #dashboardAnnouncementAssemblyBtn {
    display: none !important;
  }
}



/* Full-screen House Master Toolkits layout */
@media (min-width: 1025px) {
  #houseMasterToolkitsModal .hmt-shell {
    width: 100% !important;
    max-width: none !important;
    min-height: 100dvh;
    box-sizing: border-box;
  }

  #houseMasterToolkitsModal .hmt-inner {
    width: calc(100% - 80px) !important;
    max-width: none !important;
    min-height: 0;
    margin: 0 auto;
    padding: 0 0 24px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 18px;
  }

  #houseMasterToolkitsModal .hmt-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(104px, auto);
    align-content: start;
  }

  #houseMasterToolkitsModal .hmt-card {
    height: 100%;
    min-height: 104px;
    box-sizing: border-box;
  }
}



    @media (max-width: 1370px) {
      #tedStudentsRecognisedCard {
        pointer-events: none !important;
        cursor: default !important;
        transform: none !important;
      }
    }




@media (max-width: 780px) {

 /* Hide School Activity on phones only. */
#dashboard-section #tedWeeklyRecognitionSummary {
  display: none !important;
}

  /* Keep House Highlights heading compact. */
  #dashboard-section
  .card:has(#houseOverview)
  .card-header .mobile-only {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
  }

  #dashboard-section
  .card:has(#houseOverview)
  .card-header .mobile-only > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center !important;
    gap: 4px 6px !important;
  }

  /* Existing Challenge button beside House Highlights. */
  #dashboard-section .ted-mobile-challenge-wrap {
    display: block !important;
    position: relative !important;
    flex: 0 0 auto !important;
    margin-left: auto !important;
  }

  #dashboardStartChallengeBtn {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 !important;
    justify-content: center !important;
  }

  /* Keep the Challenge menu usable outside School Activity. */
  #dashboard-section
  .ted-mobile-challenge-wrap
  #dashboardLiveChallengeMenu {
    position: fixed !important;
    top: var(--challenge-menu-top, 60px) !important;
    left: var(--challenge-menu-left, 12px) !important;
    right: auto !important;
    bottom: auto !important;
    width: min(340px, calc(100vw - 24px)) !important;
    max-height: var(--challenge-menu-height, 420px) !important;
    overflow-y: auto !important;
    z-index: 50000 !important;
  }

  #dashboardStartChallengeBtn .challenge-button-label,
  #dashboardStartChallengeBtn .fa-chevron-down {
    display: none !important;
  }

  #dashboardStartChallengeBtn .fa-bolt {
    font-size: 16px !important;
  }
}




/* Rewards Store: Remove action */

#rewardsCatalogueDialog .ted-store-card-actions {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
}

#rewardsCatalogueDialog .ted-store-card-actions
.ted-store-visibility {
  margin-right: auto;
}

#rewardsCatalogueDialog .ted-store-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid #fecaca;
  border-radius: 9px;
  background: #fff1f2;
  color: #b91c1c;
  font: 750 12px Lexend, sans-serif;
  cursor: pointer;
}

#rewardsCatalogueDialog .ted-store-remove:hover {
  background: #ffe4e6;
  border-color: #f87171;
}

.ted-store-remove-dialog {
  position: fixed;
  inset: 0;
  width: min(420px, calc(100vw - 28px));
  max-width: none;
  max-height: 90dvh;
  margin: auto;
  padding: 0;
  border: none;
  border-radius: 18px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 25px 80px rgba(15,23,42,.35);
}

.ted-store-remove-dialog::backdrop {
  background: rgba(15,23,42,.65);
}

.ted-store-remove-content {
  padding: 26px;
  text-align: center;
  font-family: Lexend, sans-serif;
}

.ted-store-remove-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 15px;
  border-radius: 50%;
  background: #fff1f2;
  color: #dc2626;
  font-size: 24px;
}

.ted-store-remove-content h3 {
  margin: 0 0 9px;
  font-size: 21px;
  font-weight: 800;
  color: #172554;
}

.ted-store-remove-content p {
  margin: 0 0 13px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.6;
}

.ted-store-remove-name {
  display: block;
  padding: 13px;
  margin-bottom: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.ted-store-remove-content .ted-store-remove-note {
  color: #475569;
  text-align: left;
  font-size: 11px;
}

.ted-store-remove-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.ted-store-remove-actions button {
  flex: 1;
  min-height: 44px;
  padding: 10px;
  border-radius: 10px;
  font: 800 12px Lexend, sans-serif;
  cursor: pointer;
}

.ted-store-remove-cancel {
  background: white;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.ted-store-remove-confirm {
  background: #dc2626;
  color: white;
  border: 1px solid #dc2626;
}

@media (max-width: 600px) {
  .ted-store-remove-content {
    padding: 20px;
  }

  #rewardsCatalogueDialog .ted-store-card-actions {
    width: 100%;
  }

  .ted-store-remove-actions {
    flex-direction: column-reverse;
  }
}


/* ==========================================
   DASHBOARD REWARDS STORE
   ========================================== */

.ted-dashboard-store {
  width: 100%;
  min-width: 0;
  padding: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #ffffff;
  color: #0f172a;
}

.ted-dashboard-store-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.ted-dashboard-store-header h3 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 800;
  color: #172554;
}

.ted-dashboard-store-header p {
  margin: 0;
  color: #64748b;
  font-size: 12px;
}

.ted-dashboard-store-active {
  padding: 7px 11px;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  background: #f0fdf4;
  color: #15803d;
  font-size: 11px;
  font-weight: 800;
}

.ted-dashboard-store-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

/* School Store reward preview: desktop only */
.ted-dashboard-store-preview {
  display: none;
}

@media (min-width: 1371px) {
  .ted-dashboard-store-preview {
    display: block;
    margin: 8px 0 16px;
  }

  .ted-dashboard-store-preview h4 {
    margin: 0 0 10px;
    color: #172554;
    font-size: 13px;
    font-weight: 800;
  }

  .ted-dashboard-store-preview-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
  }

  .ted-dashboard-store-preview-card {
    min-width: 0;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 11px;
  }

  .ted-dashboard-store-preview-visual {
    position: relative;
    display: grid;
    place-items: center;
    height: 74px;
    overflow: hidden;
    background: #f5f8fb;
    color: #94a3b8;
    font-size: 25px;
  }

  .ted-dashboard-store-preview-visual img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f5f8fb;
  }

  .ted-dashboard-store-preview-details {
    padding: 9px 10px;
  }

  .ted-dashboard-store-preview-details > strong {
    min-height: 30px;
    color: #172554;
    font-size: 11px;
    font-weight: 750;
    line-height: 1.35;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .ted-dashboard-store-preview-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
  }

  .ted-dashboard-store-preview-cost {
    color: #15803d;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
  }

  .ted-dashboard-store-preview-stock {
    color: #64748b;
    font-size: 10px;
    white-space: nowrap;
  }

  .ted-dashboard-store-preview-stock.out {
    color: #b91c1c;
  }
}

/* ==========================================
   COMPACT SCHOOL STORE DASHBOARD
   Desktop only - no additional Firebase calls
   ========================================== */

@media (min-width: 1371px) {

  /* Reduce the main Store panel's spacing */
  .ted-dashboard-store {
    padding: 13px 15px;
  }

  .ted-dashboard-store-header {
    gap: 8px;
    margin-bottom: 10px;
  }

  .ted-dashboard-store-header .ted-dashboard-store-actions button {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 10px;
  }

  /* Smaller Store Active indicator */
  .ted-dashboard-store-active {
    padding: 5px 9px;
    font-size: 10px;
  }

  /* Compact statistics */
  .ted-dashboard-store-stats {
    gap: 8px;
    margin-bottom: 8px;
  }

  .ted-dashboard-store-stat {
    padding: 9px 11px;
    gap: 3px;
    min-height: 67px;
    border-radius: 9px;
  }

  .ted-dashboard-store-stat i {
    font-size: 13px;
  }

  .ted-dashboard-store-stat strong {
    font-size: 20px;
    line-height: 1.1;
  }

  .ted-dashboard-store-stat span {
    font-size: 10px;
    line-height: 1.3;
  }

  /* Smaller reward section */
  .ted-dashboard-store-preview {
    margin: 8px 0 10px;
  }

  .ted-dashboard-store-preview h4 {
    margin: 0 0 7px;
    font-size: 12px;
  }

  .ted-dashboard-store-preview-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }

  .ted-dashboard-store-preview-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    min-height: 65px;
    border-radius: 9px;
    box-shadow: none;
  }

  /* Small reward image on the left */
  .ted-dashboard-store-preview-visual {
    position: relative;
    flex: 0 0 54px;
    width: 54px;
    height: 54px;
    margin: 5px;
    border-radius: 7px;
    background: #f8fafc;
    font-size: 20px;
  }

  .ted-dashboard-store-preview-visual img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 5px;
    background: transparent;
  }

  /* Reward information beside image */
  .ted-dashboard-store-preview-details {
    flex: 1;
    min-width: 0;
    padding: 6px 7px 6px 2px;
  }

  .ted-dashboard-store-preview-details > strong {
    display: -webkit-box;
    min-height: 0;
    margin: 0;
    font-size: 10px;
    font-weight: 750;
    line-height: 1.3;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  /* Points and stock on one line */
  .ted-dashboard-store-preview-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 3px 7px;
    margin-top: 5px;
  }

  .ted-dashboard-store-preview-cost {
    font-size: 10px;
    font-weight: 800;
  }

  .ted-dashboard-store-preview-stock {
    font-size: 9px;
  }

  /* Compact request status */
  .ted-dashboard-store-all-clear {
    min-height: 0;
    padding: 7px 10px;
    gap: 7px;
    border-radius: 8px;
    font-size: 10px;
    background: transparent;
  }

  .ted-dashboard-store-all-clear i {
    font-size: 12px;
  }
}

/* No preview on iPads or mobile phones */
@media (max-width: 1370px) {
  .ted-dashboard-store-preview {
    display: none !important;
  }
}

.ted-dashboard-store-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  background: #ffffff;
  color: #172554;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.ted-dashboard-store-stat:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.ted-dashboard-store-stat:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.ted-dashboard-store-stat strong {
  font-size: 23px;
  line-height: 1.2;
}

.ted-dashboard-store-stat span {
  font-size: 10px;
  line-height: 1.4;
}

.ted-dashboard-store-all-clear {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 650;
}

.ted-dashboard-store-all-clear i {
  color: #16a34a;
  font-size: 15px;
}

@media (max-width: 1000px) {
  .ted-dashboard-store-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .ted-dashboard-store-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .ted-dashboard-store-stat {
    padding: 10px;
    min-height: 77px;
  }

  .ted-dashboard-store-stat strong {
    font-size: 20px;
  }

  .ted-dashboard-store-stat span {
    font-size: 10px;
  }
}

.ted-dashboard-store-stat i {
  color: #2563eb;
  font-size: 17px;
}

.ted-dashboard-store-stat strong {
  font-size: 28px;
  line-height: 1.2;
  color: #172554;
}

.ted-dashboard-store-stat span {
  color: #64748b;
  font-size: 12px;
  font-weight: 650;
}

.ted-dashboard-store-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  min-width: 0;
}

.ted-dashboard-store-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.ted-dashboard-store-header > div:first-child {
  flex: 0 0 auto;
}

.ted-dashboard-store-header .ted-store-open-right {
  margin-left: auto;
}

/* Open School Store button on the far right */
.ted-dashboard-store-header .ted-store-open-right {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  background: #f0fdf4;
  color: #15803d;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.ted-dashboard-store-header .ted-store-open-right:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.ted-dashboard-store-header .ted-store-open-right:focus-visible {
  outline: 3px solid #22c55e;
  outline-offset: 2px;
}

@media (max-width: 780px) {
  .ted-dashboard-store-header .ted-store-open-right {
    margin-left: auto;
  }
}

.ted-dashboard-store-header .ted-dashboard-store-actions button {
  width: auto;
  min-height: 32px;
  padding: 6px 9px;
  gap: 5px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.ted-dashboard-store-header .ted-dashboard-store-actions button i {
  font-size: 10px;
}

.ted-dashboard-store-actions button,
.ted-dashboard-store-empty button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 43px;
  padding: 10px 15px;
  border-radius: 10px;
  font: 750 12px Lexend, sans-serif;
  cursor: pointer;
}

.ted-dashboard-store-primary {
  background: #1e40af;
  border: 1px solid #1e40af;
  color: #ffffff;
}

.ted-dashboard-store-primary:hover {
  background: #1d4ed8;
}

.ted-dashboard-store-secondary {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
}

.ted-dashboard-store-secondary:hover {
  background: #f8fafc;
}

.ted-dashboard-store-list-title {
  margin: 18px 0 10px;
  color: #172554;
  font-size: 15px;
  font-weight: 800;
}

.ted-dashboard-store-requests-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.ted-dashboard-store-request {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  padding: 12px 14px;
  margin: 0;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  background: #ffffff;
}

@media (max-width: 1000px) {
  .ted-dashboard-store-requests-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 540px) {
  .ted-dashboard-store-requests-grid {
    grid-template-columns: 1fr;
  }

  .ted-dashboard-store-request {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }
}

.ted-dashboard-store-request > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 4px;
}

.ted-dashboard-store-request strong {
  color: #0f172a;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.ted-dashboard-store-request div span {
  color: #64748b;
  font-size: 11px;
}

.ted-dashboard-store-status {
  flex-shrink: 0;
  padding: 5px 9px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  font-weight: 800;
}

.ted-dashboard-store-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 500px;
  margin: 12px auto;
  padding: 30px 20px;
  text-align: center;
}

.ted-dashboard-store-empty-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 25px;
}

.ted-dashboard-store-empty h3 {
  margin: 0;
  color: #172554;
  font-size: 19px;
}

.ted-dashboard-store-empty p,
.ted-dashboard-store-teacher-note {
  margin: 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.65;
}

.ted-dashboard-store-teacher-note {
  margin: 12px 0;
}

/* Hide House-only controls while Store is selected */
body.dashboard-store-mode #schoolValuesBar {
  display: none !important;
}

/* Hide School Activity when Rewards Store is selected */
body.dashboard-store-mode #dashboard-section #tedWeeklyRecognitionSummary {
  display: none !important;
}

/* Accessible focus */
.ted-dashboard-store button:focus-visible,
#dashboardRewardsStoreModeBtn:focus-visible {
  outline: 3px solid #60a5fa;
  outline-offset: 3px;
}

/* Tablet and mobile */
@media (max-width: 780px) {
  .ted-dashboard-store {
    padding: 13px;
  }

  .ted-dashboard-store-stats {
    gap: 9px;
  }

  .ted-dashboard-store-stat {
    padding: 12px;
  }

  .ted-dashboard-store-stat strong {
    font-size: 23px;
  }

  .ted-dashboard-store-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
    gap: 6px;
  }

  .ted-dashboard-store-actions button {
    width: auto;
    flex: 0 1 auto;
  }

  .ted-dashboard-store-header {
    align-items: flex-start;
    gap: 9px;
  }

  .ted-dashboard-store-header .ted-dashboard-store-active {
    margin-left: auto;
  }

  .ted-dashboard-store-header .ted-dashboard-store-actions button {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 10px;
  }

  .ted-dashboard-store-request {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  #dashboardOverviewSwitch {
    flex-wrap: wrap;
  }

  #dashboardRewardsStoreModeBtn {
    min-height: 38px;
    white-space: normal;
  }
}

/* Dark mode */
body.house-display-dark .ted-dashboard-store {
  background: #172337;
  border-color: #334155;
  color: #f8fafc;
}

body.house-display-dark .ted-dashboard-store-header h3,
body.house-display-dark .ted-dashboard-store-list-title,
body.house-display-dark .ted-dashboard-store-empty h3 {
  color: #f8fafc;
}

body.house-display-dark .ted-dashboard-store-stat,
body.house-display-dark .ted-dashboard-store-request {
  background: #1e293b;
  border-color: #334155;
}

body.house-display-dark .ted-dashboard-store-stat strong,
body.house-display-dark .ted-dashboard-store-request strong {
  color: #f8fafc;
}

body.house-display-dark .ted-dashboard-store-secondary {
  background: #263449;
  color: #f8fafc;
  border-color: #475569;
}

/* ==========================================
   PREMIUM SCHOOL STORE DASHBOARD
   Compact, responsive, zero additional requests
   ========================================== */

.ted-dashboard-store {
  background: linear-gradient(145deg, #f6fbf8 0%, #f9fbfd 100%);
  border: 1px solid #dcebe2;
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 3px 16px rgba(15, 75, 45, .035);
}

.ted-dashboard-store-header {
  gap: 8px 12px;
  margin-bottom: 15px;
}

.ted-dashboard-store-header h3,
.ted-dashboard-store-list-title {
  color: #172554;
}

.ted-dashboard-store-active {
  background: #e8f8ef;
  border: 1px solid #b7ebcc;
  color: #137d44;
  box-shadow: none;
}

/* Premium compact metric cards */

.ted-dashboard-store-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 13px;
}

.ted-dashboard-store-stat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  min-height: 94px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #dfeae4;
  border-radius: 12px;
  box-shadow: 0 2px 7px rgba(15, 50, 35, .025);
  color: #172554;
  font-family: inherit;
  text-align: left;
  overflow: hidden;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

button.ted-dashboard-store-stat {
  cursor: pointer;
}

button.ted-dashboard-store-stat:hover {
  background: #fafffc;
  border-color: #86d9a8;
  box-shadow: 0 4px 13px rgba(22, 163, 74, .07);
}

.ted-dashboard-store-stat i {
  color: #16a34a;
  font-size: 15px;
  margin-bottom: 1px;
}

.ted-dashboard-store-stat strong {
  font-size: 25px;
  font-weight: 850;
  line-height: 1.1;
  color: #172554;
  font-variant-numeric: tabular-nums;
}

.ted-dashboard-store-stat span {
  color: #64748b;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.4;
}

/* Pending requests deserve attention without looking alarming */

.ted-dashboard-store-stat:first-child {
  border-color: #eadfc5;
  background: #fffdf8;
}

.ted-dashboard-store-stat:first-child i {
  color: #d97706;
}

/* Clear primary/secondary action hierarchy */

.ted-dashboard-store-header
.ted-dashboard-store-actions
.ted-dashboard-store-primary {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.ted-dashboard-store-header
.ted-dashboard-store-actions
.ted-dashboard-store-primary:hover {
  background: #15803d;
  border-color: #15803d;
}

.ted-dashboard-store-header
.ted-dashboard-store-actions
.ted-dashboard-store-secondary {
  background: #ffffff;
  border-color: #d9e6df;
  color: #334155;
}

.ted-dashboard-store-header
.ted-dashboard-store-actions
.ted-dashboard-store-secondary:hover {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

/* Request cards */

.ted-dashboard-store-list-title {
  margin: 13px 0 9px;
  font-size: 14px;
  font-weight: 800;
}

.ted-dashboard-store-requests-grid {
  gap: 9px;
}

.ted-dashboard-store-request {
  background: #ffffff;
  border: 1px solid #dce9e1;
  border-left: 3px solid #16a34a;
  border-radius: 11px;
  padding: 12px 14px;
  gap: 6px;
  box-shadow: 0 2px 7px rgba(15, 50, 35, .025);
}

.ted-dashboard-store-request strong {
  color: #172554;
  font-size: 13px;
}

.ted-dashboard-store-request .ted-dashboard-store-status {
  background: #fff3d6;
  border: 1px solid #fde5a5;
  color: #9a5800;
  border-radius: 7px;
  padding: 5px 9px;
}

/* Empty / all-clear status */

.ted-dashboard-store-all-clear {
  background: #ffffff;
  border: 1px solid #dcebe2;
  border-radius: 10px;
  color: #475569;
  padding: 10px 12px;
  font-size: 12px;
}

.ted-dashboard-store-all-clear i {
  color: #16a34a;
}

/* Tablet */

@media (max-width: 1000px) {
  .ted-dashboard-store-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Mobile */

@media (max-width: 600px) {
  .ted-dashboard-store {
    padding: 12px;
    border-radius: 13px;
  }

  .ted-dashboard-store-header {
    gap: 10px;
    margin-bottom: 12px;
  }

  .ted-dashboard-store-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .ted-dashboard-store-stat {
    min-height: 83px;
    padding: 10px 11px;
  }

  .ted-dashboard-store-stat strong {
    font-size: 22px;
  }

  .ted-dashboard-store-stat i {
    font-size: 14px;
  }

  .ted-dashboard-store-stat span {
    font-size: 10px;
  }

  .ted-dashboard-store-request {
    padding: 11px 12px;
  }

  .ted-dashboard-store-header
  .ted-dashboard-store-actions button {
    min-height: 36px;
    padding: 8px 10px;
  }
}

/* Dark mode */

body.house-display-dark .ted-dashboard-store {
  background: #172337;
  border-color: #334155;
}

body.house-display-dark .ted-dashboard-store-stat,
body.house-display-dark .ted-dashboard-store-request,
body.house-display-dark .ted-dashboard-store-all-clear {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.house-display-dark .ted-dashboard-store-stat strong,
body.house-display-dark .ted-dashboard-store-request strong {
  color: #f8fafc;
}

body.house-display-dark .ted-dashboard-store-stat:first-child {
  border-color: #755a32;
}

body.house-display-dark .ted-dashboard-store-stat span {
  color: #cbd5e1;
}

/* School Store reward previews in dark mode */
body.house-display-dark .ted-dashboard-store-preview h4 {
  color: #e2e8f0;
}

body.house-display-dark .ted-dashboard-store-preview-card {
  background: #1e293b;
  border-color: #334155;
}

body.house-display-dark .ted-dashboard-store-preview-visual {
  background: #263449;
  color: #cbd5e1;
}

body.house-display-dark .ted-dashboard-store-preview-visual img {
  background: transparent;
}

body.house-display-dark .ted-dashboard-store-preview-details > strong {
  color: #f8fafc;
}

body.house-display-dark .ted-dashboard-store-preview-cost {
  color: #4ade80;
}

body.house-display-dark .ted-dashboard-store-preview-stock {
  color: #cbd5e1;
}

body.house-display-dark .ted-dashboard-store-preview-stock.out {
  color: #f87171;
}

body.house-display-dark
.ted-dashboard-store-header
.ted-dashboard-store-actions
.ted-dashboard-store-secondary {
  background: #263449;
  border-color: #475569;
  color: #f8fafc;
}



/* School Store: description alongside dashboard title */

#dashboardStoreSubtitle {
  display: none;
  color: #64748b;
  font-family: Lexend, sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

body.dashboard-store-mode #dashboardStoreSubtitle {
  display: inline;
}

#dashboardStudentPortalSubtitle {
  display: none;
  color: #64748b;
  font-family: Lexend, sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

body.dashboard-student-activity-mode #dashboardStudentPortalSubtitle {
  display: inline;
}

/* Hide Student Portal description on iPad and tablets */
@media (min-width: 781px) and (max-width: 1370px) {
  body.dashboard-student-activity-mode #dashboardStudentPortalSubtitle {
    display: none !important;
  }
}

@media (max-width: 780px) {
  #dashboardStudentPortalSubtitle {
    font-size: 10px;
  }

  body.dashboard-student-activity-mode
  .card-header:has(#dashboardOverviewTitle)
  > div:first-child {
    flex-wrap: wrap;
    row-gap: 4px;
  }
}

body.dashboard-store-mode #dashboardOverviewTitle {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 780px) {
  #dashboardStoreSubtitle {
    font-size: 10px;
  }

  body.dashboard-store-mode
  .card-header:has(#dashboardOverviewTitle)
  > div:first-child {
    flex-wrap: wrap;
    row-gap: 4px;
  }
}




/* Turn Store Points On or Off: admin-only compact disclosure */

#rewardsCatalogueDialog .ted-store-admin-settings {
  display: block;
  margin: 0 0 16px;
  border: 1px solid #dce9e1;
  border-radius: 12px;
  background: #ffffff;
  overflow: hidden;
}

#rewardsCatalogueDialog .ted-store-admin-settings[hidden] {
  display: none !important;
}

#rewardsCatalogueDialog .ted-store-admin-settings > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
  color: #172554;
}

#rewardsCatalogueDialog .ted-store-admin-settings > summary::-webkit-details-marker {
  display: none;
}

#rewardsCatalogueDialog .ted-store-settings-title,
#rewardsCatalogueDialog .ted-store-settings-right {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 800;
}

#rewardsCatalogueDialog .ted-store-settings-title i {
  color: #16a34a;
}

#rewardsCatalogueDialog .ted-store-settings-right {
  color: #15803d;
}

#rewardsCatalogueDialog .ted-store-settings-right > span {
  background: #eaf8ef;
  border-radius: 99px;
  padding: 5px 10px;
  font-size: 10px;
}

#rewardsCatalogueDialog .ted-store-settings-right > i {
  color: #94a3b8;
  transition: transform .15s;
}

#rewardsCatalogueDialog .ted-store-admin-settings[open]
.ted-store-settings-right > i {
  transform: rotate(180deg);
}

#rewardsCatalogueDialog .ted-store-admin-settings-body {
  padding: 0 16px 16px;
  border-top: 1px solid #edf2ef;
}

#rewardsCatalogueDialog .ted-store-admin-settings-body h3 {
  display: none !important;
}

#rewardsCatalogueDialog .ted-store-admin-settings-body > p {
  margin-top: 10px !important;
}

#rewardsCatalogueDialog .ted-store-admin-settings-body
> div:last-child {
  background: #f5faf7 !important;
  border: 1px solid #e1eee5;
}

@media (max-width: 600px) {
  #rewardsCatalogueDialog .ted-store-admin-settings {
    margin-bottom: 12px;
  }

  #rewardsCatalogueDialog .ted-store-admin-settings > summary {
    padding: 12px;
  }

  #rewardsCatalogueDialog .ted-store-admin-settings-body {
    padding: 0 12px 12px;
  }
}



    /* ==========================================
       LARGE DESKTOP TOOLKIT GRIDS
       ========================================== */

    @media (min-width: 1400px) {

      #houseMasterToolkitsModal
      .hmt-section-portal
      .hmt-grid {
        grid-template-columns:
          repeat(4, minmax(0, 1fr));
      }


      #houseMasterToolkitsModal
      .hmt-section-admin
      .hmt-grid {
        grid-template-columns:
          repeat(3, minmax(0, 1fr));
      }

    }


    /* Incident Settings beside the heading */
#dashboard-section .card-header
.ted-incident-header-settings {
  display:inline-flex !important;
  align-items:center;
  justify-content:center;
  gap:7px;

  flex:0 0 auto;
  width:auto !important;
  min-height:36px;
  margin:0 !important;
  padding:7px 12px;

  border:1px solid #cbd5e1;
  border-radius:10px;
  background:#ffffff;
  color:#475569;

  font-family:inherit;
  font-size:12px;
  font-weight:800;
  white-space:nowrap;
  cursor:pointer;
}

#dashboard-section .card-header
.ted-incident-header-settings:hover {
  background:#f8fafc;
  border-color:#94a3b8;
}

/* Only show Incident Settings in Incidents mode */
body:not(.dashboard-behaviour-mode)
#dashboard-section .card-header
.ted-incident-header-settings {
  display:none !important;
}

/* Hide the empty footer after moving settings */
#dashboard-section
.dashboard-behaviour-footer-actions:empty {
  display:none !important;
}


/* Dashboard: quieter Assembly Mode button */
body.active-section-dashboard
#dashboardAnnouncementAssemblyBtn {
  background:#ffffff !important;
  color:#475569 !important;
  border:1px solid #cbd5e1 !important;
  box-shadow:none !important;
}

body.active-section-dashboard
#dashboardAnnouncementAssemblyBtn:hover {
  background:#f8fafc !important;
  color:#1e293b !important;
  border-color:#94a3b8 !important;
}

/* Hide Privacy from the announcement bar */
#dashboardPrivacyDataBtn {
  display:none !important;
}

/* Assembly Mode beside Edit */
#announcementBar #dashboardAnnouncementAssemblyBtn {
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  gap:5px !important;

  height:30px !important;
  min-height:30px !important;
  padding:0 10px !important;
  margin:0 !important;

  border:1px solid #cbd5e1 !important;
  border-radius:8px !important;
  background:#ffffff !important;
  color:#475569 !important;

  font-family:inherit;
  font-size:10px !important;
  font-weight:750 !important;
  white-space:nowrap;

  box-shadow:0 1px 3px rgba(15,23,42,0.06) !important;
  cursor:pointer;
}

#announcementBar #dashboardAnnouncementAssemblyBtn:hover {
  background:#f8fafc !important;
  border-color:#94a3b8 !important;
  color:#1e293b !important;
}

/* Assembly Mode button in dark mode */
body.house-display-dark
#announcementBar #dashboardAnnouncementAssemblyBtn {
  background:#1e293b !important;
  border-color:#475569 !important;
  color:#e2e8f0 !important;
  box-shadow:none !important;
}

body.house-display-dark
#announcementBar #dashboardAnnouncementAssemblyBtn:hover {
  background:#334155 !important;
  border-color:#64748b !important;
  color:#ffffff !important;
}

body.house-display-dark
#announcementBar #dashboardAnnouncementAssemblyBtn:focus-visible {
  outline:2px solid #60a5fa !important;
  outline-offset:2px;
}

/* Keep Assembly Mode available in all dashboard views */
body.dashboard-student-activity-mode
#announcementBar #dashboardAnnouncementAssemblyBtn,
body.dashboard-store-mode
#announcementBar #dashboardAnnouncementAssemblyBtn,
body.dashboard-behaviour-mode
#announcementBar #dashboardAnnouncementAssemblyBtn {
  display:inline-flex !important;
}

@media (max-width: 599px) {
  #schoolTodayAbsencesBtn {
    width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
    gap: 0 !important;
    flex: 0 0 38px;
  }

  #schoolTodayAbsencesBtn .school-absences-button-text {
    display: none !important;
  }

  #schoolTodayAbsencesBtn i {
    font-size: 16px !important;
  }
}

#schoolAbsencesSettingsBtn[hidden] {
  display: none !important;
}

#schoolAbsencesSettingsBtn:hover {
  background: #f1f5f9 !important;
  color: #2563eb !important;
}


.classboard-attendance-toggle.attendance-settings-highlight {
  background: #dbeafe !important;
  border: 2px solid #2563eb !important;
  border-radius: 10px !important;
  padding: 8px 12px !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12) !important;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

/* Hide TrackEDU Attendance when the school turns it OFF */

body.trackedu-attendance-off a[onclick*="openMyClassAttendance"],
body.trackedu-attendance-off .smart-menu-item[onclick*="openMyClassAttendance"],
body.trackedu-attendance-off .smart-menu-attendance-dynamic,
body.trackedu-attendance-off .cd-attendance-history-tool {
  display: none !important;
}


/* Hide attendance marking in Student Insights when disabled */

body.trackedu-attendance-off
#classDashboardContent .student-attendance-toggle {
  display: none !important;
}

body.trackedu-attendance-off
#classDashboardContent .si-attendance-action-row {
  justify-content: center !important;
  margin-top: 6px !important;
}


/* Attendance settings: text on desktop, icon on smaller screens */

#schoolAbsencesSettingsBtn[hidden] {
  display: none !important;
}

#schoolAbsencesSettingsBtn:not([hidden]) {
  display: inline-flex;
}

.school-absences-settings-text {
  display: none;
}

@media (min-width: 1024px) {
  .school-absences-settings-text {
    display: inline;
  }
}

@media (max-width: 1023px) {
  #schoolAbsencesSettingsBtn {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    flex: 0 0 36px;
  }
}



/* Mobile only: House Highlights always remains visible. */
@media (max-width:780px) {
  #tedHouseHighlightsCollapseBtn {
    display:none!important;
  }
}

