:root {
  --font-ui: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --sidebar-width: 286px;
  --topbar-height: 72px;
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --ink-950: #111827;
  --ink-850: #1f2937;
  --ink-700: #374151;
  --ink-500: #6b7280;
  --ink-300: #d1d5db;
  --ink-150: #e5e7eb;
  --ink-075: #f3f4f6;
  --paper: #ffffff;
  --paper-soft: #f8fafc;
  --teal: #0f766e;
  --teal-soft: #ccfbf1;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --coral: #e11d48;
  --coral-soft: #ffe4e6;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --violet: #7c3aed;
  --violet-soft: #ede9fe;
  --shadow-xs: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-sm: 0 10px 28px rgba(17, 24, 39, 0.08);
  --shadow-md: 0 20px 55px rgba(17, 24, 39, 0.12);
  --shadow-lg: 0 32px 80px rgba(17, 24, 39, 0.18);
  --line: rgba(17, 24, 39, 0.1);
  --glass: rgba(255, 255, 255, 0.76);
  --motion-fast: 140ms ease;
  --motion: 220ms ease;
  --motion-slow: 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

html {
  min-height: 100%;
  font-size: 16px;
  scrollbar-gutter: stable;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink-850);
  font-family: var(--font-ui);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.06), transparent 280px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.05), transparent 360px),
    var(--paper-soft);
}

.app-nav-toggle i {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.25rem;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  color: #1d4ed8;
}

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 3px;
}

.page-transition {
  position: fixed;
  inset: 0;
  z-index: 3000;
  pointer-events: none;
  background: rgba(248, 250, 252, 0.74);
  opacity: 0;
  transition: opacity var(--motion);
}

body.is-leaving .page-transition,
body.is-submitting .page-transition {
  opacity: 1;
}

.app-topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1030;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(17, 24, 39, 0.92);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
}

.app-navbar {
  min-height: var(--topbar-height);
  padding: 0.6rem 1rem;
  --bs-navbar-toggler-border-color: rgba(255, 255, 255, 0.22);
  --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.86%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.app-brand {
  display: inline-flex;
  gap: 0.8rem;
  align-items: center;
  color: #fff !important;
  min-width: 0;
}

.brand-mark,
.sidebar-avatar,
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff;
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.28);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 1.1rem;
}

.brand-copy {
  display: grid;
  line-height: 1.05;
}

.brand-name {
  font-weight: 800;
  letter-spacing: 0;
}

.brand-subtitle {
  margin-top: 0.2rem;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.78rem;
  letter-spacing: 0;
}

.topbar-actions .nav-link,
.app-login-link {
  color: rgba(255, 255, 255, 0.82) !important;
}

.app-login-link {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem !important;
  background: rgba(255, 255, 255, 0.08);
}

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  color: var(--teal-soft);
  border: 1px solid rgba(204, 251, 241, 0.22);
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.18);
  font-size: 0.9rem;
  white-space: nowrap;
}

.user-menu-link {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.user-avatar,
.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 800;
}

.user-name {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-dropdown {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.app-dropdown .dropdown-item {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  min-height: 38px;
}

.app-sidebar {
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  z-index: 1020;
  width: var(--sidebar-width);
  padding: 1rem;
  background: rgba(255, 255, 255, 0.9);
  border-right: 1px solid rgba(17, 24, 39, 0.08);
  box-shadow: 12px 0 40px rgba(17, 24, 39, 0.06);
  backdrop-filter: blur(18px);
}

.sidebar-scroll {
  height: 100%;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.09), rgba(217, 119, 6, 0.08));
}

.sidebar-profile strong,
.sidebar-profile span {
  display: block;
}

.sidebar-profile span {
  max-width: 170px;
  overflow: hidden;
  color: var(--ink-500);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  display: grid;
  gap: 0.2rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.sidebar-section-title {
  padding: 1.05rem 0.75rem 0.35rem;
  color: var(--ink-500);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 42px;
  padding: 0.65rem 0.75rem;
  color: var(--ink-700);
  border-radius: var(--radius-md);
  transition: color var(--motion), background var(--motion), transform var(--motion), box-shadow var(--motion);
}

.sidebar-nav a i {
  width: 20px;
  color: var(--teal);
  text-align: center;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--ink-950);
  background: #fff;
  box-shadow: var(--shadow-xs);
  transform: translateX(4px);
}

