:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --secondary: #0f766e;
  --secondary-hover: #115e59;
  --secondary-soft: #f0fdfa;
  --accent: #b45309;
  --accent-soft: #fef3c7;
  --success: #15803d;
  --danger: #b91c1c;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #ffffff;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.5px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.brand-name {
  display: block;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: #0f172a;
}

.brand-dot {
  color: var(--primary);
}

.brand-tagline {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #bfdbfe;
}

.nav-pill {
  background: #dbeafe;
  color: #1e40af;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
}

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

.user-badge-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.user-badge-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
}

.role-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 700;
}

/* Hero Banner */
.main-content {
  padding-top: 24px;
  padding-bottom: 56px;
}

.hero-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #0f766e 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 28px;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 28px;
  align-items: center;
  box-shadow: var(--shadow-md);
}

.hero-eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 99px;
  margin-bottom: 10px;
}

.hero-text h1 {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.25;
}

.hero-text p {
  margin: 0 0 18px;
  color: #e2e8f0;
  font-size: 15px;
}

.hero-text code {
  background: rgba(255, 255, 255, 0.18);
  padding: 2px 6px;
  border-radius: 4px;
  color: #fef08a;
}

.hero-cta-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-cta-group .btn-outline {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.hero-cta-group .btn-outline:hover {
  background: rgba(255, 255, 255, 0.22);
}

.hero-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.18);
}

.stat-value {
  display: block;
  font-size: 26px;
  font-weight: 800;
  color: #fde047;
  line-height: 1.1;
}

.stat-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-top: 4px;
}

.stat-sub {
  display: block;
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 2px;
}

/* Tab Panels */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Layout Grids & Cards */
.split-layout {
  display: grid;
  grid-template-columns: 1.85fr 1fr;
  gap: 24px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card h2, .card h3 {
  margin-top: 0;
}

.card-subtitle, .section-subtitle, .muted-text {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.section-header h2 {
  margin: 0;
  font-size: 22px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: #ffffff;
}

.btn-secondary:hover {
  background: var(--secondary-hover);
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: var(--surface-alt);
  border-color: #94a3b8;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  padding: 4px 0;
  font-weight: 600;
}

.btn-link:hover {
  text-decoration: underline;
}

.full-width {
  width: 100%;
}

/* AI Chatbot Section */
.chatbot-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chatbot-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.chatbot-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-control, .inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.inline-control select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  font-size: 13px;
}

.prompt-chips-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--surface-alt);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.chip-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.prompt-chip {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.prompt-chip:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.chat-messages {
  max-height: 540px;
  min-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.chat-msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.chat-msg.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-msg.user .msg-avatar {
  background: var(--secondary);
}

.msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  max-width: 88%;
  box-shadow: var(--shadow-sm);
}

.chat-msg.user .msg-bubble {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.msg-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.msg-content p {
  margin: 0 0 10px;
}

.msg-content p:last-child {
  margin-bottom: 0;
}

.chat-q-card {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 12px;
}

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

.chat-q-title {
  font-weight: 700;
  font-size: 14px;
  color: #1e3a8a;
}

.chat-q-body {
  white-space: pre-line;
  font-size: 14px;
  margin-bottom: 10px;
}

.chat-q-answer {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13.5px;
  white-space: pre-line;
  margin-bottom: 10px;
}

.ref-badge-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.ref-badge-btn:hover {
  background: #fde68a;
}

.chat-input-bar {
  display: flex;
  gap: 10px;
}

.chat-input-bar input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* Sidebar */
.overview-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-card h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

.sidebar-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.featured-list, .mini-calendar-list {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13.5px;
}

.featured-list li {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* Filter Bar & Pills */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.subject-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.filter-inputs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
  justify-content: flex-end;
}

.filter-inputs select, .filter-inputs input {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.filter-inputs input {
  min-width: 240px;
}

/* Cards Grid (Papers, Tuition, Tutors, Materials) */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.subj-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
  text-transform: uppercase;
}

.subj-English { background: #dbeafe; color: #1e40af; }
.subj-Math { background: #dcfce7; color: #166534; }
.subj-Science { background: #fef3c7; color: #92400e; }
.subj-Hindi { background: #fae8ff; color: #86198f; }
.subj-All { background: #e2e8f0; color: #334155; }

.meta-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--text-muted);
}

.item-title {
  margin: 6px 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.item-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.item-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 4px 0;
}

.item-footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Questions Stack */
.questions-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.question-text {
  font-size: 15px;
  white-space: pre-line;
  margin: 12px 0;
  color: var(--text);
}

.answer-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 4px solid #16a34a;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  white-space: pre-line;
  font-size: 14px;
}

/* Forms */
.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: grid;
  gap: 14px;
}

.form-row.two-col {
  grid-template-columns: 1fr 1fr;
}

.form-row.three-col {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.stacked-form input,
.stacked-form select,
.stacked-form textarea {
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
}

.feedback-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.feedback-banner.error {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

/* Calendar Table & Grid */
.calendar-terms-card {
  margin-bottom: 20px;
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th, .data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  background: var(--surface-alt);
  font-weight: 700;
  color: #1e3a8a;
}

.calendar-events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.calendar-download-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.directory-block {
  margin-bottom: 32px;
}

.block-title {
  margin: 0 0 14px;
  font-size: 18px;
  color: #1e3a8a;
}

.contact-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Footer */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* ========================================================================= */
/* DIALOG MODALS (Following modern-web-guidance mandatory scroll & backdrop) */
/* ========================================================================= */
dialog:modal {
  /* MANDATORY: Prevent scroll gestures inside the modal from chaining to the underlying page */
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 560px;
  width: 92vw;
  box-shadow: var(--shadow-lg);
  background: var(--surface);
  color: var(--text);
}

dialog.modal-xl:modal {
  max-width: 1080px;
  width: 95vw;
  height: 88vh;
}

dialog::backdrop {
  /* MANDATORY: ::backdrop defaults to overflow: visible. Set overflow: hidden and overscroll-behavior: contain */
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(3px);
}

.modal-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

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

.modal-close-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-weight: 700;
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

.pdf-iframe-container {
  flex: 1;
  padding: 0;
  height: calc(88vh - 72px);
}

#pdfViewerFrame {
  width: 100%;
  height: 100%;
  border: none;
}

.quick-auth-box {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
}

.quick-auth-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #1e3a8a;
  margin-bottom: 8px;
}

.quick-auth-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

@media (max-width: 960px) {
  .hero-banner, .split-layout {
    grid-template-columns: 1fr;
  }
  .form-row.two-col, .form-row.three-col {
    grid-template-columns: 1fr;
  }
}
