:root {
  --page: #f4f7fa;
  --white: #ffffff;
  --ink: #102635;
  --muted: #5f7280;
  --line: #d8e4eb;
  --soft: #edf4f7;
  --green: #08724f;
  --green-dark: #064b36;
  --blue: #075fc4;
  --blue-dark: #073a75;
  --blue-soft: #e8f2ff;
  --gold: #d6a72d;
  --gold-soft: #fff6dc;
  --danger: #c54135;
  --danger-soft: #fff0ee;
  --shadow: 0 18px 44px rgba(24, 53, 68, 0.1);
  --sidebar-width: 270px;
  --radius: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

body.nav-open {
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button,
select {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  color: #f5fffb;
  background:
    linear-gradient(180deg, rgba(4, 75, 54, 0.96), rgba(3, 50, 42, 0.98)),
    #064b36;
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 30;
}

.brand {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand img {
  width: 58px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid rgba(255, 255, 255, 0.7);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
  line-height: 1.2;
}

.brand small {
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.84rem;
}

.side-nav {
  display: grid;
  gap: 7px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 12px;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.82);
  font-weight: 760;
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.side-nav a:hover,
.side-nav a:focus-visible,
.side-nav a.is-active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(2px);
}

.nav-icon {
  width: 28px;
  aspect-ratio: 1;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.78rem;
  font-weight: 900;
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-note span {
  display: block;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.84rem;
}

.sidebar-note strong {
  display: block;
  margin-top: 6px;
  font-size: 1.05rem;
}

.main-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 76px;
  padding: 13px clamp(18px, 3vw, 36px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar p,
.topbar strong {
  margin: 0;
}

.topbar p {
  color: var(--muted);
  font-size: 0.84rem;
}

.topbar strong {
  display: block;
  margin-top: 4px;
  font-size: 1.12rem;
}

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

.menu-button {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  place-items: center;
  gap: 4px;
  padding: 9px;
}

.menu-button span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--ink);
}

main {
  padding: 26px clamp(18px, 3vw, 36px) 46px;
}

.view {
  animation: fadeUp 260ms ease both;
}

.view[hidden] {
  display: none;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.school-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.school-header h1,
.page-heading h1 {
  margin: 0;
  color: var(--green-dark);
  font-size: clamp(1.9rem, 3vw, 2.8rem);
  line-height: 1.1;
}

.school-header p,
.page-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.session-card {
  min-width: 170px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.session-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.session-card strong {
  display: block;
  margin-top: 5px;
  color: var(--blue);
  font-size: 1.8rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.96fr) minmax(460px, 1.04fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.panel:not(.enrollment-card) {
  padding: 18px;
}

.panel-band {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  color: var(--white);
  background: linear-gradient(135deg, var(--blue), #0480d6);
  border-radius: var(--radius) var(--radius) 0 0;
}

.panel-mark {
  width: 42px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.16);
  font-weight: 900;
}

.panel-band h2,
.panel-band p {
  margin: 0;
}

.panel-band p {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.86);
}

.mini-enrollment,
.capacity-summary {
  padding: 18px;
}

.mini-enrollment {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.mini-enrollment .primary-button {
  grid-column: 1 / -1;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-title.tight {
  margin-bottom: 8px;
}

.panel-title h2,
.panel-title h3,
.student-result h2,
.control-cards h3,
.announcement-item h3 {
  margin: 0;
}

.panel-title h2 {
  font-size: 1.28rem;
}

.panel-title h3 {
  font-size: 1.02rem;
}

.panel-title p,
.student-result p,
.control-cards p,
.helper-text,
.form-status {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.capacity-table {
  display: grid;
  gap: 2px;
}

.capacity-row {
  display: grid;
  grid-template-columns: 70px minmax(120px, 1fr) 78px 92px;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.capacity-row.header {
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.mini-bar {
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--soft);
}

.mini-bar i {
  display: block;
  width: var(--fill);
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.seat-pill,
.status-pill,
.announcement-meta span,
.panel-title > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 0.82rem;
  font-weight: 850;
}

.status-pill.low,
.seat-pill.low {
  color: #8a5f00;
  background: var(--gold-soft);
}

.status-pill.full,
.seat-pill.full {
  color: var(--danger);
  background: var(--danger-soft);
}

.controls-card,
.announcements-card {
  min-height: 280px;
}

.control-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.control-cards > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  background: #fbfdfe;
}

.control-cards ul,
.algorithm-list {
  margin: 14px 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.page-heading {
  margin-bottom: 22px;
  max-width: 760px;
}

.split-layout,
.admin-layout,
.announcement-layout,
.portal-layout {
  display: grid;
  gap: 18px;
  align-items: start;
}

.split-layout,
.admin-layout,
.announcement-layout {
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
}

.portal-layout {
  grid-template-columns: minmax(320px, 0.72fr) minmax(0, 1.28fr);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(7, 95, 196, 0.58);
  box-shadow: 0 0 0 4px rgba(7, 95, 196, 0.11);
}

.wide-label {
  margin: 14px 0;
}

.primary-button,
.ghost-button,
.link-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 0 15px;
  border: 1px solid transparent;
  font-weight: 850;
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.primary-button {
  color: var(--white);
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  box-shadow: 0 12px 24px rgba(8, 114, 79, 0.22);
}

.ghost-button {
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
}

.link-button {
  min-height: 36px;
  padding: 0;
  color: var(--blue);
  background: transparent;
  white-space: nowrap;
}

.small-button {
  min-height: 42px;
}

.full-button {
  width: 100%;
}

.primary-button:hover,
.primary-button:focus-visible,
.ghost-button:hover,
.ghost-button:focus-visible,
.link-button:hover,
.link-button:focus-visible {
  transform: translateY(-1px);
}

.form-status {
  min-height: 25px;
  font-weight: 850;
}

.form-status.success {
  color: var(--green);
}

.form-status.error {
  color: var(--danger);
}

.section-list {
  display: grid;
  gap: 10px;
}

.section-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfe;
}

.section-card.is-recommended {
  border-color: rgba(8, 114, 79, 0.34);
  background: #eff9f5;
}

.section-card.is-full {
  background: var(--danger-soft);
}

.section-card-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.section-card strong {
  font-size: 1.18rem;
}

.capacity-bar {
  height: 9px;
  margin: 12px 0 8px;
  border-radius: 99px;
  background: var(--soft);
  overflow: hidden;
}

.capacity-bar i {
  display: block;
  height: 100%;
  width: var(--fill);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #13a477);
}

.section-card.is-full .capacity-bar i {
  background: var(--danger);
}

.section-card small {
  color: var(--muted);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.student-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.student-shortcuts button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  padding: 8px 10px;
  color: var(--green-dark);
  font-weight: 850;
}

.student-profile {
  display: grid;
  gap: 16px;
}

.profile-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.profile-top h2 {
  margin: 0;
}

.profile-code {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--gold-soft);
  color: #7f620e;
  font-weight: 900;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fafc;
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.detail-grid strong {
  display: block;
  margin-top: 5px;
}

.control-stack {
  display: grid;
  gap: 12px;
}

.schedule-wrap {
  overflow-x: auto;
}

.schedule-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.schedule-wrap.compact .schedule-table {
  min-width: 100%;
  table-layout: fixed;
  font-size: 0.78rem;
}

.schedule-table th,
.schedule-table td {
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.schedule-wrap.compact .schedule-table th,
.schedule-wrap.compact .schedule-table td {
  padding: 8px 6px;
}

.schedule-wrap.compact .schedule-table th:first-child,
.schedule-wrap.compact .schedule-table td:first-child {
  width: 86px;
}

.schedule-table th {
  color: var(--blue-dark);
  background: #f3f8fb;
  font-size: 0.82rem;
}

.schedule-table td:first-child {
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.schedule-table select {
  min-width: 126px;
  padding: 8px;
  font-size: 0.86rem;
}

.announcement-form {
  display: grid;
  gap: 13px;
}

.announcement-feed {
  display: grid;
  gap: 12px;
}

.announcement-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfe;
}

.announcement-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
}

.announcement-meta span.is-urgent {
  color: var(--danger);
  background: var(--danger-soft);
}

.announcement-item p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.58;
}

.compact-feed .announcement-item:nth-child(n + 5) {
  display: none;
}

@media (max-width: 1180px) {
  .dashboard-grid,
  .split-layout,
  .admin-layout,
  .announcement-layout,
  .portal-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, var(--sidebar-width));
    transform: translateX(-100%);
    transition: transform 220ms ease;
    box-shadow: var(--shadow);
  }

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

  .menu-button {
    display: grid;
  }
}

@media (max-width: 720px) {
  main,
  .topbar {
    padding-inline: 14px;
  }

  .topbar-actions .ghost-button {
    display: none;
  }

  .school-header,
  .panel-title {
    display: grid;
  }

  .mini-enrollment,
  .form-grid,
  .control-cards,
  .detail-grid,
  .search-row,
  .profile-top {
    grid-template-columns: 1fr;
  }

  .capacity-row {
    grid-template-columns: 62px minmax(90px, 1fr) 70px;
  }

  .capacity-row span:last-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