.sidebar-nav a.active {
  border: 1px solid rgba(15, 118, 110, 0.16);
}

.app-main {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: calc(var(--topbar-height) + 1.5rem) 1.5rem 2.5rem;
  animation: content-enter var(--motion-slow);
}

.app-main-public {
  margin-left: 0;
  padding: calc(var(--topbar-height) + 1rem) 1rem 2rem;
}

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

.toast-zone {
  max-width: 1120px;
  margin: 0 auto;
}

.app-alert {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.auth-page {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.76fr);
  gap: 1.25rem;
  align-items: stretch;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.auth-hero,
.auth-panel,
.page-hero,
.surface-card,
.metric-card,
.role-card,
.action-tile,
.empty-state,
.stat-box,
.info-box,
.recent-grade-item {
  border: 1px solid rgba(17, 24, 39, 0.08);
  background: var(--glass);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
}

.auth-hero,
.auth-panel {
  min-width: 0;
}

.auth-hero {
  position: relative;
  overflow: hidden;
  min-height: 620px;
  padding: clamp(1.5rem, 3vw, 2.4rem);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(15, 118, 110, 0.88)),
    var(--ink-950);
  color: #fff;
}

.auth-hero::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -80px;
  width: 320px;
  height: 320px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
}

.auth-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  padding: 0.35rem 0.7rem;
  color: var(--teal-soft);
  border: 1px solid rgba(204, 251, 241, 0.24);
  border-radius: 999px;
  background: rgba(204, 251, 241, 0.08);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.auth-title,
.page-hero h1 {
  max-width: 760px;
  margin: 1rem 0 0;
  color: inherit;
  font-size: 2.35rem;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.05;
}

.auth-copy,
.page-hero p {
  max-width: 720px;
  margin: 1rem 0 0;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.65;
}

.auth-role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: auto;
  padding-top: 2rem;
}

.role-card {
  position: relative;
  display: grid;
  gap: 0.55rem;
  padding: 1rem;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font: inherit;
  transition: transform var(--motion), background var(--motion), border-color var(--motion), box-shadow var(--motion);
}

.role-card:not(button) {
  cursor: default;
}

.role-card:not(button):hover {
  transform: none;
}

.role-card:hover,
.role-card.is-selected {
  transform: translateY(-4px);
  border-color: rgba(204, 251, 241, 0.42);
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.role-card i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  color: var(--ink-950);
  border-radius: var(--radius-md);
  background: var(--teal-soft);
}

.role-card strong,
.role-card span {
  display: block;
}

.role-card span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.88rem;
  line-height: 1.45;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 620px;
  padding: clamp(1.5rem, 3vw, 2.2rem);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.88);
}

.auth-panel h2,
.form-title {
  margin: 0;
  color: var(--ink-950);
  font-size: 1.75rem;
  font-weight: 850;
  letter-spacing: 0;
}

.auth-panel .text-muted {
  line-height: 1.6;
}

.selected-role-note {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  min-height: 54px;
  padding: 0.85rem;
  margin: 1rem 0;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: var(--radius-md);
  background: rgba(204, 251, 241, 0.36);
  color: var(--ink-700);
  line-height: 1.45;
}

.selected-role-note i {
  color: var(--teal);
  margin-top: 0.1rem;
}

.form-control,
.form-select,
.input-group-text {
  min-height: 44px;
  border-color: rgba(17, 24, 39, 0.12);
  border-radius: var(--radius-sm);
}

