:root {
  --bg: #edf1f7;
  --ink: #142746;
  --muted: #4e607f;
  --card: #ffffff;
  --line: #d4ddeb;
  --brand: #1a2e62;
  --brand-soft: #e8eefb;
  --accent: #486ca5;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --shadow: 0 18px 36px rgba(17, 35, 78, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Tajawal", "Cairo", "Noto Kufi Arabic", sans-serif;
}

.background-layer {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 90% 8%, rgba(26, 46, 98, 0.22), transparent 34%),
    radial-gradient(circle at 7% 84%, rgba(72, 108, 165, 0.2), transparent 30%),
    linear-gradient(165deg, #f8fafd, #eff4fb 45%, #e8eef9);
  z-index: -1;
}

main {
  width: min(1200px, 95vw);
  margin: 26px auto 36px;
}

.shell {
  display: grid;
  gap: 18px;
}

.top-banner {
  background:
    radial-gradient(circle at 14% 10%, rgba(255, 255, 255, 0.16), transparent 40%),
    linear-gradient(118deg, rgba(19, 35, 76, 0.98), rgba(53, 84, 136, 0.95));
  border-radius: 22px;
  padding: 18px 20px;
  color: #f8fafc;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-logo {
  width: 70px;
  height: 70px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.26);
  display: grid;
  place-items: center;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-logo .fallback-logo {
  font-weight: 700;
  letter-spacing: 0.5px;
  opacity: 0.85;
}

.brand h1,
.brand h2,
.brand p {
  margin: 0;
}

.brand h1,
.brand h2 {
  font-size: 1.3rem;
}

.brand p {
  opacity: 0.85;
  font-size: 0.95rem;
}

