:root {
  --portal-bg: #ebe6f4;
  --portal-sidebar: #f7f5fc;
  --portal-card: #ffffff;
  --portal-primary: #2f3f73;
  --portal-primary-dark: #24325d;
  --portal-accent: #f2c94c;
  --portal-accent-hover: #e5b93a;
  --portal-text: #2f3f73;
  --portal-muted: #7b86a8;
  --portal-border: #e3ddf1;
  --portal-alert: #d96b7a;
  --portal-good: #3cb878;
  --portal-average: #f2c94c;
  --portal-low: #e45757;
  --portal-shadow: 0 8px 24px rgba(47, 63, 115, 0.08);
  --portal-radius: 18px;
}

* {
  box-sizing: border-box;
}

body.student-portal {
  margin: 0;
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  background: var(--portal-bg);
  color: var(--portal-text);
}

.portal-wrapper {
  min-height: 100vh;
  display: flex;
}

.portal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(36, 50, 93, 0.45);
  z-index: 1040;
}

.portal-overlay.show {
  display: block;
}

.portal-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--portal-sidebar);
  border-right: 1px solid var(--portal-border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
  z-index: 1050;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  font-weight: 800;
  color: var(--portal-primary);
}

.portal-brand-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.portal-profile {
  text-align: center;
  padding: 10px 8px 22px;
  border-bottom: 1px solid var(--portal-border);
  margin-bottom: 18px;
}

.portal-avatar-wrap {
  position: relative;
  width: 92px;
  height: 92px;
  margin: 0 auto 12px;
}

.portal-avatar,
.portal-avatar-fallback {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #fff;
  box-shadow: var(--portal-shadow);
}

.portal-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f6bb5, #2f3f73);
  color: #fff;
  font-size: 1.6rem;
  font-weight: 800;
}

.portal-status-dot {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--portal-good);
  border: 2px solid #fff;
}

.portal-profile-name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--portal-primary);
}

.portal-profile-role,
.portal-profile-reg {
  display: none;
}

.portal-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.portal-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--portal-primary);
  text-decoration: none;
  font-weight: 600;
  transition: 0.2s ease;
}

.portal-nav-link i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

.portal-nav-link:hover,
.portal-nav-link.active {
  background: rgba(47, 63, 115, 0.08);
  color: var(--portal-primary-dark);
}

.portal-nav-link.active {
  font-weight: 800;
}

.portal-sidebar-footer {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--portal-border);
}

.portal-logout:hover {
  background: rgba(228, 87, 87, 0.1);
  color: var(--portal-low);
}

.portal-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.portal-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 16px 28px 14px;
  background: #fff;
  border-bottom: 1px solid var(--portal-border);
  position: sticky;
  top: 0;
  z-index: 1025;
  box-shadow: 0 2px 12px rgba(47, 63, 115, 0.06);
}

.portal-topbar-spacer {
  display: none;
}

.portal-menu-btn {
  display: none;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: var(--portal-card);
  color: var(--portal-primary);
  box-shadow: var(--portal-shadow);
  grid-column: 1;
  justify-self: start;
}

.portal-topbar-title h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 800;
  color: var(--portal-primary);
}

.portal-topbar-title p {
  margin: 4px 0 0;
  color: var(--portal-muted);
  font-size: 0.95rem;
}

.portal-topbar-brand {
  grid-column: 2;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 0;
  text-align: left;
}

.portal-topbar-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
}

.portal-topbar-brand-text {
  min-width: 0;
}

.portal-topbar-brand-text h1 {
  display: none;
}

.portal-topbar-brand-text p {
  margin: 0;
  color: var(--portal-primary);
  line-height: 1.35;
  font-size: 0.95rem;
  font-weight: 700;
  max-width: min(520px, 42vw);
}

.portal-page-heading {
  padding: 0 28px 4px;
}

.portal-page-heading h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--portal-primary);
}

.portal-page-heading p {
  margin: 4px 0 0;
  color: var(--portal-muted);
  font-size: 0.92rem;
}

.portal-mobile-footer {
  display: none;
}

.portal-topbar-user {
  grid-column: 3;
  justify-self: end;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--portal-card);
  box-shadow: var(--portal-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--portal-primary);
  font-weight: 800;
}

