:root {
  --bg: #f8fbff;
  --surface: rgba(255, 255, 255, 0.74);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --surface-soft: rgba(255, 255, 255, 0.58);
  --ink: #13243f;
  --muted: #5e6c86;
  --line: rgba(18, 36, 63, 0.1);
  --line-strong: rgba(18, 36, 63, 0.16);
  --primary: #1457d4;
  --primary-deep: #0e3ea2;
  --teal: #18b7b0;
  --teal-deep: #0f8c87;
  --sky: #d7eeff;
  --mint: #dff7f2;
  --warn: #f2a94d;
  --danger: #c74d5e;
  --success: #14806d;
  --shadow: 0 26px 70px rgba(20, 56, 111, 0.12);
  --shadow-soft: 0 14px 40px rgba(20, 56, 111, 0.09);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

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

.page-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 0% 0%, rgba(20, 87, 212, 0.18), transparent 28%),
    radial-gradient(circle at 100% 12%, rgba(24, 183, 176, 0.16), transparent 24%),
    radial-gradient(circle at 80% 100%, rgba(20, 87, 212, 0.1), transparent 28%),
    linear-gradient(135deg, #ffffff 0%, #f4f8ff 54%, #eefcf8 100%);
}

.app-frame {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 28px;
}

.glass {
  background: linear-gradient(180deg, var(--surface-strong) 0%, var(--surface) 100%);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.login-shell {
  min-height: calc(100vh - 52px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-panel {
  padding: 42px 40px 34px;
}

.login-panel h2,
.sidebar h2,
.topbar h1,
.feature-card h3,
.metric-card strong,
.entity-card h4,
.report-student-card h4 {
  font-family: "Sora", sans-serif;
  margin: 0;
}

.brand-copy,
.panel-copy,
.muted,
.helper-copy,
.entity-card p,
.report-result p,
.audit-item p,
.insight-list p,
.school-overview p {
  color: var(--muted);
}

.login-panel {
  width: min(440px, calc(100vw - 28px));
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(18, 36, 63, 0.08);
  box-shadow: 0 28px 80px rgba(20, 56, 111, 0.1);
}

.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 26px;
}

.login-logo {
  width: min(290px, 72vw);
  height: auto;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--primary-deep);
  font-weight: 700;
}

.stack-form,
.module-grid,
.stats-grid,
.dashboard-grid,
.entity-list,
.audit-list,
.health-grid,
.check-grid,
.course-comment-stack,
.school-overview {
  display: grid;
  gap: 16px;
}

.stack-form label,
.group-label {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 15px;
  color: var(--ink);
  background: var(--surface-strong);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(20, 87, 212, 0.34);
  box-shadow: 0 0 0 4px rgba(20, 87, 212, 0.09);
}

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

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--teal) 100%);
  box-shadow: 0 12px 28px rgba(20, 87, 212, 0.22);
}

.btn.ghost {
  color: var(--ink);
  background: rgba(20, 36, 63, 0.06);
}

.btn.danger {
  color: #fff;
  background: linear-gradient(135deg, #d96275 0%, #b83b4d 100%);
}

.btn.small {
  padding: 8px 12px;
  font-size: 0.84rem;
}

.btn.wide {
  width: 100%;
}

.btn[disabled] {
  cursor: default;
  opacity: 0.76;
  transform: none;
}

.workspace {
  min-height: calc(100vh - 52px);
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 22px;
}

.sidebar {
  padding: 26px 18px 20px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 18px;
}

.sidebar-logo {
  width: 150px;
  height: auto;
  object-fit: contain;
}

.sidebar-user {
  padding: 16px 16px 14px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(20, 87, 212, 0.05) 0%, rgba(24, 183, 176, 0.05) 100%);
  border: 1px solid rgba(20, 87, 212, 0.08);
}

.sidebar-user h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.sidebar-user-label {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  margin-top: 16px;
}

.nav-link {
  text-align: left;
  border: 0;
  border-radius: 16px;
  padding: 13px 14px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.98rem;
}

.nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--teal) 100%);
  box-shadow: 0 16px 28px rgba(20, 87, 212, 0.18);
}

.sidebar-footer {
  margin-top: auto;
}

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

