/* ============================================================
   Elite Timetable Portal — Design System
   timetable.eliteinstitute.edu.lk
   ============================================================ */

/* ── Fonts ─────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --navy:        #0d1526;
  --navy-mid:    #1a2035;
  --navy-light:  #243050;
  --red:         #c0392b;
  --red-dark:    #a93226;
  --red-glow:    rgba(192, 57, 43, 0.25);
  --gold:        #e8a020;
  --gold-light:  #f5c842;
  --white:       #ffffff;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-400:    #9ca3af;
  --gray-600:    #6b7280;
  --gray-700:    #374151;
  --gray-900:    #1f2937;
  --glass-bg:    rgba(255, 255, 255, 0.05);
  --glass-border:rgba(255, 255, 255, 0.10);
  --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md:   0 8px 32px rgba(0, 0, 0, 0.25);
  --shadow-lg:   0 20px 60px rgba(0, 0, 0, 0.35);
  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --transition:  0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--navy);
  color: var(--white);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ── Background Gradient + Orbs ────────────────────────────── */
.bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse at 20% 20%, #1e3a5f 0%, transparent 50%),
              radial-gradient(ellipse at 80% 80%, #3d0b0b 0%, transparent 50%),
              linear-gradient(135deg, #0d1526 0%, #1a2035 50%, #0d1526 100%);
  pointer-events: none;
}
.bg-canvas::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 25% 60%, rgba(192,57,43,0.08) 0%, transparent 40%),
    radial-gradient(circle at 75% 30%, rgba(232,160,32,0.06) 0%, transparent 40%);
}

/* ── Layout Wrapper ────────────────────────────────────────── */
.portal-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ── Header / Topbar ───────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 21, 38, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: brightness(1.1);
}
.topbar-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.3px;
}
.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--glass-border);
}
.topbar-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}
.topbar-spacer { flex: 1; }
.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(192,57,43,0.15);
  border: 1px solid rgba(192,57,43,0.3);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  color: #f08070;
  letter-spacing: 0.5px;
}
.topbar-badge span { font-size: 8px; line-height: 1; }

/* ── Hero Section ──────────────────────────────────────────── */
.hero {
  padding: 72px 32px 56px;
  text-align: center;
  position: relative;
}
.hero-logo-wrap {
  display: inline-block;
  margin-bottom: 24px;
  position: relative;
}
.hero-logo {
  width: 90px;
  height: 90px;
  object-fit: contain;
  border-radius: 20px;
  background: var(--navy-light);
  padding: 8px;
  box-shadow: 0 0 0 1px var(--glass-border), var(--shadow-md);
  animation: floatLogo 4s ease-in-out infinite;
}
@keyframes floatLogo {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
.hero-title {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #ffffff 0%, rgba(255,255,255,0.7) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}
.hero-subtitle {
  font-size: 16px;
  color: rgba(255,255,255,0.5);
  font-weight: 400;
  max-width: 520px;
  margin: 0 auto 36px;
}
.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  backdrop-filter: blur(10px);
}
.hero-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74,222,128,0.2);
  animation: pulse-dot 2s ease infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(74,222,128,0.2); }
  50%       { box-shadow: 0 0 0 6px rgba(74,222,128,0.1); }
}

/* ── Section Titles ────────────────────────────────────────── */
.section-header {
  padding: 0 32px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
}
.section-line {
  flex: 1;
  height: 1px;
  background: var(--glass-border);
}

/* ── Course Grid ───────────────────────────────────────────── */
.courses-section {
  padding: 0 32px;
  margin-bottom: 48px;
}
.courses-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}