.input-group > .form-control,
.input-group > .form-select {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.input-group > .input-group-text {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: rgba(15, 118, 110, 0.5);
  box-shadow: 0 0 0 0.22rem rgba(15, 118, 110, 0.14);
}

.form-label {
  color: var(--ink-700);
  font-weight: 700;
}

.btn {
  border-radius: var(--radius-sm);
  font-weight: 750;
  letter-spacing: 0;
  transition: transform var(--motion), box-shadow var(--motion), background var(--motion), border-color var(--motion);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xs);
}

.btn-primary {
  border-color: var(--teal);
  background: var(--teal);
}

.btn-primary:hover,
.btn-primary:focus {
  border-color: #0d5f59;
  background: #0d5f59;
}

.btn-success {
  border-color: var(--green);
  background: var(--green);
}

.btn-info {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.btn-warning {
  color: var(--ink-950);
  border-color: var(--amber);
  background: #fbbf24;
}

.btn-danger {
  border-color: var(--coral);
  background: var(--coral);
}

.export-btn {
  color: #fff;
  border: none;
  background: linear-gradient(135deg, var(--teal), var(--green));
}

.page-hero {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  align-items: flex-end;
  padding: clamp(1.25rem, 2.4vw, 2rem);
  margin: 0 0 1.25rem;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(31, 41, 55, 0.9)),
    var(--ink-950);
  color: #fff;
}

.page-hero p {
  color: rgba(255, 255, 255, 0.74);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: flex-end;
}

.hero-actions .btn {
  white-space: nowrap;
}

.metric-grid,
.action-grid,
.dashboard-grid,
.portal-grid {
  display: grid;
  gap: 1rem;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1.25rem;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
  margin-top: 1.25rem;
}

.portal-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.metric-card,
.surface-card,
.action-tile,
.empty-state {
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.86);
}

.metric-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 0.75rem;
  padding: 1.15rem;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--teal);
}

.metric-card--blue::before,
.border-left-primary {
  border-left-color: var(--blue) !important;
}

.metric-card--green::before,
.border-left-success {
  border-left-color: var(--green) !important;
}

.metric-card--amber::before,
.border-left-warning {
  border-left-color: var(--amber) !important;
}

.metric-card--coral::before,
.border-left-danger {
  border-left-color: var(--coral) !important;
}

.metric-card--blue::before {
  background: var(--blue);
}

.metric-card--green::before {
  background: var(--green);
}

.metric-card--amber::before {
  background: var(--amber);
}

.metric-card--coral::before {
  background: var(--coral);
}

.metric-card .metric-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  color: var(--teal);
  border-radius: var(--radius-md);
  background: var(--teal-soft);
}

.metric-card--blue .metric-icon {
  color: var(--blue);
  background: var(--blue-soft);
}

.metric-card--green .metric-icon {
  color: var(--green);
  background: var(--green-soft);
}

.metric-card--amber .metric-icon {
  color: var(--amber);
  background: var(--amber-soft);
}

.metric-card--coral .metric-icon {
  color: var(--coral);
  background: var(--coral-soft);
}

.metric-label,
.text-xs {
  color: var(--ink-500);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric-value {
  margin: 0;
  color: var(--ink-950);
  font-size: 2rem;
  font-weight: 850;
  line-height: 1;
  overflow-wrap: anywhere;
}

.metric-caption {
  color: var(--ink-500);
  font-size: 0.9rem;
}

.surface-card {
  overflow: hidden;
}

.surface-card-header,
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 58px;
  padding: 1rem 1.15rem;
  color: var(--ink-950);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.surface-card-header h2,
.surface-card-header h3,
.surface-card-header h4,
.surface-card-header h5,
.card-header h2,
.card-header h3,
.card-header h4,
.card-header h5 {
  margin: 0;
  font-size: 1rem;
  font-weight: 850;
}

.surface-card-body,
.card-body {
  padding: 1.15rem;
}

.card {
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-sm);
  transition: transform var(--motion), box-shadow var(--motion), border-color var(--motion);
}

.card:hover,
.surface-card:hover,
.metric-card:hover,
.action-tile:hover {
  border-color: rgba(15, 118, 110, 0.18);
  box-shadow: var(--shadow-md);
}

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