.portal-topbar-user img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portal-content {
  padding: 10px 28px 32px;
}

.portal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 24px;
  align-items: start;
}

.portal-grid-left,
.portal-grid-right {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.portal-card {
  background: var(--portal-card);
  border-radius: var(--portal-radius);
  box-shadow: var(--portal-shadow);
  padding: 24px;
}

.portal-card-title {
  margin: 0 0 18px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--portal-primary);
}

.portal-stat-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.portal-donut {
  --percent: 0;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: conic-gradient(var(--portal-accent) calc(var(--percent) * 1%), #dfe6fb 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.portal-donut::before {
  content: '';
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: var(--portal-card);
}

.portal-donut span {
  position: relative;
  z-index: 1;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--portal-primary);
}

.portal-stat-text {
  flex: 1;
  min-width: 220px;
  color: var(--portal-muted);
  line-height: 1.6;
}

.portal-stat-text strong {
  color: var(--portal-primary);
}

.portal-mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.portal-mini-stat {
  background: #f7f8fd;
  border-radius: 14px;
  padding: 14px;
}

.portal-mini-stat label {
  display: block;
  font-size: 0.78rem;
  color: var(--portal-muted);
  margin-bottom: 4px;
}

.portal-mini-stat strong {
  font-size: 1rem;
  color: var(--portal-primary);
}

.portal-grade-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portal-grade-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f7f8fd;
  border-radius: 14px;
  padding: 14px 16px;
}

.portal-grade-item h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--portal-primary);
}

.portal-grade-item p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--portal-muted);
}

.portal-grade-badge {
  min-width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 1rem;
}

.portal-grade-badge.grade-good { background: var(--portal-good); }
.portal-grade-badge.grade-average { background: var(--portal-average); color: #4a3f00; }
.portal-grade-badge.grade-low { background: var(--portal-low); }

.portal-notifications {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.portal-notification {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--portal-border);
}

.portal-notification:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.portal-notification-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.portal-notification-head h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--portal-alert);
}

.portal-notification-head span {
  font-size: 0.8rem;
  color: var(--portal-muted);
  white-space: nowrap;
}

.portal-notification p {
  margin: 0;
  color: var(--portal-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.portal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  background: var(--portal-accent);
  color: #4a3f00;
  font-weight: 800;
  text-decoration: none;
  transition: 0.2s ease;
}

.portal-btn:hover {
  background: var(--portal-accent-hover);
  color: #4a3f00;
}

.portal-btn-secondary {
  background: #eef1fa;
  color: var(--portal-primary);
}

.portal-btn-secondary:hover {
  background: #e3e8f5;
  color: var(--portal-primary-dark);
}

.portal-empty {
  text-align: center;
  color: var(--portal-muted);
  padding: 24px 12px;
}

.portal-table-wrap {
  overflow-x: auto;
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
}

.portal-table th,
.portal-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--portal-border);
  text-align: left;
  font-size: 0.92rem;
}

.portal-table th {
  color: var(--portal-muted);
  font-weight: 700;
  background: #f7f8fd;
}

.portal-profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.portal-profile-field {
  background: #f7f8fd;
  border-radius: 14px;
  padding: 14px 16px;
}

.portal-profile-field label {
  display: block;
  font-size: 0.78rem;
  color: var(--portal-muted);
  margin-bottom: 4px;
}

.portal-profile-field strong {
  color: var(--portal-primary);
  font-size: 0.95rem;
  word-break: break-word;
}

.portal-profile-field.wide {
  grid-column: 1 / -1;
}

.portal-quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.portal-quick-card {
  background: var(--portal-card);
  border-radius: var(--portal-radius);
  box-shadow: var(--portal-shadow);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease;
}

.portal-quick-card:hover {
  transform: translateY(-2px);
  color: inherit;
}

.portal-quick-card i {
  font-size: 1.4rem;
  color: var(--portal-primary);
  margin-bottom: 10px;
}

.portal-quick-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 800;
}

.portal-quick-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--portal-muted);
}

.portal-notice-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.portal-notice-board.compact .portal-notice-item {
  padding: 16px;
}