/* ── Course Selector – Compact Layout ──────────────────────── */
.cs-section { margin-bottom: 18px; }
.cs-section-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.cs-badge {
  font-size: 9px; font-weight: 800; letter-spacing: 1.5px;
  padding: 3px 9px; border-radius: 100px; text-transform: uppercase;
}
.cs-badge-degree   { background: rgba(99,102,241,0.15); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.3); }
.cs-badge-foundation { background: rgba(16,185,129,0.15); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.3); }
.cs-badge-professional { background: rgba(232,160,32,0.15); color: #fcd34d; border: 1px solid rgba(232,160,32,0.3); }
.cs-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  color: rgba(255,255,255,0.4); text-transform: uppercase;
}
.cs-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cs-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 12px; padding: 14px 16px;
  transition: border-color 0.2s, background 0.2s;
}
.cs-card:hover { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.18); }
.cs-card-name {
  font-size: 12px; font-weight: 700;
  color: var(--white); margin-bottom: 10px; line-height: 1.35;
}
.cs-row { display: flex; gap: 6px; align-items: center; }
.cs-sel {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 8px; padding: 7px 10px;
  color: var(--white); font-size: 11px; font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer; outline: none;
  transition: border-color 0.2s, background 0.2s;
  min-width: 0;
}
.cs-sel:focus { border-color: var(--gold); background: rgba(255,255,255,0.11); }
.cs-sel:disabled { opacity: 0.35; cursor: not-allowed; }
.cs-sel option { background: #1a2538; color: #fff; }
.cs-btn {
  padding: 7px 13px; flex-shrink: 0;
  background: var(--gold); color: var(--navy);
  font-size: 11px; font-weight: 800;
  border: none; border-radius: 8px; cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
}
.cs-btn:hover { background: #f0b030; transform: translateY(-1px); }
.cs-btn:active { transform: translateY(0); }
.cs-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* Professional panel — single wide row */
.cs-prof-panel {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 12px; padding: 14px 16px;
}
.cs-prof-panel .cs-row { flex-wrap: nowrap; }
.cs-prof-panel .cs-sel-wide { flex: 3; }
.cs-prof-panel .cs-sel       { flex: 1.2; }

/* Legacy course-card/chip — kept for backwards compat but hidden */
.course-card { display: none; }
.group-chip  { display: none; }


/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 32px;
  color: rgba(255,255,255,0.3);
}
.empty-state svg { margin: 0 auto 16px; opacity: 0.4; }
.empty-state h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ── Loading Spinner ───────────────────────────────────────── */
.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 64px;
  color: rgba(255,255,255,0.4);
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Timetable Panel ───────────────────────────────────────── */
#timetable-panel {
  padding: 0 32px 64px;
  overflow-x: auto;
}
.tt-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.tt-panel-info h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--white);
  margin-bottom: 4px;
}
.tt-panel-info p {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}
.tt-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--red);
  color: white;
  box-shadow: 0 4px 16px var(--red-glow);
}
.btn-primary:hover {
  background: var(--red-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(192,57,43,0.35);
}
.btn-ghost {
  background: var(--glass-bg);
  color: rgba(255,255,255,0.8);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  transform: translateY(-1px);
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--navy);
  font-weight: 700;
}
.btn-gold:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(232,160,32,0.35);
}

/* ── Timetable Card (pixel-accurate, mirrors index.html) ───── */
#timetable-card {
  background: #ffffff;
  color: var(--navy);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #ffffff;
  box-shadow: var(--shadow-lg);
  position: relative;
  font-family: 'Inter', sans-serif;
  width: 1000px;
  overflow: hidden;
}
#timetable-card::before {
  content: '';
  display: block;
  height: 5px;
  background: linear-gradient(90deg, var(--red) 0%, var(--gold) 100%);
}

/* ── Inner Card ────────────────────────────────────────────── */
.tt-inner { padding: 28px 36px 0; position: relative; z-index: 1; }
.tt-watermark {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  opacity: 0.18;
  mix-blend-mode: multiply;
  pointer-events: none;
  user-select: none;
  z-index: 10;
}