.action-tile {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 88px;
  padding: 1rem;
  color: var(--ink-850);
  transition: transform var(--motion), box-shadow var(--motion), border-color var(--motion);
}

.action-tile:hover {
  color: var(--ink-950);
  transform: translateY(-4px);
}

.action-tile i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  color: #fff;
  border-radius: var(--radius-md);
  background: var(--ink-850);
}

.action-tile small {
  display: block;
  color: var(--ink-500);
  font-size: 0.85rem;
}

.table {
  margin-bottom: 0;
  vertical-align: middle;
}

.table thead,
.grade-table thead {
  color: var(--ink-700);
  background: rgba(243, 244, 246, 0.82) !important;
}

.table > :not(caption) > * > * {
  padding: 0.86rem 0.8rem;
}

.table-hover > tbody > tr,
.grade-row-item,
.user-card {
  transition: background var(--motion), transform var(--motion), box-shadow var(--motion);
}

.table-hover > tbody > tr:hover,
.grade-row-item:hover {
  background: rgba(204, 251, 241, 0.2);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0;
}

.badge-grade {
  min-width: 44px;
  color: #fff;
  font-size: 0.92rem;
}

.badge-grade-a {
  background: var(--green);
}

.badge-grade-b {
  background: var(--blue);
}

.badge-grade-c {
  background: var(--amber);
}

.badge-grade-d {
  background: var(--violet);
}

.badge-grade-f {
  background: var(--coral);
}

.info-box,
.stat-box,
.recent-grade-item,
.comment-box,
.comment-box-inline {
  padding: 0.85rem;
  border-radius: var(--radius-md);
  background: rgba(248, 250, 252, 0.9);
  border-left: 4px solid var(--teal);
}

.info-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.info-item:last-child {
  border-bottom: none;
}

.comment-box,
.comment-box-inline {
  display: inline-flex;
  gap: 0.5rem;
  align-items: flex-start;
  max-width: 100%;
  border-left-color: var(--blue);
}

.grade-management-table,
.user-table {
  overflow: hidden;
  border-radius: var(--radius-md);
}

.grade-management-table thead,
.user-table thead {
  color: var(--ink-700) !important;
  background: rgba(243, 244, 246, 0.92) !important;
}

.grade-management-table thead th {
  border: none;
  font-weight: 800;
}

.grade-management-row,
.user-row {
  transition: background var(--motion), transform var(--motion), box-shadow var(--motion), border-color var(--motion);
}

.grade-management-row {
  border-left: 4px solid transparent;
}

.grade-management-row:hover,
.user-row:hover {
  background: rgba(204, 251, 241, 0.2);
  box-shadow: var(--shadow-xs);
}

.grade-management-row:hover {
  border-left-color: var(--teal);
}

.student-info,
.course-info,
.score-display {
  padding: 0.25rem 0;
}

.student-info strong,
.course-info strong,
.score-display h5 {
  color: var(--ink-950);
  font-weight: 800;
}

.score-display h5 {
  color: var(--teal);
}

.badge-role {
  min-height: 30px;
  padding: 0.35rem 0.7rem;
  color: #fff;
  border-radius: 999px;
  font-size: 0.85rem;
}

.badge-role-management {
  background: var(--coral);
}

.badge-role-teacher {
  background: var(--blue);
}

.badge-role-parent {
  background: var(--green);
}

.badge-role-student {
  background: var(--teal);
}

.nav-tabs {
  border-bottom-color: var(--line);
}

.nav-tabs .nav-link {
  color: var(--ink-500);
  border: none;
  border-bottom: 3px solid transparent;
  font-weight: 750;
}

.nav-tabs .nav-link:hover {
  border-bottom-color: var(--ink-150);
}

.nav-tabs .nav-link.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
  background: transparent;
}

.recent-grade-item {
  margin-bottom: 0.75rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 2rem;
  color: var(--ink-500);
  text-align: center;
}

.empty-state i {
  color: var(--ink-300);
}

.progress {
  background: rgba(17, 24, 39, 0.08);
  border-radius: 999px;
}

.progress-thin {
  height: 7px;
}

