/**
 * Skill Shiksha CTO Mobile Responsive UI Engine
 * Pure CSS • Apple HIG & Material Design 3 Fluid Architecture
 * Global Mobile Breakpoints: 320px, 360px, 375px, 390px, 412px, 430px, 768px, 1024px, 1280px+
 * Zero Horizontal Blowout • Zero Feature Degradation • 100% Touch-Optimized
 */

/* ==========================================================================
   1. GLOBAL RESET & OVERFLOW PREVENTION FOUNDATION
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box !important;
}

html, body {
  width: 100% !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  position: relative !important;
  -webkit-text-size-adjust: 100% !important;
}

img, video, iframe {
  max-width: 100%;
  height: auto;
}

/* ==========================================================================
   2. APP SHELL & PORTAL LAYOUT (< 1024px)
   Desktop layout (> 1024px) remains 100% untouched using uni.css baseline
   ========================================================================== */
@media (max-width: 1024px) {
  .portal-layout {
    display: flex !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    position: relative !important;
  }

  .portal-main-area {
    margin-left: 0 !important;
    width: 100% !important;
    flex: 1 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .portal-content-area {
    flex: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 16px 16px !important;
  }

  /* Responsive Portal Top Bar (Header) on Tablet & Mobile */
  .portal-top-bar {
    height: 60px !important;
    padding: 0 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: rgba(255, 255, 255, 0.88) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border-bottom: 1px solid var(--apple-border, #E2E8F0) !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 90 !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  [data-theme="dark"] .portal-top-bar {
    background: rgba(28, 28, 30, 0.85) !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
  }
}

.portal-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 8px;
  border: 1px solid var(--apple-border, #E2E8F0);
  background: var(--apple-bg-surface, #FFFFFF);
  color: var(--apple-label-primary, #0F172A);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease;
}

.portal-menu-toggle:active {
  background: var(--apple-bg-hover, rgba(0,0,0,0.05));
}

/* ==========================================================================
   4. MOBILE SIDEBAR DRAWER (< 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  .portal-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: -320px !important;
    width: 280px !important;
    max-width: 86vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    background: var(--apple-bg-surface, #FFFFFF) !important;
    z-index: 100000 !important;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.3) !important;
    transition: left 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  [data-theme="dark"] .portal-sidebar {
    background: #1C1C1E !important;
  }

  .portal-sidebar.open {
    left: 0 !important;
  }

  .portal-menu-toggle {
    display: inline-flex !important;
  }

  .portal-sidebar-collapse-btn {
    display: none !important;
  }

  .portal-sidebar-header .portal-menu-toggle {
    display: inline-flex !important;
    color: var(--apple-label-primary, #0F172A) !important;
  }

  .portal-backdrop {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(15, 23, 42, 0.5) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: 99990 !important;
    display: none !important;
  }

  .portal-backdrop.open {
    display: block !important;
  }

  .portal-content-area {
    padding: 16px 20px !important;
  }

  .portal-top-bar {
    padding: 0 16px !important;
  }
}

/* ==========================================================================
   5. MOBILE TOP BAR ADJUSTMENTS (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .portal-top-bar {
    height: 56px !important;
    padding: 0 12px !important;
    gap: 8px !important;
  }

  .portal-top-bar > div:first-child {
    min-width: 0 !important;
    flex: 1 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    overflow: hidden !important;
  }

  .portal-top-greeting {
    font-size: 0.95rem !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
  }

  .portal-top-subtitle {
    font-size: 0.68rem !important;
    gap: 4px !important;
  }

  .portal-top-subtitle span:first-child {
    display: none !important; /* Hide long date string on mobile topbar */
  }

  .portal-top-subtitle span:nth-child(2) {
    display: none !important; /* Hide bullet dot */
  }

  .portal-top-bar > div:last-child {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
  }

  /* Compact Pill Search Icon Trigger on Mobile */
  .pill-search-bar {
    min-width: 34px !important;
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    background: var(--apple-bg-secondary, #FAFAFC) !important;
    border: 1px solid var(--apple-border, #E2E8F0) !important;
  }

  .pill-search-bar input {
    display: none !important;
  }

  .pill-search-icon {
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.9rem !important;
  }

  .icon-pill-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    flex-shrink: 0 !important;
  }

  /* Compact Monogram Avatar on Mobile */
  .user-avatar-pill {
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  .user-avatar-pill > span {
    display: none !important; /* Hide long user text name */
  }

  .user-avatar-circle {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.75rem !important;
  }
}

@media (max-width: 480px) {
  .portal-content-area {
    padding: 12px 12px 36px !important;
  }

  .portal-top-bar {
    padding: 0 10px !important;
    gap: 6px !important;
  }

  .icon-pill-btn[title="Messages"] {
    display: none !important; /* Keep only essential Search, Notifications, Avatar on ultra-small screens */
  }
}

/* ==========================================================================
   6. PAGE HEADERS & ACTION BARS (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .dashboard-header,
  .page-header,
  [style*="display:flex;justify-content:space-between;align-items:flex-start"],
  [style*="display: flex; justify-content: space-between; align-items: flex-start"] {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
    width: 100% !important;
  }

  .dashboard-title,
  h1[style*="font-size:1.75rem"],
  h1[style*="font-size: 1.75rem"],
  h1 {
    font-size: clamp(1.3rem, 5.5vw, 1.75rem) !important;
    line-height: 1.25 !important;
    letter-spacing: -0.02em !important;
    word-break: break-word !important;
  }

  .dashboard-subtitle,
  p[style*="font-size:0.86rem"],
  p[style*="font-size: 0.86rem"] {
    font-size: 0.82rem !important;
    line-height: 1.4 !important;
    margin-top: 4px !important;
  }

  /* Header action buttons container */
  .dashboard-header > div > div:last-child,
  [style*="display:flex;gap:8px;flex-wrap:wrap"],
  [style*="display: flex; gap: 8px; flex-wrap: wrap"] {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
    margin-top: 4px !important;
  }

  .btn {
    min-height: 38px !important;
    padding: 7px 14px !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    border-radius: 9px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* ==========================================================================
   7. UNIVERSAL GRID REFLOW & HERO STATS (ALL VIEWS)
   ========================================================================== */
/* Tablet Grids (< 1024px) */
@media (max-width: 1024px) {
  [style*="grid-template-columns:repeat(6"],
  [style*="grid-template-columns: repeat(6"],
  [style*="grid-template-columns:repeat(5"],
  [style*="grid-template-columns: repeat(5"] {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }

  [style*="grid-template-columns: 1.8fr 1.2fr"],
  [style*="grid-template-columns:1.8fr 1.2fr"],
  [style*="grid-template-columns: 1.6fr 1fr"],
  [style*="grid-template-columns:1.6fr 1fr"],
  [style*="grid-template-columns: 1.5fr 1fr"],
  [style*="grid-template-columns:1.5fr 1fr"],
  [style*="grid-template-columns: 1.4fr 1fr"],
  [style*="grid-template-columns: 1.2fr 1fr"],
  [style*="grid-template-columns: 1fr 1.6fr"],
  [style*="grid-template-columns: 1fr 1.8fr"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .hero-metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }
}

/* Mobile Grids (< 768px) */
@media (max-width: 768px) {
  /* Automatically transform 4-col, 5-col, 6-col inline grids into crisp 2-column mobile grids */
  [style*="grid-template-columns:repeat(6"],
  [style*="grid-template-columns: repeat(6"],
  [style*="grid-template-columns:repeat(5"],
  [style*="grid-template-columns: repeat(5"],
  [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns: repeat(auto-fit, minmax(2"],
  [style*="grid-template-columns:repeat(auto-fit, minmax(2"],
  [style*="grid-template-columns: repeat(auto-fit, minmax(1"],
  [style*="grid-template-columns:repeat(auto-fit, minmax(1"],
  [style*="grid-template-columns: repeat(auto-fill, minmax(3"],
  [style*="grid-template-columns:repeat(auto-fill, minmax(3"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .hero-metric-strip {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  /* Split sidebars and forms collapse to 1 column */
  [style*="grid-template-columns: 1.5fr 1fr 2fr"],
  [style*="grid-template-columns: 1.8fr 1.2fr"],
  [style*="grid-template-columns: 1.6fr 1fr"],
  [style*="grid-template-columns: 1.5fr 1fr"],
  [style*="grid-template-columns: 1.4fr 1fr"],
  [style*="grid-template-columns: 1.2fr 1fr"],
  [style*="grid-template-columns: 1fr 1.6fr"],
  [style*="grid-template-columns: 1fr 1.8fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .dashboard-middle-row,
  .dashboard-bottom-row {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
}

/* Ultra-Compact (< 380px) */
@media (max-width: 380px) {
  [style*="grid-template-columns:repeat(6"],
  [style*="grid-template-columns: repeat(6"],
  [style*="grid-template-columns:repeat(5"],
  [style*="grid-template-columns: repeat(5"],
  [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns: repeat(4"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
}

/* ==========================================================================
   8. KPI CARD MOBILE GEOMETRY & TYPOGRAPHY
   ========================================================================== */
@media (max-width: 1024px) {
  .kpi-card-deluxe,
  .cobalt-card,
  .stat-card-deluxe,
  .card {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}

@media (max-width: 768px) {
  .kpi-card-deluxe,
  .cobalt-card,
  .stat-card-deluxe {
    padding: 12px 14px !important;
    border-radius: 14px !important;
    min-height: 105px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    overflow: hidden !important;
  }

  .kpi-header-row {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 6px !important;
    margin-bottom: 4px !important;
  }

  .kpi-label-title {
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    word-break: break-word !important;
    color: var(--apple-label-secondary, #64748B) !important;
  }

  .kpi-metric-value {
    font-size: clamp(1.2rem, 5vw, 1.65rem) !important;
    font-weight: 800 !important;
    line-height: 1.15 !important;
    margin: 4px 0 !important;
    font-variant-numeric: tabular-nums !important;
    letter-spacing: -0.02em !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .kpi-footer-row {
    margin-top: 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 4px !important;
    flex-wrap: wrap !important;
  }

  .kpi-delta-pill {
    font-size: 0.68rem !important;
    padding: 2px 6px !important;
    border-radius: 999px !important;
    white-space: nowrap !important;
  }

  .cobalt-icon-badge {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    border-radius: 8px !important;
    font-size: 0.85rem !important;
  }

  .kpi-date-term-card {
    grid-column: 1 / -1 !important; /* Date Term card spans full row on mobile */
    padding: 12px 14px !important;
    border-radius: 14px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
  }

  .kpi-date-day-num {
    font-size: 1.4rem !important;
    line-height: 1 !important;
  }

  .kpi-date-month-txt {
    font-size: 0.72rem !important;
  }
}

/* ==========================================================================
   9. FACETED SEARCH & FILTER BAR (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .faceted-filter-bar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px !important;
    border-radius: 14px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    position: relative !important;
    margin-bottom: 16px !important;
  }

  /* Hide stray absolute search icons in filter bars */
  .faceted-filter-bar > svg,
  .faceted-filter-bar > span[style*="position: absolute"],
  .faceted-filter-bar > span[style*="position:absolute"] {
    display: none !important;
  }

  .faceted-search-input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
    height: 42px !important;
    font-size: 15px !important;
    border-radius: 10px !important;
    padding: 8px 12px 8px 36px !important;
    background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2394a3b8' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 12px center !important;
  }

  .filter-divider {
    display: none !important;
  }

  .filter-pill-group {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .filter-pill {
    width: 100% !important;
    height: 38px !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    padding: 6px 26px 6px 10px !important;
    border-radius: 8px !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .faceted-filter-bar > button[type="submit"],
  .faceted-filter-bar > .btn-primary {
    width: 100% !important;
    height: 38px !important;
    margin-top: 2px !important;
  }

  .filter-clear-link {
    text-align: center !important;
    width: 100% !important;
    display: block !important;
    font-size: 0.78rem !important;
    padding: 4px 0 !important;
  }
}

/* ==========================================================================
   10. TABLES & DATA CONTAINER SCROLL CONTAINMENT
   ========================================================================== */
.card,
.data-table-container,
.table-responsive {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
  border-radius: 14px !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

@media (max-width: 768px) {
  table {
    min-width: 540px !important; /* Forces clean internal scroll without page blowout */
  }

  thead th {
    padding: 9px 12px !important;
    font-size: 0.7rem !important;
  }

  tbody td {
    padding: 10px 12px !important;
    font-size: 0.8rem !important;
  }

  /* Table card header strip */
  .card > div:first-child[style*="border-bottom:1px solid"],
  .card > div:first-child[style*="border-bottom: 1px solid"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    padding: 12px 14px !important;
  }

  .card > div:first-child[style*="border-bottom"] > div:last-child {
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }
}

/* ==========================================================================
   11. FORMS & TOUCH INPUTS
   ========================================================================== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
select,
textarea {
  max-width: 100% !important;
  box-sizing: border-box !important;
  font-size: 16px !important; /* 16px prevents iOS automatic zoom on focus */
  border-radius: 8px !important;
}

@media (max-width: 640px) {
  .form-group,
  .form-row {
    width: 100% !important;
  }

  .form-row,
  [style*="display: grid; grid-template-columns: 1fr 1fr"],
  [style*="display:grid;grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}

/* ==========================================================================
   12. MODALS & POPUPS
   ========================================================================== */
@media (max-width: 768px) {
  .modal-dialog-deluxe,
  .destructive-modal-box,
  .command-palette-modal {
    width: calc(100vw - 20px) !important;
    max-width: 500px !important;
    max-height: 88vh !important;
    max-height: 88dvh !important;
    margin: 16px auto !important;
    border-radius: 16px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .command-palette-input {
    font-size: 16px !important;
  }

  .command-kbd {
    display: none !important;
  }
}

/* ==========================================================================
   13. CHARTS, SVG & MAP CONTAINERS
   ========================================================================== */
@media (max-width: 768px) {
  .apple-world-map-wrap,
  #worldMapContainer,
  #leafletMapContainer {
    height: 300px !important;
    min-height: 280px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .osm-metric-switcher,
  .osm-region-pills {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
    width: 100% !important;
  }

  .osm-metric-btn,
  .osm-region-pill {
    font-size: 0.72rem !important;
    padding: 3px 8px !important;
  }
}

/* ==========================================================================
   14. PUBLIC WEBSITE PAGES (NAVBAR, HERO, CARDS & MARKETPLACE)
   ========================================================================== */
@media (max-width: 1024px) {
  .public-nav-links {
    display: none !important;
  }

  .public-mobile-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--apple-border, #E2E8F0);
    background: transparent;
    color: var(--apple-label-primary, #0F172A);
    cursor: pointer;
  }

  .marketplace-grid,
  [style*="grid-template-columns: 240px 1fr"],
  [style*="grid-template-columns: 260px 1fr"],
  [style*="grid-template-columns: 280px 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
}

@media (max-width: 768px) {
  .public-navbar-container {
    padding: 0 14px !important;
  }

  .public-nav-actions .btn {
    padding: 6px 12px !important;
    font-size: 0.78rem !important;
  }

  .public-footer-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  .hero-section {
    padding: 32px 14px !important;
  }

  .hero-section h1 {
    font-size: 1.8rem !important;
    line-height: 1.2 !important;
  }

  /* Supporting 5-Card Grid: 2-2-1 layout on mobile */
  .kpi-supporting-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .kpi-supporting-grid > *:last-child:nth-child(odd) {
    grid-column: 1 / -1 !important;
  }

  /* Ecosystem completion card full span on mobile */
  .hero-metric-strip > .card:last-child {
    grid-column: 1 / -1 !important;
  }

  /* Public Search Bar on /programs and /workshops */
  form[action="/programs"],
  form[action="/workshops"] {
    flex-wrap: wrap !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  form[action="/programs"] > div:first-of-type,
  form[action="/workshops"] > div:first-of-type {
    width: 100% !important;
    flex: 1 1 100% !important;
  }

  form[action="/programs"] > button,
  form[action="/programs"] > a,
  form[action="/workshops"] > button,
  form[action="/workshops"] > a {
    flex: 1 !important;
    justify-content: center !important;
  }

  /* Category pills segmented control on mobile */
  .segmented-control {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    padding: 4px !important;
    border-radius: 9999px !important;
    gap: 4px !important;
  }

  .category-tab-pill {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
}

/* Workshop & Program Card Stacking (< 640px) */
@media (max-width: 640px) {
  [style*="grid-template-columns: repeat(auto-fill, minmax(3"],
  [style*="grid-template-columns:repeat(auto-fill, minmax(3"],
  [style*="grid-template-columns: repeat(auto-fit, minmax(3"],
  [style*="grid-template-columns:repeat(auto-fit, minmax(3"],
  [style*="grid-template-columns: repeat(auto-fit, minmax(280px"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Trainer Calendar Mobile Support */
  #calendarMonthView {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
  }

  #calendarMonthView > div:first-child,
  #calendarDaysGrid {
    min-width: 480px !important;
  }

  #calendarWeekGrid {
    grid-template-columns: 1fr !important;
  }

  /* Student Skill Journey Horizontal Scroll */
  .skill-blueprint-stage-wrapper {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: 14px !important;
  }
}

/* ==========================================================================
   15. ROLE-AWARE MOBILE BOTTOM NAVIGATION BAR & REFINED CARDS (< 768px)
   ========================================================================== */
.portal-mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .portal-mobile-bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 60px !important;
    background: rgba(255, 255, 255, 0.94) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
    z-index: 9999 !important;
    align-items: center !important;
    justify-content: space-around !important;
    padding: 0 4px !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03) !important;
  }

  [data-theme="dark"] .portal-mobile-bottom-nav {
    background: rgba(28, 28, 30, 0.94) !important;
    border-top-color: rgba(255, 255, 255, 0.08) !important;
  }

  .portal-mobile-tab {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
    height: 100% !important;
    text-decoration: none !important;
    color: #8E8E93 !important;
    font-size: 0.65rem !important;
    font-weight: 600 !important;
    gap: 2px !important;
    transition: all 0.15s ease !important;
  }

  .portal-mobile-tab-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 20px !important;
  }

  .portal-mobile-tab.active {
    color: #0071E3 !important;
    font-weight: 700 !important;
  }

  .portal-mobile-tab.active .portal-mobile-tab-icon {
    transform: translateY(-1px) !important;
  }

  .portal-mobile-tab-label {
    letter-spacing: -0.01em !important;
    white-space: nowrap !important;
  }

  /* Safe content bottom spacing so bottom nav never overlaps action buttons */
  .portal-content-area,
  .main-content {
    padding-bottom: 84px !important;
  }

  /* Refined Student Cockpit & Dashboard Cards (< 768px) */
  .career-roles-grid,
  [style*="grid-template-columns: repeat(auto-fit, minmax(175px"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }

  .career-role-card {
    padding: 16px 12px !important;
    border-radius: 14px !important;
    min-height: auto !important;
  }

  .career-role-card h4 {
    font-size: 0.84rem !important;
    min-height: auto !important;
    margin-bottom: 4px !important;
  }

  .career-role-card p {
    font-size: 0.72rem !important;
    min-height: auto !important;
    line-height: 1.3 !important;
  }

  .skill-inventory-grid,
  [style*="grid-template-columns: repeat(auto-fill, minmax(220px"] {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .skill-inv-card {
    padding: 10px 12px !important;
    border-radius: 10px !important;
  }

}

/* ==========================================================================
   16. PUBLIC HOME & LANDING PAGE MOBILE FIXES (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  /* Goal grid: force 2-column instead of auto-fit which can blowout */
  .goal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
    margin-bottom: 36px !important;
  }

  /* Curated opportunity cards: 1-column (320px minmax causes blowout on 390px) */
  .curated-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  /* Public hero section vertical rhythm */
  .public-hero {
    padding: 32px 16px 24px !important;
    text-align: center !important;
  }

  .public-hero-title {
    font-size: clamp(1.55rem, 7vw, 2.2rem) !important;
    line-height: 1.22 !important;
    letter-spacing: -0.03em !important;
    word-break: break-word !important;
  }

  .public-hero-subtitle {
    font-size: 0.9rem !important;
    line-height: 1.55 !important;
    margin-top: 10px !important;
  }

  .public-hero-ctas {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 340px !important;
    margin: 16px auto 0 !important;
  }

  .public-hero-ctas .btn {
    width: 100% !important;
    justify-content: center !important;
    font-size: 0.95rem !important;
    min-height: 44px !important;
  }

  /* Stats ribbon: flex wrap and reduce gap */
  .public-stats-ribbon {
    gap: 14px 24px !important;
    padding: 10px 16px !important;
    border-radius: 14px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    justify-content: center !important;
  }

  .public-stat-num {
    font-size: 1.05rem !important;
  }

  .public-stat-label {
    font-size: 0.68rem !important;
  }

  /* Trust strip: tight 2-col wrap */
  .trust-strip {
    gap: 12px 20px !important;
    padding: 14px 16px !important;
    margin-bottom: 32px !important;
    justify-content: flex-start !important;
  }

  .trust-item {
    font-size: 0.78rem !important;
  }

  /* Section headers compact on mobile */
  .section-title-clean {
    font-size: clamp(1.3rem, 5.5vw, 1.75rem) !important;
    word-break: break-word !important;
  }

  .section-subtitle-clean {
    font-size: 0.84rem !important;
  }

  /* Goal card padding reduction on mobile */
  .goal-card {
    padding: 16px 14px !important;
  }

  .goal-icon-box {
    width: 38px !important;
    height: 38px !important;
    font-size: 1.1rem !important;
    margin-bottom: 10px !important;
  }

  .goal-title {
    font-size: 0.95rem !important;
    margin-bottom: 4px !important;
  }

  .goal-desc {
    font-size: 0.78rem !important;
    margin-bottom: 10px !important;
  }

  /* Clean opp card (curated programs) on mobile */
  .clean-opp-card {
    padding: 16px 14px !important;
  }

  /* Workshop masonry: 1 col on mobile */
  .workshop-masonry-grid,
  .masterclass-list {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  /* Container padding reduction for tighter mobile layout */
  .container {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}

/* ==========================================================================
   17. STUDENT IDENTITY HERO & OVERFLOW FIXES (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  /* Remove forced min-widths that cause horizontal overflow */
  [style*="min-width: 300px"],
  [style*="min-width:300px"] {
    min-width: 0 !important;
  }

  [style*="min-width: 220px"],
  [style*="min-width:220px"] {
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Ensure all cards clip content cleanly */
  .card,
  .cobalt-card,
  .stat-card-deluxe,
  .kpi-date-term-card {
    overflow: hidden !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
  }

  /* Hero-metric-strip: 2-column on mobile (override uni.css 1fr) */
  .hero-metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  /* Date term card: full-width bottom of 2-col grid */
  .kpi-date-term-card {
    grid-column: 1 / -1 !important;
  }

  /* Skill Journey section: reduce padding for stage room */
  #skillJourneySection {
    padding: 20px 14px 20px !important;
  }

  /* Skill Journey control buttons: Watch full-width, others 50/50 */
  #btnWatchJourney {
    flex: 1 1 100% !important;
    justify-content: center !important;
  }

  #btnSoundToggle,
  #btnReplayJourney {
    flex: 1 !important;
    justify-content: center !important;
    font-size: 0.78rem !important;
  }
}

/* ==========================================================================
   18. iOS SAFE AREA SUPPORT FOR BOTTOM NAV DOCK
   ========================================================================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .portal-mobile-bottom-nav {
      padding-bottom: env(safe-area-inset-bottom) !important;
      height: calc(60px + env(safe-area-inset-bottom)) !important;
    }

    .portal-content-area,
    .main-content {
      padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important;
    }
  }
}

/* ==========================================================================
   19. UNIVERSITY, TRAINER & PARTNER PANEL MOBILE FIXES (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  /* Faculty panel: student info row stacking */
  .faculty-student-card {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  /* Admin payments: filter buttons row wrapping */
  .payments-filter-row {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Message center: full-width input */
  .message-input-row {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .message-input-row input,
  .message-input-row textarea {
    width: 100% !important;
  }

  /* University department / mentor grid: 1-col */
  [style*="grid-template-columns: repeat(auto-fill, minmax(260px"],
  [style*="grid-template-columns: repeat(auto-fill, minmax(250px"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Trainer calendar: horizontal scroll container */
  .trainer-calendar-wrapper,
  #trainerCalendarSection {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
  }

  /* Partner metrics: 2-col */
  .partner-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
}

/* ==========================================================================
   20. STUDENT DASHBOARD — DEFINITIVE CLASS-BASED MOBILE RECOMPOSITION
   Target viewports: 320px, 360px, 375px, 390px, 412px, 430px
   ROOT CAUSE FIX: All overrides use semantic classes added to the PHP.
   Replaces unreliable inline-style attribute selectors.
   ========================================================================== */

/* ── 20a. STUDENT IDENTITY HERO CARD ────────────────────────────────────── */
@media (max-width: 768px) {
  /* Hero card padding: comfortable breathing room on small screens */
  .student-hero-card {
    padding: 20px 18px !important;
  }

  /* Main row: COLUMN stack — kills the side-by-side squeeze */
  .student-hero-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 16px !important;
    justify-content: flex-start !important;
  }

  /* Identity left section: row (avatar beside name) — no min-width blowout */
  .student-hero-identity {
    flex: none !important;
    min-width: 0 !important;
    width: 100% !important;
    align-items: flex-start !important;
    gap: 14px !important;
  }

  /* Avatar: fixed size, never shrinks, never causes layout issues */
  .student-hero-avatar {
    flex-shrink: 0 !important;
  }

  /* Text block beside avatar: shrinks to fill, never overflows */
  .student-hero-info {
    flex: 1 !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  /* Student name h1: readable, never breaks character-by-character */
  .student-hero-info h1 {
    font-size: clamp(1.3rem, 6vw, 1.55rem) !important;
    line-height: 1.25 !important;
    letter-spacing: -0.025em !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    white-space: normal !important;
    margin: 0 !important;
  }

  /* Badge/university row: wrap naturally, never force wide */
  .student-hero-info > div:first-child {
    flex-wrap: wrap !important;
    gap: 4px 8px !important;
  }

  /* Degree/year row: allow text to wrap between full words */
  .student-hero-info > div:last-child,
  .student-hero-info > div:nth-child(3) {
    flex-wrap: wrap !important;
    gap: 4px 8px !important;
  }

  .student-hero-info span {
    overflow-wrap: break-word !important;
    word-break: normal !important;
    max-width: 100% !important;
  }

  /* Profile Readiness: full width below identity, not beside it */
  .student-hero-readiness {
    width: 100% !important;
    flex-wrap: nowrap !important;
  }

  /* Readiness card itself: full width, no min-width forcing overflow */
  .student-readiness-card {
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 12px 14px !important;
    flex: 1 !important;
  }
}

/* ── 20b. TODAY'S FOCUS — ACTION ITEMS ──────────────────────────────────── */
@media (max-width: 640px) {
  /* Card padding tighter */
  .card[style*="border-left: 4.5px solid"] {
    padding: 18px 16px !important;
  }

  /* Action item row: stack icon+info above button */
  .card [style*="display: flex; justify-content: space-between; align-items: center; padding: 14px 18px"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .card [style*="display: flex; justify-content: space-between; align-items: center; padding: 14px 18px"] > div:last-child {
    width: 100% !important;
  }

  .card [style*="display: flex; justify-content: space-between; align-items: center; padding: 14px 18px"] > div:last-child .btn {
    width: 100% !important;
    justify-content: center !important;
  }
}

/* ── 20c. SKILL JOURNEY SECTION ─────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Section header row: stack controls below title */
  #skillJourneySection > div[style*="display: flex; justify-content: space-between"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  /* Control buttons container: 2-per-row grid */
  #skillJourneySection [style*="display: flex; gap: 8px; align-items: center; flex-wrap: wrap"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* Watch Journey button: full width primary CTA */
  #btnWatchJourney {
    grid-column: 1 / -1 !important;
    justify-content: center !important;
  }

  #btnSoundToggle,
  #btnReplayJourney {
    justify-content: center !important;
  }

  /* Career Roles anchor button */
  #skillJourneySection a.btn-outline {
    grid-column: 1 / -1 !important;
    justify-content: center !important;
  }
}

/* ── 20d. CAREER ROLES GRID ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* 2-column roles grid — already handled in Section 15, reinforcing */
  .career-roles-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .career-role-card {
    padding: 14px 10px !important;
    border-radius: 14px !important;
    gap: 10px !important;
  }

  .career-role-card h4 {
    font-size: 0.82rem !important;
  }

  .career-role-card p {
    font-size: 0.7rem !important;
    line-height: 1.3 !important;
  }

  /* Eligible role section header row: stack */
  #careerRolesSection > div:first-child {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  #careerRolesSection > div:first-child a {
    width: 100% !important;
    justify-content: center !important;
  }
}

/* ── 20e. SKILL INVENTORY GRID ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .skill-inventory-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .skill-inv-card {
    padding: 10px 12px !important;
  }
}

/* ── 20f. CAPACITY & SCHEDULE ENGINE ────────────────────────────────────── */
@media (max-width: 640px) {
  /* Capacity section: 2 stats side by side, then single below */
  #capacitySection > div,
  [style*="grid-template-columns: repeat(auto-fit, minmax(260px"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  /* Update availability button: full width */
  #btnOpenAvailability {
    width: 100% !important;
    justify-content: center !important;
    margin-top: 8px !important;
  }
}

/* ── 20g. COMMITMENT HEALTH MATRIX ─────────────────────────────────────── */
@media (max-width: 640px) {
  .student-commitment-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
}

/* ── 20h. ENROLLED PROGRAMS GRID ───────────────────────────────────────── */
@media (max-width: 640px) {
  .student-programs-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  /* Program card: ensure bottom action row doesn't overflow */
  .student-programs-grid .card > div:last-child {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .student-programs-grid .card a.btn {
    flex: 1 !important;
    justify-content: center !important;
    min-width: 120px !important;
  }
}

/* ── 20i. LEARNING & COMMITMENT TRAJECTORY SECTION ──────────────────────── */
.student-trajectory-card {
  width: 100%;
}

.student-trajectory-header {
  width: 100%;
}

.student-trajectory-header-content {
  width: 100%;
}

@media (max-width: 768px) {
  .student-trajectory-card {
    padding: 18px 16px !important;
    border-radius: 16px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .student-trajectory-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    margin-bottom: 16px !important;
    gap: 8px !important;
  }

  .student-trajectory-header-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
  }

  .student-trajectory-header h2 {
    font-size: clamp(1.1rem, 4.8vw, 1.25rem) !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    margin: 6px 0 3px !important;
    line-height: 1.3 !important;
    color: var(--apple-label-primary) !important;
  }

  .student-trajectory-header p {
    font-size: 0.8rem !important;
    line-height: 1.45 !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    color: var(--apple-label-secondary) !important;
    margin: 0 !important;
  }

  /* Responsive Chart Canvas Container */
  #studentTrajectoryChart {
    width: 100% !important;
    min-height: 220px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    display: block !important;
  }

  #studentTrajectoryChart svg {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
  }

  /* Mobile 2+1 KPI Layout: Curriculum (col 1) + Time (col 2), Compliance (full width) */
  .student-trajectory-kpis {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    margin-top: 14px !important;
    padding-top: 14px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .student-trajectory-kpis .trajectory-kpi-item {
    padding: 10px 12px !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
  }

  .student-trajectory-kpis .trajectory-kpi-compliance {
    grid-column: span 2 !important;
  }
}

@media (max-width: 360px) {
  .student-trajectory-kpis {
    grid-template-columns: 1fr !important;
  }

  .student-trajectory-kpis .trajectory-kpi-compliance {
    grid-column: span 1 !important;
  }
}

/* ── 20j. UNIVERSAL STUDENT DASHBOARD TYPOGRAPHY GUARD ─────────────────── */
@media (max-width: 640px) {
  /* Guarantee no text on the dashboard ever breaks character-by-character */
  .student-hero-card *,
  .student-commitment-grid *,
  .student-programs-grid * {
    overflow-wrap: break-word !important;
    word-break: normal !important;
    /* explicitly prohibit break-all */
  }

  /* All h1/h2 inside student dashboard: clamped, fluid typography */
  .student-hero-card h1,
  .student-hero-card h2 {
    font-size: clamp(1.2rem, 5.5vw, 1.55rem) !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }

  /* Section h2s: clamped */
  .card h2[style*="font-size: 1.85rem"] {
    font-size: clamp(1.2rem, 5.5vw, 1.5rem) !important;
  }
}

/* ── 20k. 320px ULTRA-COMPACT OVERRIDE ─────────────────────────────────── */
@media (max-width: 360px) {
  /* At 320–360px: hero identity switches to fully stacked (avatar above name) */
  .student-hero-identity {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .student-hero-card {
    padding: 16px 14px !important;
  }

  .student-hero-info h1 {
    font-size: clamp(1.1rem, 7vw, 1.3rem) !important;
  }

  .career-roles-grid {
    grid-template-columns: 1fr !important;
  }

  /* Quick preset buttons in availability modal: 2-col */
  [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
  }
}

/* ==========================================================================
   21. GLOBAL PADDING & CONTAINER SAFEGUARD (all pages)
   ========================================================================== */
@media (max-width: 640px) {
  /* Every .card gets comfortable mobile padding */
  .card {
    padding: 18px 16px !important;
    border-radius: 16px !important;
  }

  /* All section headings inside cards */
  .card h2 {
    font-size: clamp(1rem, 4.5vw, 1.2rem) !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
  }

  .card h3 {
    font-size: clamp(0.95rem, 4vw, 1.1rem) !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
  }

  /* Card header rows (title + badge): stack on very small screens */
  .card > div > div[style*="display: flex; justify-content: space-between; align-items: center; margin-bottom"] {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
}

/* ── Global text & badge overflow guard (< 768px) ────────────────────────── */
@media (max-width: 768px) {
  .badge {
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    display: inline-block !important;
    vertical-align: middle !important;
  }

  /* Ensure no text element creates a wider-than-viewport text node */
  p, span, div, a, li, td, th, label, strong, em {
    max-width: 100% !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
  }

  h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word !important;
    word-break: normal !important;
    max-width: 100% !important;
  }
}

/* ==========================================================================
   22. SKILL JOURNEY — INTERACTIVE MOBILE VERTICAL STAGE & CONTROLS
   Desktop (>= 768px): Horizontal SVG stage visible, mobile vertical stage hidden
   Mobile  (< 768px):  Horizontal SVG stage hidden, vertical interactive stage visible
   ========================================================================== */

/* ── Show/hide rules ──────────────────────────────────────────────────────── */
.skill-journey-desktop-view { display: block; }
.skill-journey-mobile-view  { display: none; }

/* Skill Journey card: allow rich surface presentation */
.skill-journey-card {
  overflow: visible !important;
}

/* Desktop Stage wrapper */
.skill-blueprint-stage-wrapper {
  overflow-x: auto !important;
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch !important;
  max-width: 100% !important;
}

@media (max-width: 767px) {
  /* Hide desktop horizontal journey on mobile */
  .skill-journey-desktop-view {
    display: none !important;
  }

  /* Show mobile vertical interactive journey */
  .skill-journey-mobile-view {
    display: block !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Skill Journey card: snug mobile padding */
  .skill-journey-card {
    padding: 20px 14px !important;
    overflow: hidden !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── Responsive Controls Header ───────────────────────────────────────── */
  .skill-journey-controls {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
    margin-top: 14px !important;
  }

  #btnWatchJourney {
    width: 100% !important;
    justify-content: center !important;
    padding: 9px 14px !important;
    font-size: 0.84rem !important;
    border-radius: 10px !important;
  }

  .skill-journey-secondary-controls {
    display: flex !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .skill-journey-secondary-controls .btn {
    flex: 1 !important;
    justify-content: center !important;
    padding: 7px 6px !important;
    font-size: 0.74rem !important;
    white-space: nowrap !important;
    text-align: center !important;
    border-radius: 8px !important;
  }

  /* ── Mobile Vertical Stage ────────────────────────────────────────────── */
  .skill-blueprint-stage-mobile {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    position: relative !important;
    background: #FFFFFF !important;
    border-radius: 16px !important;
    border: 1px solid #E5E7EB !important;
    padding: 22px 14px 20px !important;
    margin: 14px 0 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03) !important;
  }

  /* 3D Brick Block on Mobile */
  .skill-brick-block-mobile {
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, filter 0.25s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .skill-brick-block-mobile:active {
    transform: scale(0.95) !important;
  }

  /* Mobile Student Character */
  .skill-journey-character-mobile {
    pointer-events: none;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  }

  /* Mobile Node Rows */
  .sj-mobile-node-row {
    transition: opacity 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .sj-mobile-node-row:active {
    opacity: 0.75;
  }

  /* Capstone Node Mobile Accent */
  .sj-mobile-node-capstone {
    background: linear-gradient(135deg, #FFFDF5, #FFF9F0);
    border-radius: 12px;
    padding: 10px 12px !important;
    border: 1.5px solid #FDE68A;
    margin: 2px 0;
  }
}

/* ==========================================================================
   23. GLOBAL OVERFLOW HARDENING — final guard against any remaining blowout
   ========================================================================== */

/* Ensure no absolutely-positioned element inside the page body
   can create a horizontal overflow wider than the viewport */
@media (max-width: 767px) {
  /* Skill blueprint stage is only allowed to overflow INSIDE its wrapper */
  .skill-blueprint-stage-wrapper {
    contain: layout style !important;
    max-width: 100% !important;
  }

  /* Explicit: body must not scroll horizontally under any circumstances */
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* All direct children of the page body: clamp to viewport */
  body > * {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
}

/* ==========================================================================
   24. UNIVERSAL CERTIFICATE ENGINE — LAPTOP & MOBILE FLUID FOUNDATION
   ========================================================================== */

/* Universal Canvas Fluid Scaling: Never exceed container or viewport */
canvas[id*="CertCanvas"],
canvas[id*="PreviewCanvas"],
canvas[id*="adminPreviewCanvas"],
canvas[id*="studentCertCanvas"],
canvas[id*="publicCertCanvas"] {
  max-width: 100% !important;
  height: auto !important;
  display: block !important;
  box-sizing: border-box !important;
}

/* Certificate Layout Wrappers */
.admin-cert-page-container,
.admin-cert-lifecycle-layout,
.cert-builder-grid,
.student-cert-grid,
.public-container {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  min-width: 0 !important;
}

/* Table scroll containment on all certificate views */
.cert-table-wrapper,
.card > div[style*="overflow-x: auto"] {
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

/* Responsive code and badge wrapping */
.cert-table code,
.cert-table .badge {
  white-space: nowrap !important;
}

/* Prevent flex blowout on mobile */
@media (max-width: 768px) {
  .admin-cert-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .admin-cert-tools-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .cert-builder-grid,
  .student-cert-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .cert-nav-pills,
  .admin-cert-nav-pills {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .admin-cert-nav-pill {
    width: 100% !important;
    box-sizing: border-box !important;
    justify-content: center !important;
  }
}

@media (max-width: 480px) {
  .admin-cert-kpi-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   UNIVERSITY DASHBOARD — LOAD MORE & MOBILE RESPONSIVE ENGINE
   ========================================================================== */
.uni-load-more-wrapper {
  transition: all 0.2s ease;
}

.uni-load-more-btn:hover {
  background: var(--apple-blue, #2563eb) !important;
  color: #ffffff !important;
  border-color: var(--apple-blue, #2563eb) !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25) !important;
}

.uni-load-more-btn:hover .uni-batch-badge {
  background: rgba(255, 255, 255, 0.25) !important;
  color: #ffffff !important;
}

.uni-filter-card {
  padding: 16px 20px;
  margin-bottom: 20px;
  background: var(--apple-bg-secondary, #f8fafc);
  border: 1px solid var(--apple-border, #e2e8f0);
  border-radius: 12px;
}

.uni-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  align-items: flex-end;
}

/* 2-Column Department & Faculty Grids */
.uni-two-col-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 24px;
  margin-bottom: 30px;
  align-items: start;
}

@media (max-width: 1024px) {
  .uni-two-col-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
}

@media (max-width: 768px) {
  .uni-filter-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .uni-filter-actions {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .uni-filter-actions .btn {
    flex: 1 !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* Touch optimization for mobile table cells */
  .table th, .table td {
    padding: 12px 10px !important;
  }

  /* Compact headers for mobile */
  .dashboard-header {
    margin-bottom: 16px !important;
  }

  .dashboard-title {
    font-size: 1.4rem !important;
  }
}

@media (max-width: 480px) {
  .uni-filter-card {
    padding: 12px 14px !important;
  }
  
  .dashboard-title {
    font-size: 1.25rem !important;
  }
}

/* ==========================================================================
   14. ZERO-SCROLL ADAPTIVE WORKSPACE & DUAL VIEW (TABLE + EXECUTIVE CARDS)
   Eliminates all horizontal scrolling ("going on the side side side")
   ========================================================================== */

/* Universal 100% Fit Table: strictly no horizontal scroll */
.uni-table-fit-container {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
  border-radius: 12px;
}

.uni-table-fit {
  width: 100% !important;
  max-width: 100% !important;
  table-layout: fixed !important;
  border-collapse: collapse !important;
  margin: 0 !important;
}

.uni-table-fit th,
.uni-table-fit td {
  padding: 12px 14px !important;
  vertical-align: middle !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

.uni-table-fit th {
  font-size: 0.72rem !important;
  text-transform: uppercase !important;
  font-weight: 700 !important;
  letter-spacing: 0.03em !important;
  color: var(--apple-label-secondary, #64748b) !important;
  background: var(--apple-bg-secondary, #f8fafc) !important;
  border-bottom: 1px solid var(--apple-border, #e2e8f0) !important;
}

.uni-table-fit tr {
  border-bottom: 1px solid var(--apple-border, #f1f5f9) !important;
  transition: background 0.12s ease;
}

.uni-table-fit tr:hover {
  background: rgba(0, 113, 227, 0.02) !important;
}

/* Dual View Header: Title + Switcher */
.uni-dual-view-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 16px 20px !important;
  border-bottom: 1px solid var(--apple-border, #e2e8f0) !important;
  flex-wrap: wrap !important;
}

/* View Switcher: Apple Segmented Control */
.uni-view-switcher {
  display: inline-flex !important;
  background: #e2e8f0;
  padding: 3px !important;
  border-radius: 8px !important;
  border: 1px solid #cbd5e1;
  gap: 2px !important;
}

.uni-view-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  border: none !important;
  background: transparent !important;
  color: #475569 !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  padding: 5px 11px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  user-select: none !important;
}

.uni-view-btn:hover {
  color: #0f172a !important;
}

.uni-view-btn.active {
  background: #ffffff !important;
  color: #0071e3 !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

/* View visibility */
.uni-view-table.is-hidden,
.uni-view-cards.is-hidden {
  display: none !important;
}

/* Executive Cards Grid */
.uni-cards-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)) !important;
  gap: 16px !important;
  padding: 20px !important;
  box-sizing: border-box !important;
  width: 100% !important;
}

/* Individual Executive Card */
.uni-card-item {
  background: #ffffff !important;
  border: 1px solid var(--apple-border, #e2e8f0) !important;
  border-radius: 12px !important;
  padding: 16px 18px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03) !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease !important;
  position: relative !important;
  box-sizing: border-box !important;
}

.uni-card-item:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06) !important;
  border-color: #cbd5e1 !important;
}

.uni-card-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  gap: 10px !important;
  padding-bottom: 12px !important;
  border-bottom: 1px solid #f1f5f9 !important;
  margin-bottom: 12px !important;
}

.uni-card-title {
  font-weight: 700 !important;
  font-size: 0.95rem !important;
  color: var(--apple-label-primary, #0f172a) !important;
  line-height: 1.3 !important;
}

.uni-card-subtitle {
  font-size: 0.76rem !important;
  color: var(--apple-label-secondary, #64748b) !important;
  margin-top: 3px !important;
}

.uni-card-body {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  margin-bottom: 14px !important;
  flex: 1 !important;
}

.uni-card-metric-row {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  font-size: 0.8rem !important;
  gap: 8px !important;
}

.uni-card-metric-label {
  color: var(--apple-label-secondary, #64748b) !important;
  font-size: 0.74rem !important;
}

.uni-card-metric-value {
  font-weight: 700 !important;
  color: var(--apple-label-primary, #0f172a) !important;
}

.uni-card-footer {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding-top: 12px !important;
  border-top: 1px solid #f1f5f9 !important;
  gap: 8px !important;
}

/* Metric Pill Cluster */
.uni-pill-cluster {
  display: inline-flex !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
  align-items: center !important;
}

.uni-stat-pill {
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  padding: 3px 8px !important;
  border-radius: 6px !important;
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  white-space: nowrap !important;
}

/* On mobile phones (< 768px), clean responsive cards & scrollable tables */
@media (max-width: 768px) {
  .uni-cards-grid {
    grid-template-columns: 1fr !important;
    padding: 14px !important;
    gap: 12px !important;
  }

  .uni-table-fit-container {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    border-radius: 12px;
  }

  .uni-table-fit {
    min-width: 680px !important;
    width: 100% !important;
    table-layout: auto !important;
  }

  .uni-table-fit th,
  .uni-table-fit td {
    padding: 10px 12px !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow: visible !important;
  }

  .uni-trajectory-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .desktop-th-label {
    display: none !important;
  }
  .mobile-th-label {
    display: block !important;
  }
}

.desktop-th-label {
  display: block;
}
.mobile-th-label {
  display: none;
}