/* ── Card Header ───────────────────────────────────────────── */
.tt-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1.5px solid #e5e7eb;
  position: relative;
  z-index: 1;
}
.tt-header-left { display: flex; align-items: center; gap: 18px; }
.tt-logo {
  width: 68px; height: 68px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--navy);
  padding: 4px;
}
.tt-official-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--red); margin-bottom: 4px;
}
.tt-inst-name {
  font-size: 26px; font-weight: 800;
  color: var(--navy-mid); line-height: 1.15; letter-spacing: -0.3px;
}
.tt-degree { font-size: 12px; color: var(--gray-600); margin-top: 3px; }
.tt-header-right { text-align: right; }
.tt-period-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--gray-600); margin-bottom: 3px;
}
.tt-semester { font-size: 20px; font-weight: 800; color: var(--navy-mid); }
.tt-intake { font-size: 12px; color: var(--gray-600); margin-top: 2px; }

/* ── Divider + Title Row ───────────────────────────────────── */
.tt-divider { height: 1px; background: var(--gray-200); margin: 0 0 18px; position: relative; z-index: 1; }
.tt-title-row {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px; position: relative; z-index: 1;
}
.tt-title {
  font-size: 28px; font-weight: 800;
  color: var(--navy-mid); letter-spacing: -0.4px;
}
.tt-subtitle { font-size: 12px; color: var(--gray-600); margin-top: 3px; }
.tt-programme-badge {
  padding: 8px 18px;
  border: 1.5px solid var(--navy-mid);
  border-radius: 4px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--navy-mid); white-space: nowrap; align-self: center;
}

