:root {
  --ach-bg: #f6f8fc;
  --ach-surface: #ffffff;
  --ach-text: #0d1b2a;
  --ach-muted: #52637a;
  --ach-primary: #0f4c81;
  --ach-secondary: #1e88e5;
  --ach-border: rgba(15, 76, 129, 0.15);
}

html[data-theme="dark"] {
  --ach-bg: #0a1420;
  --ach-surface: #112030;
  --ach-text: #ebf2ff;
  --ach-muted: #9cb2cc;
  --ach-primary: #7fc8ff;
  --ach-secondary: #9be7ff;
  --ach-border: rgba(127, 200, 255, 0.25);
}

body {
  background:
    radial-gradient(circle at 10% 10%, rgba(30, 136, 229, 0.15), transparent 30%),
    radial-gradient(circle at 90% 20%, rgba(15, 76, 129, 0.15), transparent 35%),
    var(--ach-bg);
  color: var(--ach-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .25s ease, color .25s ease;
}

body > main {
  flex: 1 0 auto;
}

.pwa-ptr-indicator {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translate(-50%, -120%);
  opacity: 0;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--ach-border);
  background: var(--ach-surface);
  color: var(--ach-text);
  box-shadow: 0 .5rem 1.2rem rgba(0, 0, 0, 0.16);
  z-index: 1085;
  pointer-events: none;
  transition: transform .16s ease, opacity .16s ease;
}

.pwa-ptr-indicator.is-visible {
  opacity: .98;
}

.pwa-ptr-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--ach-primary) 30%, transparent);
  border-top-color: var(--ach-primary);
  animation: ptrSpin .9s linear infinite;
  animation-play-state: paused;
}

.pwa-ptr-indicator.is-ready .pwa-ptr-spinner,
.pwa-ptr-indicator.is-refreshing .pwa-ptr-spinner {
  animation-play-state: running;
}

.pwa-ptr-label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .01em;
}

@keyframes ptrSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ach-navbar {
  background: linear-gradient(100deg, #0b2741 0%, #124f80 52%, #1b7ebf 100%);
}

.ach-admin-subnav {
  background: var(--ach-surface);
}

.admin-subnav-list {
  display: flex;
  flex-wrap: nowrap;
  gap: .25rem;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: .45rem 0;
}

.admin-subnav-list .nav-link {
  border-radius: .65rem;
  color: var(--ach-primary);
  font-weight: 600;
  font-size: .92rem;
  padding: .42rem .72rem;
  white-space: nowrap;
}

.admin-subnav-list .nav-link:hover {
  background: rgba(15, 76, 129, 0.08);
}

.admin-subnav-list .nav-link.active {
  background: var(--ach-primary);
  color: #f5fbff;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-switch-track {
  width: 48px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.45);
  position: relative;
  transition: background .2s ease;
}

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fefefe;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform .2s ease;
}

.theme-switch input:checked + .theme-switch-track {
  background: rgba(127, 200, 255, 0.45);
}

.theme-switch input:checked + .theme-switch-track .theme-switch-thumb {
  transform: translateX(22px);
}

.theme-switch-label {
  color: #f8fbff;
  font-size: .88rem;
  font-weight: 700;
  min-width: 72px;
}

.navbar .nav-link,
.navbar .navbar-brand,
.navbar .navbar-brand small {
  color: #f8fbff !important;
}

.brand-logo {
  width: 46px;
  height: 46px;
}

.hero {
  color: #f5faff;
  background: linear-gradient(130deg, #0e2f4d 0%, #135d95 50%, #40a4d9 100%);
  box-shadow: 0 1rem 2rem rgba(10, 30, 50, 0.25);
  animation: fadeUp .55s ease both;
}

.ach-card {
  border: 1px solid var(--ach-border);
  background: var(--ach-surface);
  color: var(--ach-text);
  box-shadow: 0 .5rem 1.5rem rgba(15, 76, 129, 0.08);
}

.announcement-date {
  color: var(--ach-muted);
  font-size: .92rem;
}

.announcement-header {
  display: flex;
  align-items: center;
}

.announcement-type-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border-radius: 999px;
  padding: .26rem .6rem;
  font-size: .78rem;
  font-weight: 700;
}

