/* ==========================================================================
   Cubeology Coaching OS - Mobile App Styles
   Transforms the web app into a native mobile app experience
   ========================================================================== */

/* ==========================================================================
   Base Mobile Setup (up to 1024px)
   ========================================================================== */
@media (max-width: 768px) {
  /* Reset and base styles */
  html, body {
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* Smooth scrolling */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  /* App container */
  .dashboard-layout {
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    display: flex;
    flex-direction: column;
  }

  /* ==========================================================================
     App Header - Native App Style
     ========================================================================== */
  /* Use the existing .dashboard-topbar markup as the mobile header */
  .dashboard-topbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1200 !important;
    height: 56px !important;
    padding: 0 14px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(18px) saturate(170%);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  }

  .dashboard-header .header-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
  }

  /* Ensure topbar actions are visible on mobile */
  .topbar-actions { display: flex !important; gap: 12px !important; }
  .topbar-icon { width: 40px !important; height: 40px !important; }
  .topbar-icon svg { width: 24px !important; height: 24px !important; }

  .header-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    position: relative;
  }

  .header-btn:active {
    background: var(--gray-100);
    transform: scale(0.95);
  }

  .header-btn svg {
    width: 22px;
    height: 22px;
  }

  /* On mobile we use the bottom tab bar (no duplicate burger menu) */
  .menu-toggle {
    display: none !important;
  }

  /* ==========================================================================
     Main Content Area
     ========================================================================== */
  .dashboard-main {
    margin-left: 0 !important;
    padding-top: 56px !important; /* Fixed topbar height */
    width: 100% !important;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dashboard-content {
    /* Content starts immediately after the top bar */
    padding: 0px 14px 14px !important;
    max-width: 100% !important;
  }

  /* Mobile typography hierarchy (less clumsy, more "app" feel) */
  .section { margin-top: 12px; }
  .section-header { gap: 10px; }
  .section-title {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em;
    color: var(--text-primary) !important;
  }
  .section-subtitle {
    margin-top: 4px !important;
    font-size: 0.85rem !important;
    line-height: 1.3;
    color: var(--text-muted) !important;
  }

  /* Relaxed spacing + clearer buttons */
  .quick-actions { gap: 10px !important; margin-top: 12px !important; }
  .quick-actions .btn {
    padding: 12px 14px !important;
    font-weight: 600;
  }

  /* Show mobile-specific markup; keep desktop markup hidden */
  .only-mobile { display: block !important; }
  .only-desktop { display: none !important; }

  /* Prevent default margins from creating blank space at the top */
  .dashboard-content > :first-child { margin-top: 0 !important; }
  .dashboard-content h2, .dashboard-content h3, .dashboard-content h4 { margin-top: 0 !important; }

  /* Reduce section header spacing a touch on mobile */
  .section-header {
    margin-bottom: 14px !important;
  }

  /* Remove desktop padding-top on mobile */
  .section-header { padding-top: 0 !important; }

  /* Force everything to stay inside the viewport */
  *, *::before, *::after {
    box-sizing: border-box;
  }
  img, svg, canvas, video {
    max-width: 100%;
  }

  /* ==========================================================================
     Sidebar - Drawer Style
     ========================================================================== */
  .dashboard-sidebar {
    position: fixed;
    top: 0;
    right: 0 !important;
    left: auto !important;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    background: white;
    transform: translateX(100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1300 !important;
    border-left: 1px solid var(--border);
    border-right: none !important;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
  }

  .dashboard-sidebar.open {
    transform: translateX(0) !important;
  }

  .sidebar-brand {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-primary);
  }

  .sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
  }

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

  .sidebar-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 8px 12px;
    margin-bottom: 4px;
  }

  .sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
  }

  .sidebar-link svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }

  .sidebar-link:active,
  .sidebar-link:hover {
    background: var(--gray-100);
    color: var(--text-primary);
  }

  .sidebar-link.active {
    background: var(--primary-50);
    color: var(--primary-600);
  }

  .sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--gray-50);
  }

  .user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background: white;
    border: 1px solid var(--border);
  }

  .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
  }

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

  .user-name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
  }

  /* Sidebar overlay */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1250 !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  /* ==========================================================================
     Bottom Navigation Bar
     ========================================================================== */
  .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    justify-content: flex-start;
    align-items: center;
    z-index: 1100;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: 4px;
  }

  /* Hide the scrollbar but keep swipe */
  .bottom-nav::-webkit-scrollbar { height: 0; }
  .bottom-nav { scrollbar-width: none; }

  .bottom-nav-item {
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    cursor: pointer;
    flex: 0 0 auto;
    min-width: 64px;
    max-width: 92px;
  }

  .bottom-nav-item svg {
    width: 24px;
    height: 24px;
    transition: all 0.2s ease;
  }

  .bottom-nav-item.active {
    color: var(--primary-600);
  }

  .bottom-nav-item.active svg {
    transform: translateY(-2px);
  }

  .bottom-nav-item:active {
    transform: scale(0.95);
  }

  /* ==========================================================================
     Cards - Mobile Optimized
     ========================================================================== */
  .card {
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
  }

  .card:active {
    transform: scale(0.99);
  }

  .card-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .card-body {
    padding: 16px;
  }

  .card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--gray-50);
  }

  /* ==========================================================================
     Stats Cards - Mobile Grid
     ========================================================================== */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
  }

  /* Ultra-small phones: avoid cramped 2-col stats */
  @media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
  }

  .stat-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s ease;
  }

  .stat-card:active {
    transform: scale(0.98);
    background: var(--gray-50);
  }

  .stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }

  .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
  }

  .stat-meta {
    font-size: 0.6875rem;
    color: var(--text-muted);
  }

  .stat-change {
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .stat-change.positive {
    color: var(--success-600);
  }

  .stat-change.negative {
    color: var(--error-600);
  }

  /* ==========================================================================
     Section Headers
     ========================================================================== */
  .section {
    margin-bottom: 24px;
  }

  .section-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }

  .section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
  }

  .section-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
  }

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

  .section-actions .btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }

  /* ==========================================================================
     Buttons - Touch Optimized
     ========================================================================== */
  .btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
    -webkit-touch-callout: none;
    user-select: none;
  }

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

  .btn-primary {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  }

  .btn-primary:active {
    background: linear-gradient(135deg, var(--primary-700), var(--primary-800));
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.2);
  }

  .btn-secondary {
    background: var(--gray-100);
    color: var(--text-primary);
    border: 1px solid var(--border);
  }

  .btn-secondary:active {
    background: var(--gray-200);
  }

  .btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
  }

  .btn-outline:active {
    background: var(--gray-50);
  }

  .btn-danger {
    background: linear-gradient(135deg, var(--error-500), var(--error-600));
    color: white;
  }

  .btn-success {
    background: linear-gradient(135deg, var(--success-500), var(--success-600));
    color: white;
  }

  .btn-sm {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 0.875rem;
  }

  .btn-lg {
    min-height: 52px;
    padding: 14px 24px;
    font-size: 1rem;
  }

  .btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
  }

  /* ==========================================================================
     Forms - Mobile Optimized
     ========================================================================== */
  .form-group {
    margin-bottom: 16px;
  }

  .form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
  }

  .form-input,
  .form-select,
  .form-textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px; /* Prevents zoom on iOS */
    line-height: 1.5;
    color: var(--text-primary);
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
  }

  .form-input:focus,
  .form-select:focus,
  .form-textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
  }

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

  .form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 44px;
  }

  .form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
  }

  /* ==========================================================================
     Data Cards - Mobile Style
     ========================================================================== */
  .data-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .data-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.2s ease;
  }

  .data-card:active {
    background: var(--gray-50);
    transform: scale(0.99);
  }

  .data-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .data-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    flex-shrink: 0;
  }

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

  .data-card-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .data-card-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
  }

  /* ==========================================================================
     Session Cards
     ========================================================================== */
  .session-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
  }

  .session-card:active {
    background: var(--gray-50);
    transform: scale(0.99);
  }

  .session-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    padding: 10px 8px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: white;
    border-radius: 12px;
    text-align: center;
  }

  .session-day {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
  }

  .session-month {
    font-size: 0.6875rem;
    text-transform: uppercase;
    opacity: 0.9;
    margin-top: 2px;
  }

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

  .session-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .session-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .session-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
  }

  /* ==========================================================================
     Student Cards
     ========================================================================== */
  .student-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
    transition: all 0.2s ease;
  }

  .student-card:active {
    background: var(--gray-50);
    transform: scale(0.99);
  }

  .student-card.overdue {
    border-color: var(--error-300);
    background: var(--error-50);
  }

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

  .student-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 600;
    flex-shrink: 0;
  }

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

  .student-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .student-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .student-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  /* Make student stats readable on mobile */
  @media (max-width: 520px) {
    .student-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .student-stat-label { font-size: 0.65rem; }
    .student-stat-value { font-size: 0.95rem; }
  }

  /* Quick actions should feel like an app grid */
  .quick-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }
  .quick-actions .btn {
    width: 100% !important;
    justify-content: center;
    padding: 14px 12px;
    border-radius: 16px;
    min-height: 72px;
    flex-direction: column;
    gap: 10px;
  }
  .quick-actions .btn svg {
    width: 26px;
    height: 26px;
  }

  /* Charts: NEVER overflow the card on mobile */
  .charts-grid,
  .analytics-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .chart-card {
    padding: 16px !important;
    border-radius: 18px;
  }
  .chart-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
  }
  .chart-subtitle {
    margin: 0 !important;
    font-size: 0.8rem !important;
    line-height: 1.35;
    color: var(--text-muted);
  }
  .chart-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    height: 240px !important;
  }
  .chart-container canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    display: block !important;
  }

  /* Specifically tighten the two overview charts */
  #overview-sessions-by-student,
  #overview-revenue-by-student {
    height: 220px !important;
  }

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

  .student-stat-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
  }

  .student-stat-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  /* ==========================================================================
     Tables - Mobile Scrollable
     ========================================================================== */
  .table-container,
  .data-table,
  .table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: white;
  }

  .table-container table,
  .data-table table,
  .table-wrapper table {
    min-width: 600px;
    width: 100%;
    font-size: 0.875rem;
    border-collapse: collapse;
  }

  .table-container th,
  .table-container td,
  .data-table th,
  .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }

  .table-container th,
  .data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--gray-50);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .table-container tbody tr:last-child td,
  .data-table tbody tr:last-child td {
    border-bottom: none;
  }

  /* ==========================================================================
     Charts - Mobile Optimized
     ========================================================================== */
  .charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .chart-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid var(--border);
  }

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

  .chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .chart-container {
    position: relative;
    width: 100%;
    height: 280px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
  }

  .chart-container canvas {
    display: block;
    height: 260px !important;
    width: auto !important;
    max-width: none !important;
    min-width: 100% !important;
  }

  /* Chart swipe hint */
  .chart-container::after {
    content: '← Swipe to explore →';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 12px;
    border-radius: 20px;
    pointer-events: none;
    opacity: 0.8;
  }

  /* ==========================================================================
     Modals - Full Screen on Mobile
     ========================================================================== */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 5000 !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 0;
  }

  .modal-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  .modal-overlay.active .modal {
    transform: translateY(0);
  }

  .modal {
    background: white;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
  }

  .modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .modal-close:active {
    background: var(--gray-200);
    transform: scale(0.95);
  }

  .modal-body {
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
  }

  .modal-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--gray-50);
    flex-shrink: 0;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* Modal handle bar */
  .modal::before {
    content: '';
    width: 40px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  /* ==========================================================================
     Side Panel - Mobile Style
     ========================================================================== */
  .side-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 350;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .side-panel-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  .side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 360px;
    height: 100vh;
    height: 100dvh;
    background: white;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 400;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  }

  .side-panel.active {
    transform: translateX(0);
  }

  .side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .side-panel-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
  }

  .side-panel-section {
    margin-bottom: 24px;
  }

  .side-panel-heading {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
  }

  .side-panel-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .side-panel-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }

  .side-panel-stat-row:last-child {
    border-bottom: none;
  }

  .side-panel-stat-row dt {
    font-size: 0.875rem;
    color: var(--text-muted);
    flex-shrink: 0;
  }

  .side-panel-stat-row dd {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: right;
    word-break: break-word;
  }

  /* ==========================================================================
     Confirm Dialog
     ========================================================================== */
  .confirm-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 6000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 20px;
  }

  .confirm-dialog-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  .confirm-dialog {
    background: white;
    border-radius: 20px;
    padding: 24px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  }

  .confirm-dialog-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    color: var(--warning-500);
  }

  .confirm-dialog-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
  }

  .confirm-dialog-message {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
  }

  .confirm-dialog-actions {
    display: flex;
    gap: 12px;
  }

  .confirm-dialog-actions .btn {
    flex: 1;
  }

  /* ==========================================================================
     Tabs - Mobile Scrollable
     ========================================================================== */
  .tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
  }

  .tab.active {
    background: var(--primary-600);
    color: white;
  }

  .tab:active {
    background: var(--gray-100);
  }

  .tab.active:active {
    background: var(--primary-700);
  }

  /* ==========================================================================
     Badges
     ========================================================================== */
  .badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }

  .badge-default {
    background: var(--gray-100);
    color: var(--gray-700);
  }

  .badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
  }

  .badge-success {
    background: var(--success-100);
    color: var(--success-700);
  }

  .badge-warning {
    background: var(--warning-100);
    color: var(--warning-700);
  }

  .badge-error {
    background: var(--error-100);
    color: var(--error-700);
  }

  /* ==========================================================================
     Alerts
     ========================================================================== */
  .alert {
    padding: 16px;
    border-radius: 12px;
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }

  .alert svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
  }

  .alert-success {
    background: var(--success-50);
    color: var(--success-700);
    border: 1px solid var(--success-200);
  }

  .alert-warning {
    background: var(--warning-50);
    color: var(--warning-700);
    border: 1px solid var(--warning-200);
  }

  .alert-error {
    background: var(--error-50);
    color: var(--error-700);
    border: 1px solid var(--error-200);
  }

  .alert-info {
    background: var(--primary-50);
    color: var(--primary-700);
    border: 1px solid var(--primary-200);
  }

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

  .empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    color: var(--gray-300);
  }

  .empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
  }

  .empty-state-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    max-width: 280px;
    margin: 0 auto 24px;
    line-height: 1.5;
  }

  /* ==========================================================================
     Loading States
     ========================================================================== */
  .loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: var(--text-muted);
  }

  .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-600);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
  }

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

  /* Skeleton loading */
  .skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
  }

  @keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  /* ==========================================================================
     Calendar - Mobile
     ========================================================================== */
  .calendar-container {
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
  }

  .calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
  }

  .calendar-nav {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .calendar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .calendar-grid {
    display: grid;
    grid-template-columns: 50px repeat(7, 1fr);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .calendar-day-header {
    padding: 12px 8px;
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
  }

  .calendar-day {
    min-height: 80px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    position: relative;
  }

  .calendar-day-number {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
  }

  .calendar-day.today .calendar-day-number {
    width: 28px;
    height: 28px;
    background: var(--primary-600);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .calendar-event {
    font-size: 0.625rem;
    padding: 4px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ==========================================================================
     Quick Actions
     ========================================================================== */
  .quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
  }

  .quick-actions .btn {
    padding: 16px;
    flex-direction: column;
    gap: 8px;
    height: auto;
    text-align: center;
  }

  .quick-actions .btn svg {
    width: 24px;
    height: 24px;
  }

  /* ==========================================================================
     Filters
     ========================================================================== */
  .filters-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    margin-bottom: 16px;
  }

  .filters-row::-webkit-scrollbar {
    display: none;
  }

  .filter-select {
    flex: 0 0 auto;
    min-width: 140px;
  }

  /* ==========================================================================
     Search Input
     ========================================================================== */
  .search-input-wrapper {
    position: relative;
    width: 100%;
  }

  .search-input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 20px;
    height: 20px;
  }

  .search-input {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px 12px 48px;
    font-size: 16px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: white;
    transition: all 0.2s ease;
  }

  .search-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
  }

  /* ==========================================================================
     Competition Cards
     ========================================================================== */
  .competition-card {
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 12px;
    transition: all 0.2s ease;
  }

  .competition-card:active {
    transform: scale(0.99);
    background: var(--gray-50);
  }

  .competition-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
  }

  .competition-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
  }

  .competition-date {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .competition-body {
    padding: 16px;
  }

  .competition-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
  }

  .competition-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--text-secondary);
  }

  /* ==========================================================================
     Event Cards
     ========================================================================== */
  .event-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
    transition: all 0.2s ease;
  }

  .event-card:active {
    transform: scale(0.99);
    background: var(--gray-50);
  }

  .event-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }

  .event-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .event-code {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-600);
    background: var(--primary-50);
    padding: 4px 10px;
    border-radius: 20px;
  }

  /* ==========================================================================
     Availability Cards
     ========================================================================== */
  .availability-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
  }

  .availability-card:active {
    background: var(--gray-50);
  }

  .availability-card.booked {
    background: var(--success-50);
    border-color: var(--success-200);
  }

  .availability-time {
    text-align: center;
    min-width: 60px;
  }

  .availability-time-start {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .availability-time-end {
    font-size: 0.75rem;
    color: var(--text-muted);
  }

  .availability-info {
    flex: 1;
  }

  .availability-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
  }

  .availability-status {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* ==========================================================================
     Text Utilities
     ========================================================================== */
  a, .session-link, .detail-value {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* ==========================================================================
     Touch Feedback
     ========================================================================== */
  .touch-feedback {
    position: relative;
    overflow: hidden;
  }

  .touch-feedback::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.05);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
  }

  .touch-feedback:active::after {
    opacity: 1;
  }

  /* ==========================================================================
     Pull to Refresh Indicator
     ========================================================================== */
  .pull-to-refresh {
    position: absolute;
    top: -60px;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .pull-to-refresh.visible {
    opacity: 1;
  }

  .pull-to-refresh-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary-600);
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
}