/* ── Schedule Table ────────────────────────────────────────── */
.tt-table { width: 100%; border-collapse: collapse; position: relative; z-index: 1; }
.tt-table thead tr { background: #1a2035; }
.tt-table thead th {
  padding: 14px 20px; text-align: left;
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: rgba(255,255,255,0.85);
}
.tt-table thead th:first-child { width: 200px; }
.tt-table thead th:nth-child(2) { width: 220px; }
.tt-table tbody tr { background: #fff; }
.tt-table tbody td { 
  padding: 16px 20px; 
  font-size: 14px; 
  color: var(--navy-mid); 
  vertical-align: middle; 
  border-bottom: 1px solid var(--gray-200); 
}
.tt-table tbody tr:not(:last-child) td:not(.tt-day-cell-grouped) {
  border-bottom: none;
}
.tt-table tbody:last-child tr:last-child td { border-bottom: none; }
.tt-row-continuation td { border-top: 1px dashed #e9ecef; }
.tt-row-continuation td:first-child { border-top: none; }
.tt-table tbody td.tt-day-cell-grouped { padding: 16px 20px 16px 36px; vertical-align: middle; position: relative; }
.tt-grouped-inner { display: flex; align-items: center; height: 100%; }
.tt-day-accent-tall { position: absolute; top: 16px; bottom: 16px; left: 20px; width: 4px; border-radius: 2px; background: var(--gold); }
.tt-day-name { font-weight: 700; font-size: 14px; color: var(--navy-mid); }
.tt-time { font-size: 14px; color: var(--gray-700); }
.tt-subject { font-size: 14px; font-weight: 700; color: var(--navy-mid); }
.tt-lecturer { font-size: 11px; color: var(--gray-600); margin-top: 3px; }

/* ── Delivery Mode Badges (portal UI only, hidden inside card) ─ */
#timetable-card .tt-mode-badge { display: none; }
.tt-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: 4px;
}
.tt-mode-online {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.tt-mode-physical {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.tt-join-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  padding: 4px 12px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}
.tt-join-btn:hover { background: #1d4ed8; }


/* ── Info Row ──────────────────────────────────────────────── */
.tt-info-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0; margin-top: 22px;
  border-top: 1.5px solid var(--gray-200);
  position: relative; z-index: 1;
}
.tt-info-box { padding: 16px 20px; border-right: 1px solid var(--gray-200); }
.tt-info-box:last-child { border-right: none; }
.tt-info-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: 1.8px; text-transform: uppercase;
  color: var(--gray-600); margin-bottom: 5px;
}
.tt-info-value { font-size: 13px; color: #374151; }

/* ── Card Footer ────────────────────────────────────────────── */
.tt-footer {
  background: #f9fafb;
  border-top: 1.5px solid var(--gray-200);
  padding: 14px 36px;
  display: flex; align-items: flex-start; justify-content: space-between;
  position: relative; z-index: 1;
}
.tt-footer-left { font-size: 11.5px; color: var(--gray-700); line-height: 1.8; }
.tt-footer-left strong { font-weight: 700; }
.tt-footer-right { text-align: right; }
.tt-footer-brand {
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--navy-mid); margin-bottom: 3px;
}
.tt-footer-addr { font-size: 10.5px; color: var(--gray-600); line-height: 1.6; }

/* ── QR Code Section ───────────────────────────────────────── */
.qr-section {
  margin-top: 24px;
  max-width: 1000px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
}
#qr-canvas { border-radius: 8px; background: white; padding: 8px; }
.qr-info h4 { font-size: 14px; font-weight: 700; color: var(--white); margin-bottom: 4px; }
.qr-info p { font-size: 12px; color: rgba(255,255,255,0.5); }
.qr-url {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  word-break: break-all;
}

/* ── Export Overlay ────────────────────────────────────────── */
.export-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(13,21,38,0.8);
  z-index: 1000;
  align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
.export-overlay.active { display: flex; }
.export-spinner {
  background: var(--navy-mid);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 40px 56px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.spinner-ring {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
.export-spinner p { font-size: 14px; font-weight: 600; color: rgba(255,255,255,0.8); }

/* ── Footer Bar ────────────────────────────────────────────── */
.portal-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 32px;
  border-top: 1px solid var(--glass-border);
  font-size: 12px;
  color: rgba(255,255,255,0.3);
}
.portal-footer a { color: rgba(255,255,255,0.5); text-decoration: none; }
.portal-footer a:hover { color: var(--white); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar { flex-direction: column; padding: 12px 16px; gap: 12px; height: auto; text-align: center; }
  .topbar-left { flex-direction: column; gap: 8px; }
  .topbar-right { margin-left: 0; }
  .logo-text { border-left: none; padding-left: 0; margin-left: 0; }
  
  .hero { padding: 32px 16px 24px; }
  .hero-title { font-size: 32px; }
  .hero-subtitle { font-size: 15px; }

  .courses-section, #timetable-panel { padding: 0 16px 48px; }
  .section-header { padding: 0 16px; }
  
  /* Course Selector Mobile Adjustments */
  .cs-grid-2 { grid-template-columns: 1fr; }
  .cs-row, .cs-prof-panel .cs-row { flex-wrap: wrap; flex-direction: column; align-items: stretch; gap: 10px; }
  .cs-sel-wide, .cs-sel { flex: none; width: 100%; }
  
  .tt-actions { flex-direction: column; gap: 8px; }
  .tt-actions button { width: 100%; justify-content: center; }
  
  .tt-inner { padding: 20px 16px 0; }
  .tt-footer { flex-direction: column; gap: 12px; text-align: center; align-items: center; }
  .tt-header { flex-direction: column; gap: 16px; text-align: center; }
  .tt-inst-name { font-size: 18px; }
  .tt-title { font-size: 20px; }
  .tt-panel-header { flex-direction: column; align-items: center; text-align: center; gap: 16px; }
  .tt-actions { width: 100%; max-width: 300px; margin: 0 auto; }  
  .qr-section { flex-direction: column; text-align: center; }
  
  /* Timetable wrapper scrolling */
  #timetable-panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ── Print ─────────────────────────────────────────────────── */
@media print {
  body { background: white; }
  .bg-canvas, .topbar, .hero, .courses-section, .tt-actions, .qr-section, .portal-footer { display: none !important; }
  #timetable-panel { padding: 0 !important; }
  #timetable-card {
    box-shadow: none !important;
    border-radius: 0 !important;
    color: black !important;
    max-width: none !important;
  }
  .tt-panel-header { flex-direction: column; align-items: stretch; gap: 12px; }
  @page { size: A4 landscape; margin: 1cm; }
}

@media (max-width: 768px) {
    /* Hide the secondary export button on mobile */
    #desktop-export-bar { display: none !important; }

    /* For export, we force the wrapper to desktop width */
    #tt-card-wrapper.export-mode {
        display: block !important;
        position: absolute;
        left: -9999px;
        top: 0;
        width: 1200px;
        max-width: none;
    }

    /* ── Mobile Card Timetable ── */
    #tt-card-wrapper:not(.export-mode) #timetable-card {
        width: 100%;
    }
    
    #tt-card-wrapper:not(.export-mode) .tt-inner {
        padding: 20px 16px 0;
    }
    
    #tt-card-wrapper:not(.export-mode) .tt-footer {
        padding: 14px 16px;
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    #tt-card-wrapper:not(.export-mode) .tt-footer-right {
        text-align: center;
        width: 100%;
    }
    /* ── Topbar Mobile Fixes ── */
    .topbar-sep { display: none; }
    .topbar-sub { 
        line-height: 1.4; 
        font-size: 11px;
        padding: 0 10px;
        color: rgba(255,255,255,0.6);
    }
    
    /* ── Header Centering ── */
    #tt-card-wrapper:not(.export-mode) .tt-header {
        align-items: center;
        border-bottom: 1px dashed var(--gray-200);
        padding-bottom: 16px;
    }
    #tt-card-wrapper:not(.export-mode) .tt-header-left {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    #tt-card-wrapper:not(.export-mode) .tt-header-right {
        text-align: center;
        margin-top: 4px;
    }
    #tt-card-wrapper:not(.export-mode) .tt-title-row {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
    }
    #tt-card-wrapper:not(.export-mode) .tt-title {
        font-size: 20px;
    }
    #tt-card-wrapper:not(.export-mode) .tt-programme-badge {
        font-size: 10px;
        padding: 6px 14px;
    }

    #tt-card-wrapper:not(.export-mode) .tt-table,
    #tt-card-wrapper:not(.export-mode) .tt-day-group,
    #tt-card-wrapper:not(.export-mode) tr,
    #tt-card-wrapper:not(.export-mode) td {
        display: block;
        width: 100%;
        border: none;
    }
    
    #tt-card-wrapper:not(.export-mode) thead {
        display: none;
    }

    #tt-card-wrapper:not(.export-mode) .tt-day-group {
        background: var(--glass-bg);
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        margin-bottom: 16px;
        overflow: hidden;
        box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    }

    /* The Day Banner */
    #tt-card-wrapper:not(.export-mode) .tt-day-cell-grouped {
        background: var(--navy);
        padding: 14px 16px;
    }
    #tt-card-wrapper:not(.export-mode) .tt-grouped-inner {
        padding: 0;
    }
    #tt-card-wrapper:not(.export-mode) .tt-day-name {
        color: white;
        font-size: 15px;
        font-weight: 700;
        letter-spacing: 1px;
    }
    #tt-card-wrapper:not(.export-mode) .tt-day-accent-tall {
        display: none;
    }

    /* Session Rows */
    #tt-card-wrapper:not(.export-mode) tr {
        display: flex;
        flex-direction: column;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }
    #tt-card-wrapper:not(.export-mode) tr:last-child {
        border-bottom: none;
    }

    /* Time & Subject Cells */
    #tt-card-wrapper:not(.export-mode) td.tt-time {
        padding: 12px 16px 4px;
        font-weight: 700;
        color: var(--navy);
        font-size: 14px;
    }
    #tt-card-wrapper:not(.export-mode) td:last-child {
        padding: 4px 16px 16px;
    }
}
