:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #132033;
  --muted: #617089;
  --accent: #1d4c9a;
  --accent-2: #edf3ff;
  --border: #dbe3f1;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Montserrat", system-ui, sans-serif; background: var(--bg); color: var(--ink); }
.portal-body { min-height: 100vh; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card, .panel, .metric-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 8px 22px rgba(20, 32, 51, 0.05); }
.login-card { width: min(100%, 460px); padding: 32px; }
.logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 12px; }
.stack-form { display: grid; gap: 14px; }
.stack-form label span { display: block; margin-bottom: 6px; font-weight: 600; }
input, select, button { width: 100%; border-radius: 12px; border: 1px solid var(--border); padding: 12px 14px; font: inherit; }
button, .button { background: var(--accent); color: #fff; border: none; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-weight: 600; }
.button { width: auto; padding: 12px 18px; border-radius: 999px; box-shadow: 0 8px 20px rgba(29, 76, 154, 0.15); }
button:disabled { opacity: 0.7; cursor: wait; }
.button.secondary { background: #22324f; }
.alert { background: #fff2f2; border: 1px solid #f5c2c2; color: #9e2525; padding: 12px 14px; border-radius: 14px; margin: 14px 0; }
.success { background: #eef9ef; border: 1px solid #b6dfba; color: #1c6b28; padding: 12px 14px; border-radius: 14px; margin: 14px 0; }
.alert.wide { margin: 16px 24px; }
.success.wide { margin: 16px 24px; }
.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding: 24px; }
.header-branding { display: flex; gap: 14px; align-items: center; }
.header-school-logo { width: 54px; height: 54px; border-radius: 12px; border: 1px solid var(--border); background: #fff; object-fit: contain; padding: 4px; flex: 0 0 auto; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tab-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.tab-link { text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--border); padding: 10px 14px; border-radius: 12px; font-weight: 600; }
.tab-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.logout-link { background: #22324f; color: #fff; border-color: #22324f; }
.inline-form { display: flex; gap: 10px; align-items: center; }
.inline-form select, .inline-form button { width: auto; min-width: 140px; }
.compact-inline input, .compact-inline button { min-width: 0; }
.compact-inline input[type="number"] { width: 120px; }
.compact-inline input[type="text"] { width: 160px; }
.compact-inline input[type="password"] { width: 160px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.section-note { margin-top: -4px; margin-bottom: 16px; color: var(--muted); }
.wide { margin: 0 24px 24px; }
.toolbar { display: flex; justify-content: flex-start; }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; padding: 0 24px 24px; }
.compact-metrics { padding: 0; margin-top: 16px; }
.metric-card { padding: 18px; }
.metric-value { font-size: 28px; font-weight: 700; }
.metric-label { color: var(--muted); margin-top: 6px; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; padding: 0 24px 24px; }
.single-col { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 0 24px 24px; }
.panel { padding: 18px; overflow: hidden; }
.intro-panel { background: #fbfcff; }
.simple-meta { display: grid; gap: 8px; margin-top: 12px; }
.school-branding-row { display: grid; grid-template-columns: 160px 1fr; gap: 20px; align-items: start; }
.school-logo-panel { display: flex; justify-content: center; align-items: center; }
.school-logo-preview,
.school-logo-placeholder { width: 140px; height: 140px; border-radius: 18px; border: 1px solid var(--border); background: #fff; }
.school-logo-preview { object-fit: contain; padding: 10px; }
.school-logo-placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 600; text-align: center; padding: 12px; }
.school-branding-content { min-width: 0; }
.compact-stack { max-width: 440px; margin-top: 16px; }
.logo-upload-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-upload-loader { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; }
.logo-upload-loader[hidden] { display: none !important; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(29, 76, 154, 0.18); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.small-text { font-size: 13px; }
.table-wrap { overflow-x: auto; }
.two-col-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-span-2 { grid-column: 1 / -1; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
.stack-list { display: grid; gap: 10px; }
.list-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: #fafcff; }
.block-row { align-items: flex-start; }
.stack-actions { display: grid; gap: 8px; justify-items: end; }
.secondary-button { background: #22324f; color: #fff; }
.right-text { text-align: right; }
.actions-row { margin-top: 16px; display: flex; justify-content: flex-end; }
.left-actions { justify-content: flex-start; }
.template-button { background: linear-gradient(135deg, #1d4c9a 0%, #2b66c3 100%); border: 1px solid rgba(15, 41, 88, 0.12); }
.section-spacer { margin-top: 16px; }
.stack-action-group { display: grid; gap: 10px; min-width: 260px; }
.compact-form-block { gap: 8px; }
.danger-button { background: #aa2e25; color: #fff; }
.code-wrap {
  display: inline-block;
  max-width: 280px;
  padding: 6px 8px;
  border-radius: 10px;
  background: #f4f7fb;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
textarea { width: 100%; border-radius: 12px; border: 1px solid var(--border); padding: 12px 14px; font: inherit; resize: vertical; }
.no-link { color: inherit; text-decoration: none; }
.wrap-form { flex-wrap: wrap; }
h1, h2 { margin-top: 0; }
.faq-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: auto;
  min-width: 72px;
  padding: 14px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #1d4c9a 0%, #2b66c3 100%);
  box-shadow: 0 16px 30px rgba(29, 76, 154, 0.28);
  z-index: 1100;
}
.faq-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 20, 38, 0.48);
  z-index: 1190;
}
.faq-dialog {
  position: fixed;
  right: 20px;
  bottom: 92px;
  width: min(440px, calc(100vw - 24px));
  max-height: min(76vh, 720px);
  z-index: 1200;
}
.faq-dialog-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 48px rgba(12, 24, 46, 0.2);
  padding: 18px;
  overflow: auto;
  max-height: inherit;
}
.faq-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.faq-close-button {
  width: auto;
  padding: 10px 14px;
  border-radius: 999px;
  background: #22324f;
  flex: 0 0 auto;
}
.faq-list {
  display: grid;
  gap: 10px;
}
.faq-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfcff;
  padding: 0 14px;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 700;
  padding: 14px 0;
  list-style: none;
}
.faq-item summary::-webkit-details-marker {
  display: none;
}
.faq-item p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.5;
}
.print-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}
.print-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 8px 22px rgba(20, 32, 51, 0.05);
  padding: 24px;
}
.print-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.print-title {
  font-size: 30px;
  margin-bottom: 6px;
}
.print-logo {
  width: 84px;
  height: 84px;
  object-fit: contain;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 6px;
  background: #fff;
}
.report-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.report-meta-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fbfcff;
}
.report-score {
  font-size: 32px;
  font-weight: 800;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@media (max-width: 920px) {
  .topbar, .two-col { grid-template-columns: 1fr; display: grid; }
  .topbar { padding-bottom: 8px; }
  .header-branding { align-items: flex-start; }
  .inline-form { flex-direction: column; width: 100%; }
  .inline-form select, .inline-form button, .inline-form input { width: 100%; }
  .tab-nav { width: 100%; }
  .school-branding-row { grid-template-columns: 1fr; }
  .school-logo-panel { justify-content: flex-start; }
  .two-col-form { grid-template-columns: 1fr; }
  .report-meta-grid { grid-template-columns: 1fr; }
  .faq-dialog {
    right: 12px;
    left: 12px;
    bottom: 82px;
    width: auto;
    max-height: calc(100vh - 112px);
  }
  .faq-fab {
    right: 12px;
    bottom: 12px;
  }
}
@media print {
  body {
    background: #fff;
  }
  .topbar,
  .faq-fab,
  .faq-dialog,
  .faq-dialog-backdrop,
  .alert,
  .success,
  .print-actions {
    display: none !important;
  }
  .print-shell {
    padding: 0;
    max-width: none;
  }
  .print-card {
    border: none;
    box-shadow: none;
    padding: 0;
  }
}