.progress-full {
  width: 100%;
}

.max-access-alert {
  max-width: 720px;
}

.inline-select-auto {
  width: auto;
}

.spinner-lg {
  width: 3rem;
  height: 3rem;
}

.ai-result-pre,
.ai-error-pre {
  max-height: 300px;
  overflow-y: auto;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #e5e7eb;
}

.ai-error-pre {
  max-height: 200px;
}

.bg-gradient-primary,
.bg-gradient-success,
.bg-gradient-info {
  color: #fff !important;
  background: linear-gradient(135deg, var(--ink-850), var(--teal)) !important;
}

.bg-primary {
  background-color: var(--teal) !important;
}

.bg-info {
  background-color: var(--blue) !important;
}

.text-primary {
  color: var(--teal) !important;
}

.text-info {
  color: var(--blue) !important;
}

.text-success {
  color: var(--green) !important;
}

.text-warning {
  color: var(--amber) !important;
}

.text-gray-300 {
  color: var(--ink-300) !important;
}

.text-gray-800 {
  color: var(--ink-850) !important;
}

.font-weight-bold {
  font-weight: 800 !important;
}

.border-left-primary,
.border-left-success,
.border-left-info,
.border-left-warning,
.border-left-danger {
  border-left-style: solid !important;
  border-left-width: 4px !important;
}

.border-left-info {
  border-left-color: var(--blue) !important;
}

.border-left-warning {
  border-left-color: var(--amber) !important;
}

.border-left-danger {
  border-left-color: var(--coral) !important;
}

body.is-submitting button[type="submit"] {
  position: relative;
}

body.is-submitting button[type="submit"]::after {
  content: "";
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  margin-left: 0.5rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.12rem;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .metric-grid,
  .action-grid,
  .portal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 992px) {
  :root {
    --topbar-height: 68px;
  }

  .app-sidebar {
    position: sticky;
    top: var(--topbar-height);
    width: 100%;
    height: auto;
    padding: 0.75rem;
    overflow-x: auto;
  }

  .sidebar-scroll {
    overflow: visible;
  }

  .sidebar-profile,
  .sidebar-section-title {
    display: none;
  }

  .sidebar-nav {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.1rem;
  }

  .sidebar-nav li {
    flex: 0 0 auto;
  }

  .sidebar-nav a {
    white-space: nowrap;
  }

  .sidebar-nav a:hover,
  .sidebar-nav a.active {
    transform: translateY(-1px);
  }

  .app-main {
    margin-left: 0;
    padding: 1rem;
  }

  .zs-body-authenticated .app-main {
    padding-top: 1rem;
  }

  .auth-page {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    order: -1;
  }

  .auth-hero,
  .auth-panel {
    min-height: auto;
  }

  .page-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .app-navbar {
    padding: 0.55rem 0.7rem;
  }

  .brand-subtitle,
  .user-name {
    display: none;
  }

  .auth-role-grid,
  .metric-grid,
  .action-grid,
  .portal-grid {
    grid-template-columns: 1fr;
  }

  .auth-title,
  .page-hero h1 {
    font-size: 1.75rem;
  }

  .auth-page {
    gap: 0.85rem;
  }

  .auth-hero,
  .auth-panel,
  .page-hero {
    border-radius: var(--radius-lg);
  }

  .card-body,
  .surface-card-body {
    padding: 0.9rem;
  }

  .table-responsive {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

/* Theme and phase-two application surfaces */
:root,
[data-theme="light"] {
  --app-bg: #f4f7fa;
  --app-surface: #ffffff;
  --app-surface-muted: #f8fafc;
  --app-border: #e2e8f0;
  --app-text: #1f2937;
  --app-text-muted: #64748b;
  --chart-primary: #0f766e;
  --chart-secondary: #2563eb;
  --chart-fill: rgba(15, 118, 110, 0.15);
  --chart-grid: rgba(100, 116, 139, 0.18);
  --chart-text: #475569;
}

[data-theme="dark"] {
  --ink-950: #f8fafc;
  --ink-850: #e2e8f0;
  --ink-700: #cbd5e1;
  --ink-500: #94a3b8;
  --ink-300: #64748b;
  --ink-150: #334155;
  --ink-075: #1e293b;
  --paper: #1e293b;
  --paper-soft: #0f172a;
  --line: rgba(148, 163, 184, 0.22);
  --glass: rgba(30, 41, 59, 0.88);
  --app-bg: #0f172a;
  --app-surface: #1e293b;
  --app-surface-muted: #172033;
  --app-border: #334155;
  --app-text: #f8fafc;
  --app-text-muted: #94a3b8;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-sm: 0 12px 32px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 22px 55px rgba(0, 0, 0, 0.32);
  --chart-primary: #2dd4bf;
  --chart-secondary: #60a5fa;
  --chart-fill: rgba(45, 212, 191, 0.16);
  --chart-grid: rgba(148, 163, 184, 0.2);
  --chart-text: #cbd5e1;
}

body {
  color: var(--app-text);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--teal) 7%, transparent), transparent 280px),
    linear-gradient(90deg, color-mix(in srgb, var(--blue) 5%, transparent), transparent 360px),
    var(--app-bg);
}