.user-badge {
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px 14px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.semester-chip {
  margin-top: 7px !important;
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem !important;
}

.role-nav {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.role-nav .nav-btn {
  border-radius: 10px;
  background: #eaf0fb;
  color: #1f356b;
  font-weight: 700;
  border: 1px solid #cfdaed;
  padding: 10px 12px;
}

.role-nav .nav-btn.active {
  background: linear-gradient(120deg, var(--brand), #35548a);
  color: #fff;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
  animation: rise-in 0.45s ease both;
}

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

.card hr {
  border: 0;
  border-top: 1px dashed #cbd5e1;
  margin: 14px 0;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-card {
  border: 1px solid #d6e0f2;
  border-radius: 14px;
  background: linear-gradient(160deg, #f7faff, #edf3fc);
  padding: 14px;
  animation: rise-in 0.45s ease both;
}

.stats-card strong {
  display: block;
  font-size: 1.35rem;
  margin-bottom: 4px;
}

label {
  display: block;
  margin-bottom: 7px;
  font-weight: 600;
  font-size: 0.95rem;
}

input,
select,
button,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd7eb;
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

textarea {
  resize: vertical;
  min-height: 84px;
}

button {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  background: linear-gradient(120deg, var(--brand), #35548a);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.05);
}

button.secondary {
  background: #4a618d;
}

button.danger {
  background: var(--danger);
}

.small-btn {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.85rem;
}

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

.helper {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: -3px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  margin-bottom: 12px;
}

.check-item {
  border: 1px solid #d4e2f4;
  background: #f3f7fd;
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.check-item input {
  width: auto;
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 12px;
}

th,
td {
  text-align: right;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px;
  font-size: 0.94rem;
}

th {
  background: #f3f7fd;
  color: #274270;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge.positive {
  color: #1f3f78;
  background: #dbe8fa;
}

.badge.negative {
  color: #991b1b;
  background: #fee2e2;
}

.badge.neutral {
  color: #203a70;
  background: #e5ecfa;
}

.progress {
  width: 100%;
  background: #d9e2f1;
  border-radius: 999px;
  overflow: hidden;
  height: 11px;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3b5f9a, #1a2e62);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #d7e2f2;
  background: #f4f8fe;
  border-radius: 12px;
  margin-bottom: 12px;
}

.switch-row input {
  width: auto;
  margin: 0;
  transform: scale(1.25);
}

.notice {
  border-radius: 12px;
  padding: 9px 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

.notice.warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}

.notice.info {
  background: #edf3fe;
  border: 1px solid #c7d8f4;
  color: #1c3d74;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}

fieldset:disabled {
  opacity: 0.6;
}

.alert-host {
  position: fixed;
  inset-inline-start: 18px;
  bottom: 18px;
  z-index: 1200;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
}

.alert-box {
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 14px 30px rgba(15, 35, 76, 0.2);
  border: 1px solid #c8d8f3;
  background: #f7fbff;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: rise-in 0.28s ease both;
}

.alert-box .alert-text {
  white-space: pre-line;
  line-height: 1.4;
  font-weight: 600;
  color: #183667;
  flex: 1;
}

.alert-box .alert-close {
  padding: 2px 8px;
  min-width: 30px;
  line-height: 1;
  border-radius: 8px;
  background: transparent;
  color: #32538d;
  border: 1px solid #c8d8f3;
}

.alert-box.success {
  border-color: #b7e4cc;
  background: #f2fcf6;
}

.alert-box.warning {
  border-color: #f8d3a8;
  background: #fff9f1;
}

.alert-box.danger {
  border-color: #f6c5c5;
  background: #fff5f5;
}

.alert-box.closing {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.ranking-list li {
  border: 1px solid #d6e1f2;
  border-radius: 12px;
  background: #f7faff;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 50px 1fr auto;
  align-items: center;
  gap: 10px;
}

.ranking-list li.current-student {
  border-color: #8fb1de;
  background: #eaf3ff;
}

.ranking-list li em {
  font-style: normal;
  color: #25467a;
  font-weight: 700;
}

.week-program-hero {
  border: 1px solid #cddaf0;
  border-radius: 16px;
  background: linear-gradient(135deg, #f2f8ff, #e9f1ff);
  padding: 16px;
  margin-bottom: 12px;
}

.weekly-schedule {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.schedule-step {
  position: relative;
  border: 1px solid #cfe0f5;
  background: linear-gradient(170deg, #f9fcff, #eef5ff);
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
}

.schedule-node {
  width: 84px;
  height: 84px;
  border-radius: 999px;
  margin: 0 auto 10px;
  border: 5px solid #3d73b8;
  box-shadow: 0 0 0 4px #d4e7ff inset;
  background: #fff;
  display: grid;
  place-items: center;
}

.schedule-icon {
  font-size: 1.8rem;
}

.schedule-step h4 {
  margin: 0 0 5px;
  color: #203f74;
}

.schedule-step p {
  margin: 0;
  color: #5f86be;
  font-weight: 700;
}

.schedule-arrow {
  position: absolute;
  left: -14px;
  top: 34%;
  color: #243b66;
  font-size: 1.3rem;
}

.week-fruit {
  border: 1px dashed #c6d7f1;
  border-radius: 14px;
  padding: 12px 14px;
  background: #f8fbff;
}

.week-fruit.elegant {
  background: linear-gradient(145deg, #f6fbff, #edf4ff);
  border-style: solid;
  border-color: #c9d9ef;
}

.week-fruit blockquote {
  margin: 0 0 8px;
  padding-inline-start: 12px;
  border-inline-start: 4px solid #6688bf;
  color: #18335f;
  font-weight: 600;
}

.term-report-card {
  background: #fff !important;
  border-color: #d0dbee;
  box-shadow: none;
}

.term-report-header {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: center;
  border: 1px solid #cad9ef;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
}

.term-report-header img {
  width: 88px;
  height: 88px;
  object-fit: contain;
}

.term-report-header h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.term-report-header p {
  margin: 0;
  color: #2e4a77;
  font-size: 0.92rem;
}

.term-report-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #cad7eb;
  color: #2d4672;
  font-size: 0.92rem;
}

.term-report-card table th {
  background: #edf3fd;
}

.pdf-export-root {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  overflow: auto;
  background: #ffffff;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  direction: rtl;
}

.pdf-export-sheet {
  width: 210mm;
  max-width: 210mm;
  min-height: auto;
  margin: 0 auto;
  padding: 12mm;
  background: #fff;
  color: #0f1a2f;
  font-family: "Tajawal", "Cairo", sans-serif;
  direction: rtl;
  text-align: right;
}

.pdf-export-sheet h2,
.pdf-export-sheet h3 {
  color: #1b355f;
  margin-top: 0;
}

.pdf-export-sheet section {
  margin-bottom: 14px;
}

.pdf-table-wrap {
  overflow: hidden;
  border: 1px solid #cfd9ec;
  border-radius: 12px;
}

.pdf-export-sheet table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.pdf-export-sheet table th,
.pdf-export-sheet table td {
  border: 1px solid #d8e1f1;
  padding: 6px 8px;
  text-align: right;
  vertical-align: top;
}

.pdf-export-sheet table th {
  background: #eef4ff;
}

.archive-report-header,
.term-report-export .term-report-header {
  border: 1px solid #cad9ef;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
}

.archive-report-header {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: center;
}

.archive-report-header img {
  width: 88px;
  height: 88px;
  object-fit: contain;
}

.archive-report-sheet,
.term-report-export {
  direction: rtl;
  text-align: right;
}

.archive-report-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.archive-report-stats > div {
  border: 1px solid #d1ddef;
  border-radius: 10px;
  background: #f6f9ff;
  padding: 10px;
  text-align: center;
}

.archive-report-stats strong {
  display: block;
  font-size: 1.15rem;
  color: #15305b;
}

.archive-report-stats span {
  color: #3a4f73;
  font-size: 0.86rem;
}

.site-links-actions {
  align-items: center;
}

.site-link {
  text-decoration: none;
  color: #1f4278;
  font-weight: 700;
  border: 1px solid #bfd3ee;
  border-radius: 999px;
  background: #f5f9ff;
  padding: 7px 12px;
}

.podium-chart {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 14px;
  margin-top: 8px;
}

.podium-card {
  border: 1px solid #cfdcf0;
  border-radius: 16px;
  background: linear-gradient(165deg, #f8fbff, #edf3fd);
  padding: 14px 12px;
  text-align: center;
  display: grid;
  align-content: start;
  gap: 10px;
  animation: rise-in 0.55s ease both;
}

.podium-chart .podium-card:nth-child(1) {
  animation-delay: 0.05s;
}

.podium-chart .podium-card:nth-child(2) {
  animation-delay: 0.12s;
}

.podium-chart .podium-card:nth-child(3) {
  animation-delay: 0.18s;
}

.podium-rank {
  display: inline-block;
  margin: 0 auto;
  padding: 5px 12px;
  border-radius: 999px;
  background: #dce7f9;
  color: #1f3d74;
  font-weight: 800;
  font-size: 0.9rem;
}

.podium-content {
  display: grid;
  gap: 4px;
}

.podium-name {
  font-size: 1.04rem;
  color: #142746;
}

.podium-points {
  color: #3a4e74;
  font-weight: 700;
}

.podium-card.place-1 {
  min-height: 210px;
  transform: translateY(-12px);
  border-color: #8ca5ce;
  background: linear-gradient(165deg, #eef4ff, #dfe9fb);
  box-shadow: 0 10px 20px rgba(26, 46, 98, 0.16);
}

.podium-card.place-1 .podium-rank {
  background: #1f356c;
  color: #fff;
}

.podium-card.place-2 {
  min-height: 172px;
}

.podium-card.place-3 {
  min-height: 158px;
}

.podium-card.place-empty {
  border-style: dashed;
  background: #f8fafd;
}

.announcement-list {
  display: grid;
  gap: 16px;
}

.announcement-card {
  border: 1px solid #c8d8ef;
  background: linear-gradient(180deg, #f8fbff, #f1f6ff);
  border-radius: 16px;
  padding: 16px;
  animation: rise-in 0.45s ease both;
  position: relative;
}

.announcement-card h4 {
  margin: 0;
  font-size: 1.08rem;
}

.announcement-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.announcement-meta {
  color: var(--muted);
  margin-top: 8px;
  font-size: 0.87rem;
}

.announcement-card .inline-actions {
  position: relative;
  z-index: 2;
}

.announcement-card .inline-actions button {
  pointer-events: auto;
}

button[data-action="edit-announcement"],
button[data-action="delete-announcement"] {
  position: relative;
  z-index: 6;
}

.announcement-attachments {
  margin-top: 12px;
  border-top: 1px dashed #bfd2ef;
  padding-top: 12px;
  display: grid;
  gap: 12px;
}

.announcement-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.announcement-image {
  margin: 0;
  border: 1px solid #cddcf4;
  border-radius: 12px;
  padding: 8px;
  background: #eff4fc;
}

.announcement-image-link {
  display: block;
  text-decoration: none;
}

.announcement-image img {
  width: 100%;
  height: 190px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.announcement-image figcaption {
  margin-top: 8px;
  font-size: 0.84rem;
  color: #334155;
  word-break: break-word;
}

.announcement-files {
  display: grid;
  gap: 10px;
}

.announcement-file {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid #bdd2f1;
  border-radius: 12px;
  background: #eef4ff;
  padding: 10px 12px;
}

.announcement-file span {
  flex: 1;
  overflow-wrap: anywhere;
}

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

.announcement-file a {
  text-decoration: none;
  color: #264579;
  font-weight: 700;
  border: 1px solid #b8cced;
  border-radius: 999px;
  background: #f7fbff;
  padding: 5px 10px;
}

.announcement-pdf-preview {
  border: 1px solid #c5d7f2;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.announcement-pdf-preview iframe {
  width: 100%;
  height: 340px;
  border: 0;
  pointer-events: none;
}

.attachment-manager {
  margin-top: 8px;
  margin-bottom: 12px;
  border: 1px dashed #cad7eb;
  border-radius: 12px;
  padding: 10px;
  background: #f4f8fe;
}

.attachment-manager h4 {
  margin-top: 0;
  margin-bottom: 8px;
}

.attachment-check {
  margin-bottom: 8px;
}

.attachment-check:last-child {
  margin-bottom: 0;
}

.hidden {
  display: none !important;
}

@keyframes rise-in {
  from {
    opacity: 0;
    filter: blur(1.5px);
  }

  to {
    opacity: 1;
    filter: blur(0);
  }
}

@media (max-width: 900px) {
  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }

  .top-banner {
    padding: 15px;
  }

  .brand h1,
  .brand h2 {
    font-size: 1.1rem;
  }

  .user-badge {
    width: 100%;
    justify-content: space-between;
  }

  .role-nav .nav-btn {
    flex: 1 1 calc(50% - 8px);
  }

  .podium-chart {
    gap: 8px;
  }

  .podium-card {
    padding: 10px 8px;
  }

  .podium-card.place-1 {
    min-height: 180px;
    transform: translateY(-8px);
  }

  .podium-card.place-2 {
    min-height: 152px;
  }

  .podium-card.place-3 {
    min-height: 140px;
  }

  .weekly-schedule {
    grid-template-columns: 1fr;
  }

  .schedule-arrow {
    display: none;
  }

  .announcement-images {
    grid-template-columns: 1fr;
  }

  .announcement-image img {
    height: 220px;
  }

  .announcement-file {
    flex-direction: column;
  }

  .announcement-pdf-preview iframe {
    height: 260px;
  }

  .alert-host {
    inset-inline-start: 10px;
    inset-inline-end: 10px;
    width: auto;
    bottom: 10px;
  }

  .ranking-list li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .term-report-header {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .term-report-header img {
    margin: 0 auto;
  }
}