.portal-notice-item {
  background: #f7f8fd;
  border: 1px solid var(--portal-border);
  border-left: 4px solid var(--portal-primary);
  border-radius: 16px;
  padding: 20px;
}

.portal-notice-item.important {
  border-left-color: var(--portal-low);
  background: #fff7f8;
}

.portal-notice-item-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.portal-notice-item h3 {
  margin: 8px 0 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--portal-primary);
}

.portal-notice-item p {
  margin: 0;
  color: var(--portal-muted);
  line-height: 1.6;
}

.portal-notice-badge {
  display: inline-block;
  background: var(--portal-low);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.portal-notice-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--portal-muted);
  text-align: right;
}

.portal-notice-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.portal-notice-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--portal-primary);
}

.portal-notice-tags span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef1fa;
  border-radius: 999px;
  padding: 6px 10px;
}

.student-progress-sheet {
  max-width: 900px;
  margin: 0 auto;
}

.student-progress-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.student-progress-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.student-progress-table th,
.student-progress-table td {
  border: 1px solid var(--portal-border);
  padding: 10px 12px;
  text-align: left;
}

.student-progress-table th {
  width: 42%;
  background: #f7f8fd;
  color: var(--portal-muted);
  font-weight: 700;
}

.student-progress-percent {
  text-align: center;
  color: var(--portal-primary);
  font-size: 1rem;
}

.portal-print-card .report-letterhead {
  margin-bottom: 1rem;
}

.student-progress-sheet .receipt-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.student-progress-sheet .receipt-institute {
  font-size: 1rem;
}

.student-progress-sheet .receipt-subtitle,
.student-progress-sheet .receipt-contact {
  font-size: 0.82rem;
}

.student-progress-sheet .receipt-title {
  font-size: 1rem;
}

@media print {
  body.student-portal {
    background: #fff;
  }

  .portal-sidebar,
  .portal-topbar,
  .portal-overlay,
  .portal-mobile-footer,
  .no-print {
    display: none !important;
  }

  .portal-wrapper,
  .portal-main,
  .portal-content {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .portal-card,
  .portal-print-card {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }
}

@media (max-width: 991.98px) {
  .portal-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--portal-shadow);
  }

  .portal-sidebar.open {
    transform: translateX(0);
  }

  .portal-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    grid-column: 1;
  }

  .portal-topbar {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    gap: 10px;
    padding: 12px 14px;
  }

  .portal-topbar-brand {
    grid-column: 2;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    text-align: left;
    gap: 10px;
  }

  .portal-topbar-logo {
    width: 44px;
    height: 44px;
  }

  .portal-topbar-brand-text p {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--portal-primary);
    max-width: none;
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
  }

  .portal-topbar-user {
    display: none;
  }

  .portal-topbar-spacer {
    display: block;
    grid-column: 3;
    width: 42px;
    height: 42px;
  }

  .portal-page-heading,
  .portal-content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .portal-content {
    padding-bottom: 92px;
  }

  .portal-mobile-footer {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    background: #fff;
    border-top: 1px solid var(--portal-border);
    box-shadow: 0 -4px 18px rgba(47, 63, 115, 0.08);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    gap: 2px;
  }

  .portal-mobile-footer-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 54px;
    padding: 4px 2px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--portal-muted);
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
  }

  .portal-mobile-footer-link i {
    font-size: 1.05rem;
    flex-shrink: 0;
  }

  .portal-mobile-footer-link span {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .portal-mobile-footer-link.active {
    color: var(--portal-primary);
    background: rgba(47, 63, 115, 0.08);
  }

  .portal-mobile-footer-logout {
    color: var(--portal-low);
  }

  .portal-grid {
    grid-template-columns: 1fr;
  }

  .portal-mini-stats {
    grid-template-columns: 1fr;
  }

  .portal-profile-grid {
    grid-template-columns: 1fr;
  }

  .student-progress-info {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 575.98px) {
  .portal-card {
    padding: 18px;
  }

  .portal-stat-wrap {
    flex-direction: column;
    align-items: flex-start;
  }

  .portal-topbar-title h1 {
    font-size: 1.35rem;
  }
}