[data-theme="dark"] body {
  --bs-body-color: var(--app-text);
  --bs-body-bg: var(--app-bg);
  --bs-border-color: var(--app-border);
  --bs-secondary-color: var(--app-text-muted);
}

.theme-menu-button,
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  transition: background var(--motion), transform var(--motion);
}

.theme-menu-button:hover,
.sidebar-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.sidebar-toggle {
  display: none;
  margin-right: 0.65rem;
}

.theme-menu {
  min-width: 170px;
}

.theme-menu .dropdown-item.active {
  color: var(--teal);
  background: var(--teal-soft);
}

[data-theme="dark"] .app-sidebar {
  border-right-color: var(--app-border);
  background: rgba(17, 24, 39, 0.94);
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .sidebar-profile {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.2), rgba(217, 119, 6, 0.12));
}

[data-theme="dark"] .sidebar-nav a:hover,
[data-theme="dark"] .sidebar-nav a.active {
  background: #1e293b;
}

[data-theme="dark"] .metric-card,
[data-theme="dark"] .surface-card,
[data-theme="dark"] .action-tile,
[data-theme="dark"] .empty-state,
[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .app-dropdown,
[data-theme="dark"] .list-group-item {
  color: var(--app-text);
  border-color: var(--app-border);
  background: rgba(30, 41, 59, 0.94);
}

[data-theme="dark"] .surface-card-header,
[data-theme="dark"] .card-header,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  color: var(--app-text);
  border-color: var(--app-border);
  background: rgba(23, 32, 51, 0.96);
}

[data-theme="dark"] .table {
  --bs-table-color: var(--app-text);
  --bs-table-bg: transparent;
  --bs-table-striped-color: var(--app-text);
  --bs-table-striped-bg: rgba(148, 163, 184, 0.05);
  --bs-table-hover-color: var(--app-text);
  --bs-table-hover-bg: rgba(45, 212, 191, 0.08);
  --bs-table-border-color: var(--app-border);
}

[data-theme="dark"] .table thead,
[data-theme="dark"] .grade-table thead {
  color: var(--app-text);
  background: #172033 !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .input-group-text,
[data-theme="dark"] textarea {
  color: var(--app-text);
  border-color: var(--app-border);
  background-color: #111827;
}

[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #64748b;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  color: var(--app-text);
  border-color: #2dd4bf;
  background-color: #111827;
}

[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="datetime-local"],
[data-theme="dark"] input[type="time"] {
  color-scheme: dark;
}

[data-theme="dark"] .dropdown-divider,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  border-color: var(--app-border);
}

[data-theme="dark"] .dropdown-item {
  color: var(--app-text);
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
  color: var(--app-text);
  background: rgba(45, 212, 191, 0.1);
}

[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(180%);
}

[data-theme="dark"] .text-muted {
  color: var(--app-text-muted) !important;
}