.announcement-type-pill svg {
  flex: 0 0 auto;
}

.announcement-type-subject {
  background: #1565c0;
  color: #fff;
}

.announcement-type-admin {
  background: #c62828;
  color: #fff;
}

.announcement-type-other {
  background: #f9c74f;
  color: #1f1f1f;
}

.timeline {
  border-left: 4px solid var(--ach-primary);
  padding-left: 1rem;
}

.timeline-item {
  margin-bottom: .75rem;
  padding: .75rem 1rem;
  border-radius: .7rem;
  background: var(--ach-surface);
  border: 1px solid var(--ach-border);
}

.semester-timeline {
  overflow: hidden;
}

.semester-progress-track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: rgba(15, 76, 129, 0.16);
  border: 1px solid var(--ach-border);
}

.semester-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f4c81 0%, #1e88e5 70%, #59b4ef 100%);
  transition: width .3s ease;
}

.semester-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.semester-marker-dot {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ach-surface);
  border: 3px solid var(--ach-primary);
  box-shadow: 0 0 0 2px rgba(15, 76, 129, 0.18);
}

.subject-layout .subject-activities-table th,
.subject-layout .subject-activities-table td {
  white-space: nowrap;
  font-size: .82rem;
}

@media (min-width: 992px) {
  .subject-layout > .subject-main-col {
    width: 70%;
  }

  .subject-layout > .subject-side-col {
    width: 30%;
  }
}

.semester-marker-label {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: .72rem;
  color: var(--ach-muted);
}

.library-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  align-items: center;
  font-size: .95rem;
}

.breadcrumb-link {
  color: var(--ach-primary);
  text-decoration: none;
  font-weight: 600;
}

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

.breadcrumb-separator {
  color: var(--ach-muted);
}

.file-manager-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.library-card {
  border: 1px solid var(--ach-border);
  border-radius: .9rem;
  background: var(--ach-surface);
  color: var(--ach-text);
  padding: .9rem .75rem;
  text-align: center;
  min-height: 134px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: .55rem;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.library-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 .55rem 1.2rem rgba(15, 76, 129, 0.13);
  border-color: rgba(15, 76, 129, 0.35);
}

.library-icon {
  flex: 0 0 auto;
}

.folder-icon {
  width: 58px;
  height: 40px;
  border-radius: .45rem;
  background: linear-gradient(180deg, #ffd86b 0%, #f5b940 100%);
  position: relative;
}

.folder-icon::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 8px;
  width: 24px;
  height: 12px;
  border-radius: .35rem .35rem 0 0;
  background: #ffd86b;
}

.file-icon {
  width: 58px;
  height: 72px;
  border-radius: .5rem;
  background: linear-gradient(180deg, #f1f4f8 0%, #dbe3ed 100%);
  border: 1px solid #c2cedd;
  color: #4d5d73;
  font-size: .74rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .25rem;
}

.library-name {
  margin: 0;
  font-size: .85rem;
  line-height: 1.25;
  word-break: break-word;
}

.semester-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  font-size: .88rem;
  color: var(--ach-muted);
}

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
}

.schedule-day-column {
  min-height: 260px;
}

.schedule-item {
  border: 1px solid var(--ach-border);
  border-radius: .9rem;
  padding: .6rem .75rem .75rem;
  background: var(--ach-surface);
}

.schedule-time {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .88rem;
  color: var(--ach-muted);
  margin-bottom: .35rem;
}