.topbar {
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar h1 {
  font-size: clamp(1.45rem, 2.3vw, 2.05rem);
  line-height: 1.05;
}

.mini-health {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(20, 128, 109, 0.09);
  color: var(--success);
  font-weight: 700;
  font-size: 0.82rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(20, 128, 109, 0.12);
}

.status-banner {
  padding: 14px 18px;
  border-radius: 18px;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
}

.status-banner.ok {
  background: rgba(20, 128, 109, 0.1);
  color: var(--success);
}

.status-banner.error {
  background: rgba(199, 77, 94, 0.1);
  color: var(--danger);
}

.module-loader {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px 14px;
}

.module-loader p {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.loader-dots {
  display: inline-flex;
  gap: 8px;
}

.loader-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(36, 87, 212, 0.18);
  animation: loader-fill 1.2s infinite ease-in-out;
}

.loader-dots span:nth-child(2) { animation-delay: 0.12s; }
.loader-dots span:nth-child(3) { animation-delay: 0.24s; }
.loader-dots span:nth-child(4) { animation-delay: 0.36s; }
.loader-dots span:nth-child(5) { animation-delay: 0.48s; }

@keyframes loader-fill {
  0%, 100% {
    transform: scale(0.86);
    background: rgba(36, 87, 212, 0.18);
  }
  50% {
    transform: scale(1);
    background: linear-gradient(135deg, var(--primary) 0%, var(--teal) 100%);
  }
}

.module-panel {
  display: none;
  gap: 18px;
}

.module-panel.active {
  display: grid;
}

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

.metric-card {
  padding: 22px;
  overflow: hidden;
  position: relative;
  min-height: 148px;
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -10px;
  bottom: -22px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.metric-card p {
  margin: 0 0 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
}

.metric-card strong {
  display: block;
  font-size: clamp(2.1rem, 4vw, 3.4rem);
  color: #fff;
}

.accent-a,
.accent-b,
.accent-c,
.accent-d {
  border: 0;
}

.accent-a {
  background: linear-gradient(135deg, #1457d4 0%, #0f80cc 100%);
}

.accent-b {
  background: linear-gradient(135deg, #18b7b0 0%, #0f8c87 100%);
}

.accent-c {
  background: linear-gradient(135deg, #2e68e8 0%, #19b1d9 100%);
}

.accent-d {
  background: linear-gradient(135deg, #0e3ea2 0%, #18b7b0 100%);
}

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

.module-grid.three-columns {
  grid-template-columns: minmax(320px, 1.02fr) minmax(0, 1.02fr) minmax(280px, 0.88fr);
  align-items: start;
}

.reports-grid > .feature-card {
  min-width: 0;
}

.feature-card {
  padding: 24px;
}

.section-head,
.entity-card-head,
.form-actions,
.selector-actions,
.report-result-actions,
.toolbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.section-head {
  margin-bottom: 18px;
}

.section-head h3 {
  font-size: 1.28rem;
}

.toolbar-actions {
  justify-content: flex-end;
}

.toolbar-search {
  width: min(420px, 100%);
  min-width: 240px;
}

.section-inline-actions {
  margin-bottom: 14px;
}

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

.insight-card,
.health-card,
.school-overview-card,
.entity-card,
.audit-item,
.report-student-card,
.report-result-card {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.insight-card strong,
.health-card strong,
.school-overview-card strong {
  display: block;
  margin-bottom: 8px;
  font-family: "Sora", sans-serif;
}

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

.school-overview {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.entity-card.selected,
.report-student-card.selected {
  border-color: rgba(20, 87, 212, 0.35);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(222, 244, 255, 0.9) 100%);
}

.entity-card h4,
.report-student-card h4 {
  font-size: 1rem;
}

.entity-card p,
.report-student-card p,
.audit-item p {
  margin: 6px 0 0;
}

.course-inline-edit {
  display: grid;
  gap: 8px;
  min-width: min(100%, 380px);
}

.course-inline-label {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--muted);
}

.course-inline-input {
  min-width: 220px;
}

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

.table-shell {
  border: 1px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow-soft);
}

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

.data-table thead th {
  text-align: left;
  padding: 16px 18px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary-deep);
  background: rgba(20, 87, 212, 0.05);
  border-bottom: 1px solid var(--line);
}

.data-table tbody td {
  padding: 18px;
  border-bottom: 1px solid rgba(18, 36, 63, 0.08);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: rgba(20, 87, 212, 0.035);
}

.data-table tbody tr.is-selected {
  background: linear-gradient(180deg, rgba(219, 240, 255, 0.55) 0%, rgba(236, 249, 255, 0.7) 100%);
}

.table-title {
  font-family: "Sora", sans-serif;
  font-size: 1rem;
  font-weight: 700;
}

.table-school {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.school-thumb {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
  background: rgba(20, 87, 212, 0.06);
  border: 1px solid rgba(20, 87, 212, 0.08);
}

.school-thumb-fallback {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(20, 87, 212, 0.12) 0%, rgba(24, 183, 176, 0.12) 100%);
  color: var(--primary-deep);
  font-family: "Sora", sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  border: 1px solid rgba(20, 87, 212, 0.08);
}

.table-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.93rem;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  margin-top: 18px;
}

.checkline {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.checkline input {
  width: auto;
}

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

.check-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.check-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
}

.check-card input {
  width: auto;
  margin-top: 2px;
}

.course-comment-stack {
  margin-top: 4px;
}

.course-comment-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(20, 87, 212, 0.04);
  border: 1px solid rgba(20, 87, 212, 0.08);
}

.report-result {
  min-height: 220px;
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.preset-list {
  max-height: 980px;
  overflow: auto;
}

.preset-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-soft);
}

.preset-card.selected {
  border-color: rgba(20, 87, 212, 0.28);
  background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(231,244,255,0.92) 100%);
}