/* ==========================================================================
   Small Mobile (up to 480px)
   ========================================================================== */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .student-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-container {
    height: 240px;
  }

  .chart-container canvas {
    height: 220px !important;
  }

  .section-title {
    font-size: 1.125rem;
  }

  .modal {
    max-height: 95vh;
    max-height: 95dvh;
  }

  .side-panel {
    width: 90%;
  }
}

/* ==========================================================================
   Tablet (481px - 768px)
   ========================================================================== */
@media (min-width: 481px) and (max-width: 768px) {
  .data-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   iOS Safe Area Support
   ========================================================================== */
@supports (padding-top: env(safe-area-inset-top)) {
  .dashboard-header {
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
  }

  .dashboard-main {
    padding-top: calc(56px + env(safe-area-inset-top)) !important;
  }

  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(64px + env(safe-area-inset-bottom));
  }

  .dashboard-content {
    padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important;
  }
}

/* ==========================================================================
   Dark Mode Support (if needed in future)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  /* Dark mode styles can be added here */
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
  .dashboard-header,
  .bottom-nav,
  .menu-toggle,
  .sidebar-overlay,
  .modal-overlay,
  .side-panel-overlay {
    display: none !important;
  }

  .dashboard-main {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-left: 0 !important;
  }
}


  /* ==========================================================================
     Compact Spacing (Mobile)
     ========================================================================== */
  .dashboard-content { padding: 12px !important; }
  .section { margin-bottom: 16px !important; }
  .section-header { gap: 10px !important; margin-bottom: 12px !important; }
  .section-title { font-size: 1.05rem !important; }
  .section-subtitle { font-size: 0.85rem !important; }

  .card, .stat-card, .nudge-card, .calendar-container, .alert {
    border-radius: 16px !important;
  }

  .card-body { padding: 12px !important; }
  .stat-card { padding: 12px !important; }

  .btn { padding: 10px 12px !important; border-radius: 14px !important; }
  .btn.btn-sm { padding: 8px 10px !important; border-radius: 12px !important; font-size: 0.85rem !important; }
  .btn-icon { margin-right: 8px !important; }
  .view-header { gap: 10px !important; }
  .view-header-actions, .section-actions { gap: 8px !important; flex-wrap: wrap !important; }
  .view-header-actions .btn, .section-actions .btn { width: auto; }

  /* Prevent any child from forcing page horizontal scroll */
  .dashboard-main, .dashboard-content, .section, .card, .stat-card, .nudge-card { max-width: 100% !important; overflow-x: clip; }

  /* ==========================================================================
     Nudges (Students due + Cycles close) - App-style list cards
     ========================================================================== */
  .nudge-stack { display: grid; grid-template-columns: 1fr; gap: 12px; }
  .nudge-card { background: #fff; border: 1px solid var(--border); padding: 12px; }
  .nudge-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
  .nudge-head-left { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
  .nudge-icon { width: 36px; height: 36px; border-radius: 12px; background: var(--gray-100); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
  .nudge-title { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
  .nudge-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; line-height: 1.2; }
  .nudge-badge { flex: 0 0 auto; border-radius: 999px; padding: 6px 10px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }

  .nudge-list { display: flex; flex-direction: column; gap: 8px; }
  .nudge-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid rgba(0,0,0,0.06); border-radius: 14px; background: var(--gray-50); }
  .nudge-row-main { min-width: 0; flex: 1; }
  .nudge-row-name { font-weight: 700; font-size: 0.92rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nudge-row-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
  .nudge-row-action { flex: 0 0 auto; }

  .chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; font-size: 0.75rem; background: #fff; border: 1px solid rgba(0,0,0,0.08); color: var(--text-secondary); max-width: 100%; }
  .chip-warn { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.25); color: var(--warning-700); }
  .chip-danger { background: rgba(239, 68, 68, 0.10); border-color: rgba(239, 68, 68, 0.25); color: var(--error-600); }
  .nudge-empty { padding: 12px; color: var(--text-muted); font-size: 0.85rem; background: var(--gray-50); border-radius: 14px; border: 1px dashed rgba(0,0,0,0.10); }

  /* ==========================================================================
     Calendar - Scroll inside the calendar block (both directions)
     ========================================================================== */
  #calendar-grid-container {
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    max-height: 70vh;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #fff;
  }
  .calendar-grid {
    min-width: 860px; /* allows horizontal swipe to access all days */
  }
  .calendar-time-column {
    position: sticky;
    left: 0;
    z-index: 5;
    background: #fff;
  }
  .calendar-day-column .calendar-day-header {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #fff;
  }

  /* ==========================================================================
     Solve Data - Table scroll inside card, not the page
     ========================================================================== */
  .table-responsive {
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    max-height: 70vh;
    border-radius: 14px;
  }
  .table {
    min-width: 820px;
  }
  /* Tables (Solve Data etc.): scroll inside card instead of breaking layout */
  .table-wrapper{
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .table-wrapper table{
    min-width: 640px;
  }




/* ======================================================================
   v14 mobile polish overrides
   ====================================================================== */
@media (max-width: 768px) {
  .dashboard-topbar {
    background: rgba(248, 252, 252, 0.88) !important;
    border-bottom: 1px solid rgba(255,255,255,0.75) !important;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06) !important;
  }

  .dashboard-sidebar {
    background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(246,252,251,0.95) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-left-color: rgba(255,255,255,0.75);
  }

  .sidebar-brand {
    padding: 22px 18px;
  }

  .sidebar-link {
    border-radius: 14px;
    margin-bottom: 6px;
  }

  .dashboard-content {
    padding: 10px 14px 20px !important;
  }

  .section-title {
    font-size: 1.18rem !important;
    letter-spacing: -0.03em;
  }

  .section-subtitle,
  .page-subtitle {
    font-size: 0.82rem !important;
  }

  .topbar-icon,
  .header-btn {
    border-radius: 14px;
    background: rgba(255,255,255,0.82);
    border: 1px solid rgba(15,23,42,0.06);
    box-shadow: 0 8px 18px rgba(15,23,42,0.05);
  }

  .bottom-nav-item {
    border-radius: 16px;
    transition: transform 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
  }

  .bottom-nav-item.active {
    background: linear-gradient(135deg, rgba(15,157,148,0.16), rgba(255,255,255,0.95));
    box-shadow: 0 10px 20px rgba(15,157,148,0.10);
  }

  .calendar-container,
  .chart-card,
  .table-container {
    overflow: hidden;
  }
}

  .live-schedule-grid{grid-template-columns:1fr !important;}
  .live-board-tabs{flex-wrap:wrap;}

.live-schedule-date-tabs{display:flex;gap:10px;flex-wrap:wrap;margin:0 0 14px}.live-schedule-date-tab{border:1px solid var(--border);background:var(--card);color:var(--muted-foreground);padding:8px 12px;border-radius:999px;font-weight:700;cursor:pointer}.live-schedule-date-tab.active{background:rgba(20,184,166,.12);color:#0f766e;border-color:rgba(20,184,166,.35)}.live-schedule-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin-bottom:18px}.live-schedule-card{border:1px solid var(--border);background:var(--card);border-radius:16px;padding:12px;text-align:left;display:flex;flex-direction:column;gap:7px;min-height:128px;cursor:pointer;box-shadow:0 8px 22px rgba(15,23,42,.05);transition:transform .16s ease,box-shadow .16s ease,border-color .16s ease}.live-schedule-card:hover{transform:translateY(-1px);box-shadow:0 10px 24px rgba(15,23,42,.08)}.live-schedule-card.has-mine{border-color:rgba(20,184,166,.45);background:linear-gradient(180deg,rgba(20,184,166,.06),#fff 45%)}.live-schedule-card.has-mine .live-schedule-event,.live-schedule-card.has-mine .live-schedule-round{color:#0f172a}.live-schedule-live-badge{font-size:10px;font-weight:800;letter-spacing:.08em;color:#b91c1c;background:rgba(239,68,68,.12);border-radius:999px;padding:4px 7px}.live-schedule-time{font-size:13px;color:var(--foreground);font-weight:800}.live-schedule-event{font-size:15px;font-weight:800;color:var(--foreground);line-height:1.22}.live-schedule-round{font-size:13px;font-weight:700;color:#475569}.live-schedule-room{font-size:11px;color:var(--muted-foreground)}.live-schedule-students{display:flex;flex-wrap:wrap;gap:6px;margin-top:auto}.live-schedule-students span{font-size:11px;font-weight:800;padding:5px 8px;border-radius:999px;background:rgba(20,184,166,.12);color:#0f766e}.live-results-table-clean tbody tr.mine td{background:rgba(20,184,166,.10)!important}.live-results-table-clean tbody tr.mine td:first-child{box-shadow:inset 4px 0 0 #14b8a6}.live-rounds-now{padding:10px 12px;border:1px solid rgba(20,184,166,.18);border-radius:16px;background:linear-gradient(180deg,rgba(20,184,166,.06),rgba(255,255,255,.9));}.live-now-chip{border:1px solid rgba(20,184,166,.28);background:#fff;color:#0f172a;padding:8px 12px;border-radius:999px;font-weight:700;cursor:pointer}@media (max-width: 1100px){.live-schedule-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (max-width: 700px){.live-schedule-grid{grid-template-columns:1fr}.live-schedule-date-tabs{overflow:auto;flex-wrap:nowrap;padding-bottom:4px}}

/* live results final typography pass */
.live-results-table-wrap{width:100%;border-radius:18px;overflow:auto}
.live-results-table-clean{width:100%;table-layout:fixed;border-collapse:separate;border-spacing:0}
.live-results-table-clean th,
.live-results-table-clean td{padding:9px 10px!important;font-size:12.5px;vertical-align:middle}
.live-results-table-clean thead th{font-size:10.5px;letter-spacing:.08em;text-transform:uppercase;color:#64748b;font-weight:800}
.live-results-table-clean tbody td{border-top:1px solid rgba(226,232,240,.72)}
.live-results-table-clean tbody tr:first-child td{border-top:0}
.live-results-table-clean th:first-child,
.live-results-table-clean td:first-child{width:64px;text-align:center;font-weight:800}
.live-results-table-clean th:nth-child(2),
.live-results-table-clean td:nth-child(2){width:clamp(190px,38vw,380px);white-space:normal}
.live-results-table-clean th:nth-child(n+3):not(:last-child),
.live-results-table-clean td:nth-child(n+3):not(:last-child),
.live-results-table-clean th:last-child,
.live-results-table-clean td:last-child{text-align:center}
.live-attempt-col{width:64px}
.live-name-cell{max-width:none;width:100%;min-width:0;display:flex;flex-direction:column;gap:3px}
.live-name-trigger{font-size:13px;line-height:1.28;font-weight:800;max-width:100%;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;white-space:normal;text-align:left}
.live-name-sub{font-size:10.5px;line-height:1.2;color:#64748b;letter-spacing:.01em}
.live-profile-section h4{font-size:16px!important;line-height:1.2;margin:10px 0 6px}
.live-board-title{font-size:20px;line-height:1.12;letter-spacing:-.02em}
.table-title-row{padding:14px 16px 8px}
.table-title-row h4{font-size:14px;letter-spacing:-.01em}
@media (max-width: 900px){
  .live-results-table-clean{table-layout:auto}
  .live-results-table-clean th,
  .live-results-table-clean td{padding:8px 8px!important;font-size:11.5px}
  .live-results-table-clean th:nth-child(2),
  .live-results-table-clean td:nth-child(2){width:auto;min-width:140px}
  .live-name-trigger{font-size:12px;-webkit-line-clamp:2}
  .live-name-sub{font-size:10px}
}