.schedule-clock {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.schedule-subject {
  font-weight: 600;
}

.schedule-subject a {
  color: var(--ach-primary);
  text-decoration: none;
}

.schedule-subject a:hover {
  text-decoration: underline;
}

.schedule-empty {
  height: calc(100% - 2rem);
  min-height: 170px;
  border: 1px dashed var(--ach-border);
  border-radius: .9rem;
  display: grid;
  place-content: center;
  gap: .3rem;
  text-align: center;
  font-weight: 600;
  color: var(--ach-muted);
}

.schedule-empty-icon {
  font-size: 1.8rem;
  line-height: 1;
}

@media (max-width: 1200px) {
  .schedule-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 992px) {
  .schedule-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .semester-progress-meta {
    flex-direction: column;
  }

  .semester-marker-label {
    display: none;
  }

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

.ach-footer {
  background: var(--ach-surface);
  margin-top: auto;
}

.ach-footer a {
  color: #000 !important;
  text-decoration: none;
}

.ach-footer a:hover {
  color: #000 !important;
  text-decoration: underline;
}

.legal-content {
  background: var(--ach-surface);
  border: 1px solid var(--ach-border);
  border-radius: 1rem;
  padding: 1.5rem;
}

.table,
.list-group-item,
.form-control,
.form-select,
.accordion-item {
  background-color: var(--ach-surface);
  color: var(--ach-text);
  border-color: var(--ach-border);
}

.text-muted {
  color: var(--ach-muted) !important;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.next-academic-card {
  border-radius: 1.2rem;
  border: 1px solid color-mix(in srgb, var(--ach-primary) 24%, transparent);
  overflow: hidden;
  box-shadow: 0 .7rem 1.7rem rgba(15, 76, 129, 0.11);
}

.next-academic-card-header {
  border-bottom: 1px solid color-mix(in srgb, var(--ach-primary) 20%, transparent);
  background: linear-gradient(96deg, #0f4c81 0%, #1b7ebf 100%);
  color: #eef8ff;
  padding: .8rem 1rem;
  text-align: center;
}

.next-academic-card-header .h5 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.next-academic-card-body {
  background:
    radial-gradient(circle at 100% 0, rgba(30, 136, 229, 0.17), transparent 42%),
    linear-gradient(145deg, rgba(15, 76, 129, 0.12), rgba(30, 136, 229, 0.05));
}

.next-class-card {
  border-radius: .95rem;
  border: 1px solid color-mix(in srgb, var(--ach-primary) 18%, transparent);
  background: color-mix(in srgb, var(--ach-surface) 90%, #fff 10%);
  padding: .95rem 1rem;
  text-align: center;
}

.next-class-title {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.22;
}

.next-class-info-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: .55rem;
  color: var(--ach-muted);
  font-size: .93rem;
  margin-bottom: .46rem;
}

.next-class-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  flex: 0 0 24px;
  color: var(--ach-primary);
  background: color-mix(in srgb, var(--ach-primary) 11%, #fff 89%);
}

.next-class-link-btn {
  border-radius: .75rem;
  padding: .5rem .85rem;
  font-weight: 700;
}

.next-class-card .next-class-link-btn {
  display: inline-flex;
  margin-left: auto;
  margin-right: auto;
}

.next-class-empty {
  border: 1px dashed color-mix(in srgb, var(--ach-primary) 35%, transparent);
  border-radius: .95rem;
  padding: 1.1rem;
  display: grid;
  justify-items: center;
  text-align: center;
  background: color-mix(in srgb, var(--ach-surface) 92%, #fff 8%);
}

.next-class-empty-emoji {
  font-size: 2.1rem;
  line-height: 1;
  margin-bottom: .4rem;
}

.next-class-empty-text {
  font-weight: 700;
  color: var(--ach-muted);
}

.admin-period-form .form-label {
  margin-bottom: .35rem;
}

.engagement-kpi {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .45rem 0;
  border-bottom: 1px solid var(--ach-border);
}

.engagement-kpi:last-of-type {
  border-bottom: 0;
}

.admin-chart-wrap {
  position: relative;
  height: 320px;
}

.admin-chart-wrap #growthChart {
  width: 100% !important;
  height: 100% !important;
}

.locked-user-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  border: 1px solid var(--ach-border);
  border-radius: .8rem;
  padding: .55rem .65rem;
}

.locked-user-avatar,
.profile-avatar-preview {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--ach-border);
  background: var(--ach-surface);
}

.profile-avatar-preview {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 3px solid #fff;
  outline: 4px solid #c9c9c9;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.45);
}

@media (max-width: 768px) {
  .next-academic-card-header,
  .next-academic-card-body {
    padding-left: .85rem;
    padding-right: .85rem;
  }

  .next-class-title {
    font-size: 1.05rem;
  }
}