.preset-card h4 {
  margin: 0;
  font-family: "Sora", sans-serif;
  font-size: 0.98rem;
}

.preset-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.preset-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(20, 87, 212, 0.08);
  color: var(--primary-deep);
  font-size: 0.78rem;
  font-weight: 700;
}

.compact-result {
  min-height: 0;
  margin-top: 22px;
}

.evaluator-entry-grid {
  margin-top: 8px;
}

.evaluator-entry-card {
  display: grid;
  gap: 12px;
  text-align: left;
  padding: 24px;
  border-radius: 28px;
  border: 1px solid rgba(20, 87, 212, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88) 0%, rgba(244, 250, 255, 0.92) 100%);
  box-shadow: var(--shadow-soft);
  color: var(--ink);
}

.evaluator-entry-card strong {
  font-family: "Sora", sans-serif;
  font-size: 1.2rem;
}

.evaluator-entry-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.evaluator-entry-card:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(236, 248, 255, 1) 100%);
}

.stack-form input[readonly] {
  background: rgba(20, 36, 63, 0.04);
  color: rgba(23, 35, 58, 0.88);
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 28, 49, 0.28);
  backdrop-filter: blur(4px);
}

.drawer-panel {
  position: absolute;
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: min(520px, calc(100vw - 24px));
  padding: 24px;
  overflow: auto;
  box-shadow: 0 30px 80px rgba(11, 31, 58, 0.2);
}

.drawer-tabs {
  display: flex;
  gap: 8px;
  margin: 2px 0 18px;
  flex-wrap: wrap;
}

.drawer-tab {
  border: 1px solid var(--line);
  background: rgba(20, 36, 63, 0.04);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
}

.drawer-tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary) 0%, var(--teal) 100%);
}

.drawer-tab-panel {
  display: none;
}

.drawer-tab-panel.active {
  display: grid;
  gap: 16px;
}

.module-tabs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 8px;
  margin-bottom: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(20, 87, 212, 0.08);
  box-shadow: var(--shadow-soft);
}

.module-tabs .drawer-tab {
  padding: 12px 18px;
  min-height: 46px;
}

#module-students .drawer-tab-panel {
  width: 100%;
}

#module-students .drawer-tab-panel.active {
  display: grid;
  gap: 18px;
}

.report-result-card h4 {
  margin: 0 0 8px;
  font-family: "Sora", sans-serif;
}

.report-result-card code {
  display: block;
  overflow-wrap: anywhere;
  background: rgba(20, 36, 63, 0.06);
  padding: 12px;
  border-radius: 14px;
  margin-top: 12px;
}

.report-preview-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(20, 87, 212, 0.08);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  min-width: 0;
}

.report-preview-card h4 {
  margin: 0;
  font-family: "Sora", sans-serif;
}

.report-preview-card > div {
  min-width: 0;
}

.report-preview-card img {
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid rgba(20, 87, 212, 0.08);
  background: #fff;
}

.audit-list {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.audit-item strong {
  display: block;
  margin-bottom: 8px;
}

.helper-copy,
.status {
  margin: 0;
}

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

.notice {
  border: 1px dashed rgba(20, 87, 212, 0.2);
  border-radius: 12px;
  padding: 14px;
  color: var(--muted);
  background: rgba(248, 252, 255, 0.9);
}

.mfa-box {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(20, 87, 212, 0.1);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.mfa-secret,
.mfa-backup-list {
  border: 1px dashed rgba(20, 87, 212, 0.2);
  border-radius: 12px;
  padding: 12px;
  background: rgba(249, 252, 255, 0.9);
}

.mfa-backup-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 600;
}

.mono-copy {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.9rem;
  word-break: break-all;
}

.status {
  min-height: 20px;
}

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

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

.hidden {
  display: none !important;
}

@media (max-width: 1200px) {
  .workspace,
  .stats-grid,
  .dashboard-grid,
  .module-grid.two-columns,
  .module-grid.three-columns,
  .health-grid,
  .insight-list {
    grid-template-columns: 1fr;
  }

  .workspace {
    min-height: auto;
  }
}

@media (max-width: 900px) {
  .app-frame {
    width: min(100vw - 20px, 100%);
    padding: 10px 0 20px;
  }

  .sidebar,
  .topbar,
  .feature-card,
  .brand-panel,
  .login-panel {
    border-radius: 24px;
  }

  .sidebar-nav {
    grid-template-columns: 1fr 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .toolbar-search {
    min-width: 100%;
  }

  .drawer-panel {
    top: 10px;
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
  }
}

@media (max-width: 640px) {
  .sidebar-nav {
    grid-template-columns: 1fr;
  }

  .entity-card-head,
  .section-head,
  .topbar {
    align-items: flex-start;
  }
}