[data-theme="dark"] .page-transition {
  background: rgba(15, 23, 42, 0.78);
}

.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 3px solid rgba(15, 118, 110, 0.18);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.data-page {
  width: min(1560px, 100%);
  margin: 0 auto;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.page-heading h1 {
  margin: 0;
  color: var(--ink-950);
  font-size: clamp(1.65rem, 2.4rem, 2.4rem);
  font-weight: 850;
}

.page-heading p {
  margin: 0.4rem 0 0;
  color: var(--app-text-muted);
}

.child-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.child-switcher .btn {
  min-height: 40px;
}

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

.chart-card {
  min-width: 0;
}

.chart-shell {
  position: relative;
  min-height: 280px;
}

.chart-shell canvas {
  width: 100% !important;
  height: 280px !important;
}

.chart-empty {
  display: grid;
  min-height: 260px;
  place-items: center;
  color: var(--app-text-muted);
  text-align: center;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--app-text-muted);
  font-size: 0.84rem;
}

.kpi-delta.positive { color: var(--green); }
.kpi-delta.negative { color: var(--coral); }

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  color: var(--ink-700);
  background: var(--ink-075);
  font-size: 0.78rem;
  font-weight: 800;
}

.status-badge--published,
.status-badge--paid,
.status-badge--present,
.status-badge--graded { color: #166534; background: #dcfce7; }
.status-badge--scheduled,
.status-badge--partial,
.status-badge--late { color: #92400e; background: #fef3c7; }
.status-badge--expired,
.status-badge--cancelled,
.status-badge--overdue,
.status-badge--absent,
.status-badge--missing { color: #9f1239; background: #ffe4e6; }

[data-theme="dark"] .status-badge--published,
[data-theme="dark"] .status-badge--paid,
[data-theme="dark"] .status-badge--present,
[data-theme="dark"] .status-badge--graded { color: #bbf7d0; background: rgba(22, 163, 74, 0.22); }
[data-theme="dark"] .status-badge--scheduled,
[data-theme="dark"] .status-badge--partial,
[data-theme="dark"] .status-badge--late { color: #fde68a; background: rgba(217, 119, 6, 0.22); }
[data-theme="dark"] .status-badge--expired,
[data-theme="dark"] .status-badge--cancelled,
[data-theme="dark"] .status-badge--overdue,
[data-theme="dark"] .status-badge--absent,
[data-theme="dark"] .status-badge--missing { color: #fecdd3; background: rgba(225, 29, 72, 0.2); }

.announcement-grid {
  display: grid;
  gap: 0.85rem;
}

.announcement-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius-md);
  background: var(--app-surface);
}

.announcement-card.priority-high {
  border-left-color: var(--coral);
}

.announcement-meta,
.announcement-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.announcement-meta {
  color: var(--app-text-muted);
  font-size: 0.82rem;
}

.recipient-picker {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  background: var(--app-surface-muted);
}

.recipient-option {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--app-border);
}

.recipient-option:last-child {
  border-bottom: 0;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 992px) {
  .sidebar-toggle {
    display: inline-flex;
  }

  .app-sidebar {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    width: min(320px, 88vw);
    height: auto;
    padding: 0.8rem;
    overflow: hidden;
    transform: translateX(-105%);
    transition: transform var(--motion);
  }

  .sidebar-scroll {
    overflow-y: auto;
  }

  .sidebar-profile {
    display: flex;
  }

  .sidebar-section-title {
    display: list-item;
  }

  .sidebar-nav {
    display: grid;
    overflow: visible;
  }

  .sidebar-nav li {
    flex: initial;
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: var(--topbar-height) 0 0;
    z-index: 1015;
    background: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(2px);
  }

  .sidebar-open .sidebar-backdrop {
    display: block;
  }

  .zs-body-authenticated .app-main {
    padding-top: calc(var(--topbar-height) + 1rem);
  }

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

@media (max-width: 640px) {
  .app-brand {
    gap: 0.45rem;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart-shell,
  .chart-shell canvas {
    min-height: 240px;
    height: 240px !important;
  }

  .announcement-actions .btn {
    flex: 1 1 auto;
  }
}
/* Keep the public sign-in surface legible and cohesive in dark mode. */
.auth-panel-eyebrow {
  color: var(--teal);
  border-color: rgba(15, 118, 110, 0.24);
  background: rgba(204, 251, 241, 0.42);
}

.auth-panel .validation-summary-valid {
  display: none;
}

.auth-panel .validation-summary-errors {
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(190, 18, 60, 0.2);
  border-radius: var(--radius-sm);
  background: rgba(255, 241, 242, 0.82);
}

.auth-panel .validation-summary-errors ul {
  margin: 0;
  padding-left: 1.15rem;
}

[data-theme="dark"] .auth-panel {
  color: #e5edf7;
  border-color: rgba(100, 116, 139, 0.46);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.98), rgba(17, 24, 39, 0.98));
  box-shadow: 0 28px 70px rgba(2, 6, 23, 0.42);
}

[data-theme="dark"] .auth-panel h2 {
  color: #f8fafc;
}

[data-theme="dark"] .auth-panel .text-muted {
  color: #aebed1 !important;
}

[data-theme="dark"] .auth-panel-eyebrow {
  color: #99f6e4;
  border-color: rgba(45, 212, 191, 0.38);
  background: rgba(15, 118, 110, 0.2);
}

[data-theme="dark"] .auth-panel .selected-role-note {
  color: #d2deeb;
  border-color: rgba(45, 212, 191, 0.3);
  background: rgba(15, 118, 110, 0.14);
}

[data-theme="dark"] .auth-panel .selected-role-note i {
  color: #5eead4;
}

[data-theme="dark"] .auth-panel .form-label,
[data-theme="dark"] .auth-panel .form-check-label {
  color: #dbe7f3;
}

[data-theme="dark"] .auth-panel .form-control,
[data-theme="dark"] .auth-panel .input-group-text {
  color: #f8fafc;
  border-color: #475569;
  background-color: #0f172a;
}

[data-theme="dark"] .auth-panel .input-group-text {
  color: #5eead4;
}

[data-theme="dark"] .auth-panel .form-control::placeholder {
  color: #7f91a8;
  opacity: 1;
}

[data-theme="dark"] .auth-panel .form-control:focus {
  color: #ffffff;
  border-color: #2dd4bf;
  background-color: #0b1220;
  box-shadow: 0 0 0 0.22rem rgba(45, 212, 191, 0.18);
}

[data-theme="dark"] .auth-panel .form-check-input {
  border-color: #64748b;
  background-color: #0f172a;
}

[data-theme="dark"] .auth-panel .form-check-input:checked {
  border-color: #14b8a6;
  background-color: #14b8a6;
}

[data-theme="dark"] .auth-panel a {
  color: #7dd3fc;
}

[data-theme="dark"] .auth-panel a:hover,
[data-theme="dark"] .auth-panel a:focus {
  color: #bae6fd;
}

[data-theme="dark"] .auth-panel .text-danger,
[data-theme="dark"] .auth-panel .validation-summary-errors {
  color: #fecdd3 !important;
}

[data-theme="dark"] .auth-panel .validation-summary-errors {
  border-color: rgba(251, 113, 133, 0.35);
  background: rgba(159, 18, 57, 0.18);
}

[data-theme="dark"] .auth-panel input:-webkit-autofill,
[data-theme="dark"] .auth-panel input:-webkit-autofill:hover,
[data-theme="dark"] .auth-panel input:-webkit-autofill:focus {
  -webkit-text-fill-color: #f8fafc;
  caret-color: #f8fafc;
  border-color: #475569;
  -webkit-box-shadow: 0 0 0 1000px #0f172a inset;
  box-shadow: 0 0 0 1000px #0f172a inset;
  transition: background-color 9999s ease-out 0s;
}

.preserve-whitespace {
  white-space: pre-wrap;
}

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

@media (max-width: 575.98px) {
  .action-grid--two-columns {
    grid-template-columns: 1fr;
  }
}
