:root {
  color-scheme: light;
  --brand: #0077ff;
  --brand-deep: #005ed6;
  --brand-bright: #4cc9ff;
  --brand-soft: #eaf5ff;
  --brand-mist: #f5faff;
  --ink: #102a43;
  --ink-strong: #071b31;
  --muted: #66788a;
  --muted-strong: #455b70;
  --line: rgba(0, 119, 255, 0.14);
  --line-strong: rgba(0, 119, 255, 0.26);
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-subtle: rgba(248, 252, 255, 0.92);
  --page: #eef6ff;
  --success: #148760;
  --success-soft: #e7f8f1;
  --warning: #b97408;
  --warning-soft: #fff4dc;
  --danger: #c64050;
  --danger-soft: #fff0f2;
  --violet: #7857e8;
  --shadow-sm: 0 5px 18px rgba(22, 78, 133, 0.08);
  --shadow-md: 0 16px 42px rgba(22, 78, 133, 0.12);
  --shadow-lg: 0 28px 80px rgba(7, 52, 99, 0.18);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --container: 1440px;
  --header-height: 74px;
  --ease: 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

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

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 2%, rgba(76, 201, 255, 0.22), transparent 25rem),
    radial-gradient(circle at 92% 13%, rgba(0, 119, 255, 0.12), transparent 28rem),
    linear-gradient(180deg, #f8fcff 0%, #eef6ff 48%, #f7fbff 100%);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: -8rem auto auto -7rem;
  width: 20rem;
  height: 20rem;
  border: 1px solid rgba(76, 201, 255, 0.22);
  border-radius: 50%;
  box-shadow: 0 0 0 3.5rem rgba(0, 119, 255, 0.025);
  content: "";
  pointer-events: none;
  z-index: -1;
}

body.modal-open,
body.has-open-modal {
  overflow: hidden;
}

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

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled),
[role="button"]:not([aria-disabled="true"]),
summary,
select {
  cursor: pointer;
}

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

a {
  color: var(--brand-deep);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--brand);
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--ink-strong);
  line-height: 1.15;
}

::selection {
  color: #fff;
  background: var(--brand);
}

:focus-visible {
  outline: 3px solid rgba(0, 119, 255, 0.48);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  padding: 0.75rem 1rem;
  color: #fff;
  background: var(--ink-strong);
  border-radius: var(--radius-sm);
  transform: translateY(-160%);
  transition: transform var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--header-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 4px 24px rgba(20, 69, 115, 0.06);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}

.app-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 2.5rem, var(--container));
  min-height: var(--header-height);
  margin-inline: auto;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 0.78rem;
  color: var(--ink-strong);
  text-decoration: none;
}

.brand:hover {
  color: var(--ink-strong);
}

.brand__mark,
.portal-mark {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  place-items: center;
  overflow: hidden;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 15px;
  background: linear-gradient(145deg, var(--brand-bright), var(--brand) 60%, var(--brand-deep));
  box-shadow: 0 8px 22px rgba(0, 119, 255, 0.24);
  font-size: 1.35rem;
  font-weight: 900;
  isolation: isolate;
}

.brand__mark::before,
.portal-mark::before {
  content: "♫";
}

.brand__mark::after,
.portal-mark::after {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 50%;
  content: "";
  transform: translate(13px, -12px);
  z-index: -1;
}

.brand__mark img,
.portal-mark img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

.brand__mark:has(img)::before,
.portal-mark:has(img)::before,
.brand__mark:has(img)::after,
.portal-mark:has(img)::after {
  display: none;
}

.brand__copy {
  display: grid;
  min-width: 0;
  gap: 0.06rem;
}

.brand__name {
  overflow: hidden;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand__tagline {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-header__actions,
.header-actions,
.page-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
}

.admin-pill,
.session-pill {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 0.48rem;
  padding: 0.48rem 0.78rem;
  color: var(--muted-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.79rem;
  font-weight: 700;
  white-space: nowrap;
}

.admin-pill::before,
.session-pill::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(20, 135, 96, 0.11);
  content: "";
}

.app-main {
  flex: 1;
  width: 100%;
}

.page-shell,
.container {
  width: min(100% - 2.5rem, var(--container));
  margin-inline: auto;
}

.page-shell {
  padding-block: clamp(1.5rem, 3.3vw, 3.25rem) 4.5rem;
}

.page-shell--narrow {
  max-width: 1080px;
}

.page-shell--auth {
  display: grid;
  min-height: calc(100vh - var(--header-height) - 100px);
  place-items: center;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: clamp(1.3rem, 2.8vw, 2.2rem);
  gap: 1.25rem;
}

.page-heading__copy {
  max-width: 760px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
  color: var(--brand-deep);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 20px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-bright));
  content: "";
}

.page-title {
  margin-bottom: 0.5rem;
  font-size: clamp(1.9rem, 3.2vw, 3.3rem);
  font-weight: 850;
  letter-spacing: -0.045em;
}

.page-subtitle {
  max-width: 68ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.25vw, 1.08rem);
}

.app-footer {
  margin-top: auto;
  padding: 1.25rem;
  border-top: 1px solid rgba(0, 119, 255, 0.1);
  background: rgba(255, 255, 255, 0.54);
  text-align: center;
}

.app-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.app-footer a {
  color: var(--brand-deep);
  font-weight: 800;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.button,
.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  padding: 0.66rem 1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  font-size: 0.87rem;
  font-weight: 780;
  line-height: 1.1;
  text-decoration: none;
  transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease), background var(--ease);
}

.button:hover:not(:disabled),
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled),
.btn:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled,
.btn:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.56;
}

.button--primary,
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #168cff 58%, var(--brand-bright));
  box-shadow: 0 8px 22px rgba(0, 119, 255, 0.22);
}

.button--primary:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
  color: #fff;
  box-shadow: 0 12px 28px rgba(0, 119, 255, 0.3);
}

.button--secondary,
.btn-secondary {
  color: var(--brand-deep);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
}

.button--secondary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
  color: var(--brand-deep);
  border-color: rgba(0, 119, 255, 0.42);
  background: #fff;
}

.button--ghost,
.btn-ghost {
  color: var(--muted-strong);
  border-color: transparent;
}

.button--ghost:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.button--danger,
.btn-danger {
  color: var(--danger);
  border-color: rgba(198, 64, 80, 0.24);
  background: var(--danger-soft);
}

.button--success,
.btn-success {
  color: var(--success);
  border-color: rgba(20, 135, 96, 0.22);
  background: var(--success-soft);
}

.button--small,
.btn-sm {
  min-height: 38px;
  padding: 0.5rem 0.72rem;
  font-size: 0.78rem;
}

.button--icon,
.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
}

.button svg,
.btn svg,
.icon-button svg {
  width: 1.1rem;
  height: 1.1rem;
  stroke-width: 2;
}

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

.field {
  display: grid;
  min-width: 0;
  gap: 0.45rem;
}

.field--full {
  grid-column: 1 / -1;
}

.field label,
.field-label {
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 780;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea,
.input {
  width: 100%;
  min-height: 46px;
  padding: 0.68rem 0.82rem;
  color: var(--ink-strong);
  border: 1px solid rgba(70, 108, 143, 0.22);
  border-radius: 12px;
  outline: none;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 1px 2px rgba(31, 66, 99, 0.035);
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

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

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus,
.input:focus {
  border-color: rgba(0, 119, 255, 0.62);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 119, 255, 0.11);
}

input::placeholder,
textarea::placeholder {
  color: #95a5b4;
}

.input-with-action {
  position: relative;
}

.input-with-action input {
  padding-right: 3.2rem !important;
}

.input-with-action .icon-button,
.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.18rem;
  min-height: 44px;
  border: 0;
  color: var(--muted);
  background: transparent;
  transform: translateY(-50%);
}

.field-hint,
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.field-error,
.error-text {
  margin: 0;
  color: var(--danger);
  font-size: 0.76rem;
  font-weight: 680;
}

.check-row {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 0.65rem;
}

.check-row input {
  width: 1.12rem;
  height: 1.12rem;
  accent-color: var(--brand);
}

.switch {
  position: relative;
  display: inline-flex;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd7e1;
  transition: background var(--ease);
}

.switch__track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(12, 39, 66, 0.22);
  content: "";
  transition: transform var(--ease);
}

.switch input:checked + .switch__track {
  background: var(--brand);
}

.switch input:checked + .switch__track::after {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch__track {
  outline: 3px solid rgba(0, 119, 255, 0.42);
  outline-offset: 3px;
}

.panel,
.card,
.surface {
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
}

.panel {
  padding: clamp(1rem, 2vw, 1.45rem);
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.05rem;
  gap: 1rem;
}

.panel__title {
  margin-bottom: 0.22rem;
  font-size: 1.02rem;
  font-weight: 820;
  letter-spacing: -0.018em;
}

.panel__subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.divider {
  height: 1px;
  margin-block: 1rem;
  border: 0;
  background: var(--line);
}

.badge,
.status-badge,
.chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  padding: 0.3rem 0.58rem;
  color: var(--muted-strong);
  border: 1px solid rgba(74, 108, 141, 0.13);
  border-radius: 999px;
  background: #f1f6fa;
  font-size: 0.7rem;
  font-weight: 780;
  line-height: 1;
  white-space: nowrap;
}

.badge--brand,
.status-badge--brand {
  color: var(--brand-deep);
  border-color: rgba(0, 119, 255, 0.15);
  background: var(--brand-soft);
}

.badge--success,
.status-badge--success,
.status-present {
  color: var(--success);
  border-color: rgba(20, 135, 96, 0.16);
  background: var(--success-soft);
}

.badge--warning,
.status-badge--warning,
.status-makeup {
  color: var(--warning);
  border-color: rgba(185, 116, 8, 0.16);
  background: var(--warning-soft);
}

.badge--danger,
.status-badge--danger,
.status-absent {
  color: var(--danger);
  border-color: rgba(198, 64, 80, 0.16);
  background: var(--danger-soft);
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  color: var(--muted-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(234, 245, 255, 0.86);
  font-size: 0.84rem;
}

.alert--success {
  color: #116a4d;
  border-color: rgba(20, 135, 96, 0.2);
  background: var(--success-soft);
}

.alert--warning {
  color: #855304;
  border-color: rgba(185, 116, 8, 0.2);
  background: var(--warning-soft);
}

.alert--danger,
.alert--error {
  color: #8f2c39;
  border-color: rgba(198, 64, 80, 0.2);
  background: var(--danger-soft);
}

.alert p:last-child {
  margin-bottom: 0;
}

.toast-region {
  position: fixed;
  top: calc(var(--header-height) + 1rem);
  right: 1rem;
  z-index: 120;
  display: grid;
  width: min(380px, calc(100vw - 2rem));
  gap: 0.7rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  font-size: 0.84rem;
  pointer-events: auto;
  animation: toast-in 240ms var(--ease) both;
}

.toast.is-leaving {
  animation: toast-out 180ms ease-in both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(12px) scale(0.98); }
}

.auth-card {
  display: grid;
  width: min(100%, 470px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px);
}

.auth-card__top {
  position: relative;
  display: grid;
  min-height: 148px;
  place-items: center;
  overflow: hidden;
  padding: 1.5rem;
  color: #fff;
  background:
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.28), transparent 9rem),
    linear-gradient(135deg, var(--brand-deep), var(--brand) 55%, var(--brand-bright));
}

.auth-card__top::after {
  position: absolute;
  right: -2rem;
  bottom: -5rem;
  width: 12rem;
  height: 12rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  content: "";
  box-shadow: 0 0 0 2.4rem rgba(255, 255, 255, 0.05);
}

.auth-card__mark {
  width: 68px;
  height: 68px;
  border: 3px solid rgba(255, 255, 255, 0.82);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 28px rgba(0, 54, 116, 0.2);
}

.auth-card__body {
  padding: clamp(1.35rem, 4vw, 2rem);
}

.auth-card__title {
  margin-bottom: 0.45rem;
  font-size: 1.55rem;
  letter-spacing: -0.035em;
}

.auth-card__subtitle {
  margin-bottom: 1.4rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-card form {
  display: grid;
  gap: 1rem;
}

.auth-card .button,
.auth-card .btn {
  width: 100%;
}

.portal-intro {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 190px;
  margin-bottom: clamp(1.5rem, 3.5vw, 2.8rem);
  overflow: hidden;
  padding: clamp(1.35rem, 3vw, 2.4rem);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.95), rgba(241, 249, 255, 0.85)),
    linear-gradient(135deg, var(--brand-soft), #fff);
  box-shadow: var(--shadow-md);
  gap: 1.5rem;
}

.portal-intro::before,
.portal-intro::after {
  position: absolute;
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.portal-intro::before {
  right: -5rem;
  bottom: -8rem;
  width: 18rem;
  height: 18rem;
  border: 1px solid rgba(0, 119, 255, 0.13);
  box-shadow: 0 0 0 3.2rem rgba(76, 201, 255, 0.06);
}

.portal-intro::after {
  top: 1rem;
  right: 18%;
  width: 7px;
  height: 7px;
  background: var(--brand-bright);
  box-shadow: 42px 30px 0 rgba(0, 119, 255, 0.3), -18px 60px 0 rgba(120, 87, 232, 0.28);
}

.portal-intro__content {
  position: relative;
  z-index: 1;
  max-width: 780px;
}

.portal-intro__title {
  margin-bottom: 0.6rem;
  font-size: clamp(1.85rem, 3.3vw, 3.1rem);
  font-weight: 870;
  letter-spacing: -0.05em;
}

.portal-intro__subtitle {
  max-width: 60ch;
  margin-bottom: 0;
  color: var(--muted);
}

.portal-intro__mark {
  position: relative;
  z-index: 1;
  width: clamp(84px, 10vw, 128px);
  height: clamp(84px, 10vw, 128px);
  border-radius: 30%;
  transform: rotate(3deg);
}

.school-section-title {
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 820;
  letter-spacing: -0.015em;
}

.school-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.9rem, 1.8vw, 1.35rem);
}

.school-card {
  --school-accent: var(--brand);
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 250px;
  grid-template-rows: minmax(150px, 1fr) auto;
  overflow: hidden;
  color: var(--ink-strong);
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transform: translateZ(0);
  transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease);
}

.school-card:hover,
.school-card:focus-visible {
  color: var(--ink-strong);
  border-color: color-mix(in srgb, var(--school-accent) 30%, white);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.school-card__logo-wrap,
.school-card__media {
  position: relative;
  display: grid;
  min-height: 155px;
  place-items: center;
  overflow: hidden;
  padding: 1.35rem;
  background:
    radial-gradient(circle at 72% 15%, color-mix(in srgb, var(--school-accent) 13%, transparent), transparent 8rem),
    linear-gradient(145deg, #f9fcff, color-mix(in srgb, var(--school-accent) 7%, white));
}

.school-card__logo-wrap::after,
.school-card__media::after {
  position: absolute;
  right: -2.5rem;
  bottom: -4rem;
  width: 9rem;
  height: 9rem;
  border: 1px solid color-mix(in srgb, var(--school-accent) 18%, transparent);
  border-radius: 50%;
  content: "";
}

.school-card__logo,
.school-card__media img {
  position: relative;
  z-index: 1;
  width: auto;
  max-width: 78%;
  height: 112px;
  object-fit: contain;
  filter: drop-shadow(0 7px 12px rgba(11, 48, 82, 0.1));
}

.school-card__body {
  min-width: 0;
  padding: 1rem 1.15rem 1.08rem;
  border-top: 1px solid color-mix(in srgb, var(--school-accent) 9%, white);
}

.school-card__title {
  display: block;
  overflow: hidden;
  margin-bottom: 0.2rem;
  font-size: 1rem;
  font-weight: 820;
  letter-spacing: -0.022em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.school-card__meta {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.school-card[data-school="lps"],
.school-card--lps { --school-accent: #0b559a; }
.school-card[data-school="bps"],
.school-card--bps { --school-accent: #174d2e; }
.school-card[data-school="wbjs"],
.school-card--wbjs { --school-accent: #201545; }
.school-card[data-school="maara"],
.school-card--maara { --school-accent: #79bdb5; }
.school-card[data-school="jvr"],
.school-card--jvr { --school-accent: #18aeb4; }
.school-card[data-school="ctms"],
.school-card--ctms { --school-accent: #43b900; }
.school-card[data-school="bmms"],
.school-card--bmms { --school-accent: #004aad; }

.school-card[data-school="wbjs"] .school-card__logo-wrap,
.school-card--wbjs .school-card__logo-wrap,
.school-card[data-school="wbjs"] .school-card__media,
.school-card--wbjs .school-card__media {
  background: linear-gradient(145deg, #201545, #342466);
}

.school-card[data-school="wbjs"] .school-card__logo,
.school-card--wbjs .school-card__logo {
  max-width: 86%;
}

.school-card[data-school="maara"] .school-card__logo,
.school-card--maara .school-card__logo,
.school-card[data-school="wbjs"] .school-card__logo,
.school-card--wbjs .school-card__logo {
  height: 92px;
}

.dashboard-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  align-items: start;
  gap: 1.25rem;
}

.dashboard-nav {
  position: sticky;
  top: calc(var(--header-height) + 1.25rem);
  display: grid;
  padding: 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-sm);
  gap: 0.3rem;
  backdrop-filter: blur(18px);
}

.dashboard-nav__label {
  padding: 0.65rem 0.7rem 0.35rem;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 820;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dashboard-nav a,
.dashboard-nav button {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 0.65rem;
  padding: 0.64rem 0.72rem;
  color: var(--muted-strong);
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 720;
  text-align: left;
  text-decoration: none;
}

.dashboard-nav a:hover,
.dashboard-nav button:hover,
.dashboard-nav a[aria-current="page"],
.dashboard-nav .is-active {
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.dashboard-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 1.15rem;
}

.dashboard-toolbar,
.workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  gap: 1rem;
}

.toolbar-group,
.filter-group {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.65rem;
}

.toolbar-select {
  width: auto;
  min-width: 128px;
  min-height: 42px;
  padding-block: 0.52rem;
  font-size: 0.81rem;
  font-weight: 720;
}

.stat-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.stat-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 1rem 1.05rem;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-sm);
}

.stat-card::after {
  position: absolute;
  top: -1.8rem;
  right: -1.5rem;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: rgba(76, 201, 255, 0.09);
  content: "";
}

.stat-card__label {
  position: relative;
  z-index: 1;
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-card__value {
  position: relative;
  z-index: 1;
  display: block;
  overflow: hidden;
  color: var(--ink-strong);
  font-size: clamp(1.38rem, 2.2vw, 2rem);
  font-weight: 860;
  letter-spacing: -0.04em;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-card__detail {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 0.34rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.stat-card--brand {
  border-color: rgba(0, 119, 255, 0.2);
  background: linear-gradient(145deg, rgba(234, 245, 255, 0.94), rgba(255, 255, 255, 0.92));
}

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

.dashboard-grid > .panel,
.dashboard-grid > .card {
  grid-column: span 6;
  min-width: 0;
}

.dashboard-grid > .panel--wide,
.dashboard-grid > .card--wide,
.dashboard-grid > [data-span="12"] {
  grid-column: 1 / -1;
}

.dashboard-grid > .panel--narrow,
.dashboard-grid > [data-span="4"] {
  grid-column: span 4;
}

.metric-list,
.summary-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  gap: 0.18rem;
}

.metric-list li,
.summary-list li {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.2rem;
  border-bottom: 1px solid rgba(0, 119, 255, 0.08);
  font-size: 0.81rem;
}

.metric-list li:last-child,
.summary-list li:last-child {
  border-bottom: 0;
}

.metric-list strong,
.summary-list strong {
  color: var(--ink-strong);
  font-weight: 820;
}

.progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eff5;
}

.progress__bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-bright));
}

.progress--success .progress__bar { background: linear-gradient(90deg, #148760, #55c59c); }
.progress--warning .progress__bar { background: linear-gradient(90deg, #d58b16, #ffc65c); }

.table-wrap,
.data-table-wrap,
.attendance-matrix-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid rgba(0, 119, 255, 0.1);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
  scrollbar-color: rgba(0, 119, 255, 0.3) transparent;
  scrollbar-width: thin;
}

.data-table,
.attendance-matrix,
table.app-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.79rem;
}

.data-table,
table.app-table {
  min-width: 680px;
}

.data-table--compact {
  min-width: 440px;
}

.data-table th,
.data-table td,
.attendance-matrix th,
.attendance-matrix td,
table.app-table th,
table.app-table td {
  padding: 0.72rem 0.78rem;
  border-bottom: 1px solid rgba(0, 119, 255, 0.075);
  text-align: left;
  vertical-align: middle;
}

.data-table th,
.attendance-matrix th,
table.app-table th {
  color: var(--muted-strong);
  background: rgba(244, 249, 253, 0.96);
  font-size: 0.67rem;
  font-weight: 820;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table thead th,
.attendance-matrix thead th,
table.app-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

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

.data-table tbody tr:hover td,
.attendance-matrix tbody tr:hover td,
table.app-table tbody tr:hover td {
  background: rgba(234, 245, 255, 0.48);
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  padding: 2rem;
  text-align: center;
}

.empty-state__icon {
  display: grid;
  width: 62px;
  height: 62px;
  margin: 0 auto 1rem;
  place-items: center;
  color: var(--brand);
  border-radius: 20px;
  background: var(--brand-soft);
  font-size: 1.55rem;
}

.empty-state h3 {
  margin-bottom: 0.35rem;
  font-size: 1.02rem;
}

.empty-state p {
  max-width: 46ch;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.sync-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.sync-summary__item {
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-subtle);
}

.sync-summary__item strong {
  display: block;
  color: var(--ink-strong);
  font-size: 1.15rem;
}

.sync-summary__item span {
  color: var(--muted);
  font-size: 0.7rem;
}

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

.code-card {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(249, 252, 255, 0.86);
  gap: 0.8rem;
}

.code-card__school {
  min-width: 0;
}

.code-card__school strong,
.code-card__school span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-card__school strong {
  font-size: 0.82rem;
}

.code-card__school span {
  color: var(--muted);
  font-size: 0.68rem;
}

.guest-code {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  padding: 0.48rem 0.7rem;
  color: var(--brand-deep);
  border: 1px dashed rgba(0, 119, 255, 0.3);
  border-radius: 10px;
  background: var(--brand-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.school-workspace {
  display: grid;
  min-width: 0;
  gap: 1rem;
}

.school-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  padding: 1rem 1.15rem;
  gap: 1rem;
}

.school-hero__logo {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  overflow: hidden;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
}

.school-hero__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.school-hero__copy {
  min-width: 0;
}

.school-hero__copy h1 {
  overflow: hidden;
  margin-bottom: 0.25rem;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  font-weight: 850;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.school-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  gap: 0.45rem;
}

.school-overview,
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-width: 0;
  align-items: start;
  gap: 1rem;
}

.workspace-main,
.workspace-aside {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 1rem;
}

.workspace-main > *,
.workspace-aside > * {
  min-width: 0;
}

.class-tabs,
.segmented-control,
.lesson-strip {
  display: flex;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.3rem;
  border: 1px solid rgba(0, 119, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  gap: 0.3rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.class-tabs::-webkit-scrollbar,
.segmented-control::-webkit-scrollbar,
.lesson-strip::-webkit-scrollbar {
  display: none;
}

.class-tab,
.segmented-control a,
.segmented-control button {
  display: inline-flex;
  min-height: 40px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.78rem;
  color: var(--muted-strong);
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 0.77rem;
  font-weight: 760;
  text-decoration: none;
  white-space: nowrap;
}

.class-tab:hover,
.class-tab[aria-current="page"],
.class-tab.is-active,
.segmented-control [aria-pressed="true"],
.segmented-control .is-active {
  color: var(--brand-deep);
  background: #fff;
  box-shadow: 0 3px 12px rgba(16, 67, 115, 0.09);
}

.lesson-strip {
  padding: 0.45rem;
  scroll-snap-type: x proximity;
}

.lesson-pill {
  display: grid;
  min-width: 112px;
  min-height: 66px;
  flex: 0 0 auto;
  align-content: center;
  padding: 0.55rem 0.68rem;
  color: var(--muted-strong);
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  text-align: left;
  text-decoration: none;
  scroll-snap-align: start;
}

.lesson-pill:hover,
.lesson-pill.is-active,
.lesson-pill[aria-current="true"] {
  color: var(--brand-deep);
  border-color: var(--line);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.lesson-pill__number {
  font-size: 0.67rem;
  font-weight: 820;
  text-transform: uppercase;
}

.lesson-pill__date {
  color: inherit;
  font-size: 0.76rem;
  font-weight: 760;
}

.lesson-pill--cancelled {
  color: var(--danger);
  background: var(--danger-soft);
}

.lesson-pill--makeup {
  color: var(--warning);
  background: var(--warning-soft);
}

.attendance-matrix {
  min-width: 820px;
}

.attendance-matrix th:first-child,
.attendance-matrix td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 220px;
  min-width: 220px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 1px 0 rgba(0, 119, 255, 0.08);
}

.attendance-matrix thead th:first-child {
  z-index: 3;
  background: rgba(244, 249, 253, 0.99);
}

.student-name {
  color: var(--ink-strong);
  font-weight: 780;
}

.student-meta {
  display: block;
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 560;
}

.attendance-toggle,
.attendance-cell button {
  display: grid;
  width: 36px;
  height: 36px;
  margin-inline: auto;
  place-items: center;
  color: var(--success);
  border: 1px solid rgba(20, 135, 96, 0.16);
  border-radius: 11px;
  background: var(--success-soft);
  font-size: 0.76rem;
  font-weight: 850;
}

.attendance-toggle.is-absent,
.attendance-toggle[aria-pressed="true"],
.attendance-cell.is-absent button {
  color: var(--danger);
  border-color: rgba(198, 64, 80, 0.17);
  background: var(--danger-soft);
}

.attendance-toggle.is-unavailable,
.attendance-cell.is-unavailable button {
  color: #9aa8b6;
  border-color: transparent;
  background: #edf2f6;
}

.mobile-roster,
.mobile-only {
  display: none;
}

.student-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.62rem;
}

.student-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 68px;
  padding: 0.75rem 0.82rem;
  border: 1px solid rgba(0, 119, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  gap: 0.8rem;
}

.student-row__main {
  min-width: 0;
}

.student-row__name {
  display: block;
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 0.86rem;
  font-weight: 790;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-row__meta {
  display: flex;
  flex-wrap: wrap;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.68rem;
  gap: 0.45rem;
}

.student-row__action {
  min-width: 92px;
}

details.student-row {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

details.student-row > summary {
  min-height: 44px;
  cursor: pointer;
}

details.student-row > .field--full {
  width: 100%;
  min-width: 0;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

details.student-row .toolbar-group {
  width: 100%;
  flex-wrap: wrap;
}

details.student-row .toolbar-group select {
  min-width: 0;
  flex: 1 1 220px;
}

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

.studentstats-section {
  min-width: 0;
}

.studentstats-section--wide {
  grid-column: 1 / -1;
}

.studentstats-section__title {
  margin: 0 0 0.55rem;
  color: var(--ink-strong);
  font-size: 0.82rem;
  font-weight: 820;
}

.song-list,
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.song-chip {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 0.38rem;
  padding: 0.36rem 0.62rem;
  color: var(--brand-deep);
  border: 1px solid rgba(0, 119, 255, 0.13);
  border-radius: 999px;
  background: var(--brand-soft);
  font-size: 0.7rem;
  font-weight: 720;
}

.song-chip--complete {
  color: var(--success);
  border-color: rgba(20, 135, 96, 0.14);
  background: var(--success-soft);
}

.song-chip button {
  display: grid;
  width: 24px;
  height: 24px;
  margin: -0.2rem -0.32rem -0.2rem 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.schedule-list,
.timeline {
  display: grid;
  gap: 0.55rem;
}

.schedule-item,
.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 58px;
  padding: 0.65rem 0.7rem;
  border: 1px solid rgba(0, 119, 255, 0.09);
  border-radius: 13px;
  background: rgba(250, 253, 255, 0.82);
  gap: 0.65rem;
}

.schedule-item__number,
.timeline-item__marker {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--brand-deep);
  border-radius: 11px;
  background: var(--brand-soft);
  font-size: 0.72rem;
  font-weight: 820;
}

.schedule-item__copy {
  min-width: 0;
}

.schedule-item__copy strong,
.schedule-item__copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-item__copy strong {
  font-size: 0.78rem;
}

.schedule-item__copy span {
  color: var(--muted);
  font-size: 0.67rem;
}

dialog.modal,
.modal[role="dialog"] {
  width: min(100% - 2rem, 560px);
  max-height: min(86vh, 780px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-lg);
}

dialog.modal[open] {
  animation: modal-in 190ms var(--ease) both;
}

dialog.modal::backdrop {
  background: rgba(5, 25, 47, 0.52);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.modal[role="dialog"].is-open:not(dialog) {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 110;
  display: block;
  transform: translate(-50%, -50%);
  animation: modal-fallback-in 190ms var(--ease) both;
}

.modal-fallback-backdrop {
  position: fixed;
  inset: 0;
  z-index: 105;
  background: rgba(5, 25, 47, 0.52);
  backdrop-filter: blur(7px);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
}

@keyframes modal-fallback-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)) scale(0.98); }
}

.modal__header,
.modal__body,
.modal__footer {
  padding: 1rem 1.15rem;
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  gap: 1rem;
}

.modal__header h2,
.modal__header h3 {
  margin-bottom: 0.22rem;
  font-size: 1.08rem;
}

.modal__header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.modal__body {
  max-height: calc(86vh - 154px);
  overflow-y: auto;
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  background: #fbfdff;
  gap: 0.65rem;
}

.modal__close {
  flex: 0 0 auto;
}

.mobile-panel {
  display: none;
}

.back-link {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 0.42rem;
  margin-bottom: 0.85rem;
  color: var(--muted-strong);
  font-size: 0.8rem;
  font-weight: 740;
  text-decoration: none;
}

.back-link:hover {
  color: var(--brand-deep);
}

.sr-only,
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.text-muted { color: var(--muted) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-right { text-align: right !important; }
.nowrap { white-space: nowrap !important; }
.full-width { width: 100% !important; }
.desktop-only { display: block; }

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

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

  .dashboard-grid > .panel--narrow,
  .dashboard-grid > [data-span="4"] {
    grid-column: span 6;
  }
}

@media (max-width: 980px) {
  :root {
    --header-height: 68px;
  }

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

  .dashboard-nav {
    position: static;
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    padding: 0.4rem;
    scrollbar-width: none;
  }

  .dashboard-nav::-webkit-scrollbar {
    display: none;
  }

  .dashboard-nav__label {
    display: none;
  }

  .dashboard-nav a,
  .dashboard-nav button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

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

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

@media (max-width: 820px) {
  .button,
  .btn,
  .button--small,
  .btn-sm,
  .toolbar-select,
  .attendance-toggle {
    min-height: 44px;
  }

  .attendance-toggle {
    min-width: 44px;
  }

  .app-header__inner,
  .page-shell,
  .container {
    width: min(100% - 1.5rem, var(--container));
  }

  .page-shell {
    padding-top: 1.25rem;
    padding-bottom: 3rem;
  }

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

  .page-actions {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.1rem;
  }

  .portal-intro {
    min-height: 170px;
  }

  .portal-intro__mark {
    width: 90px;
    height: 90px;
  }

  .dashboard-grid > .panel,
  .dashboard-grid > .card,
  .dashboard-grid > .panel--narrow,
  .dashboard-grid > [data-span="4"] {
    grid-column: 1 / -1;
  }

  .dashboard-toolbar,
  .workspace-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-group,
  .filter-group,
  .toolbar-actions {
    width: 100%;
  }

  .toolbar-select {
    min-width: 0;
    flex: 1;
  }

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

@media (max-width: 680px) {
  .button,
  .btn,
  .button--small,
  .btn-sm,
  .class-tab,
  .segmented-control a,
  .segmented-control button,
  .toolbar-select,
  .password-toggle {
    min-height: 44px;
  }

  .brand__tagline,
  .admin-pill,
  .session-pill {
    display: none;
  }

  .brand__name {
    max-width: 48vw;
    font-size: 0.88rem;
  }

  .app-header__actions .button:not(.button--icon),
  .app-header__actions .btn:not(.icon-button) {
    min-height: 44px;
    padding-inline: 0.72rem;
    font-size: 0.76rem;
  }

  .portal-intro {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .portal-intro__mark {
    display: none;
  }

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

  .school-card {
    min-height: 0;
    grid-template-columns: 112px minmax(0, 1fr);
    grid-template-rows: 116px;
  }

  .school-card__logo-wrap,
  .school-card__media {
    min-height: 0;
    padding: 0.8rem;
  }

  .school-card__logo,
  .school-card__media img,
  .school-card[data-school="maara"] .school-card__logo,
  .school-card--maara .school-card__logo,
  .school-card[data-school="wbjs"] .school-card__logo,
  .school-card--wbjs .school-card__logo {
    max-width: 90%;
    height: 76px;
  }

  .school-card__body {
    display: grid;
    align-content: center;
    padding: 0.85rem 0.9rem;
    border-top: 0;
    border-left: 1px solid color-mix(in srgb, var(--school-accent) 9%, white);
  }

  .form-grid,
  .sync-summary,
  .workspace-aside {
    grid-template-columns: 1fr;
  }

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

  .school-hero__actions {
    grid-column: 1 / -1;
    display: flex;
    width: 100%;
    overflow-x: auto;
    gap: 0.55rem;
  }

  .school-hero__actions > * {
    flex: 0 0 auto;
  }

  .school-hero__copy h1 {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .desktop-matrix,
  .attendance-matrix-wrap,
  .desktop-only {
    display: none !important;
  }

  .mobile-roster,
  .mobile-only {
    display: block;
  }

  .mobile-roster {
    margin-top: 0.8rem;
  }

  .mobile-panel {
    position: fixed;
    inset: auto 0 0;
    z-index: 115;
    display: block;
    max-height: min(82vh, 680px);
    overflow-y: auto;
    padding: 1rem 0.9rem calc(1rem + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -18px 70px rgba(7, 40, 72, 0.25);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 220ms var(--ease), visibility 220ms;
  }

  .mobile-panel.is-open {
    transform: translateY(0);
    visibility: visible;
  }

  .mobile-panel::before {
    display: block;
    width: 42px;
    height: 4px;
    margin: 0 auto 0.8rem;
    border-radius: 999px;
    background: #cfdae3;
    content: "";
  }

  .mobile-panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(5, 25, 47, 0.46);
    backdrop-filter: blur(4px);
  }

  dialog.modal,
  .modal[role="dialog"] {
    width: calc(100% - 1rem);
    max-height: 90vh;
    border-radius: 22px;
  }

  .modal__body {
    max-height: calc(90vh - 150px);
  }

  .modal__footer {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .modal__footer .button,
  .modal__footer .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .app-header__inner,
  .page-shell,
  .container {
    width: min(100% - 1rem, var(--container));
  }

  .brand {
    gap: 0.55rem;
  }

  .brand__mark,
  .portal-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .brand__name {
    max-width: 43vw;
    font-size: 0.79rem;
  }

  .app-header__actions {
    gap: 0.35rem;
  }

  .page-title {
    font-size: clamp(1.72rem, 9vw, 2.2rem);
  }

  .portal-intro {
    padding: 1.1rem;
    border-radius: 22px;
  }

  .portal-intro__title {
    font-size: 1.75rem;
  }

  .school-card {
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-rows: 108px;
    border-radius: 18px;
  }

  .school-card__logo,
  .school-card__media img,
  .school-card[data-school="maara"] .school-card__logo,
  .school-card--maara .school-card__logo,
  .school-card[data-school="wbjs"] .school-card__logo,
  .school-card--wbjs .school-card__logo {
    height: 66px;
  }

  .school-card__title {
    font-size: 0.9rem;
  }

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

  .stat-card {
    padding: 0.82rem;
  }

  .stat-card__value {
    font-size: 1.42rem;
  }

  .panel {
    padding: 0.9rem;
    border-radius: 18px;
  }

  .empty-state {
    min-height: 150px;
    padding: 1.25rem;
  }

  .dashboard-toolbar form.toolbar-group {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .dashboard-toolbar form.toolbar-group .button,
  .dashboard-toolbar form.toolbar-group .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .panel__header {
    align-items: stretch;
    flex-direction: column;
  }

  .code-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .code-card__school {
    grid-column: 1 / -1;
  }

  .code-card .guest-code {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .code-card form {
    margin: 0;
  }

  .school-hero {
    padding: 0.85rem;
    gap: 0.75rem;
  }

  .school-hero__logo {
    width: 58px;
    height: 58px;
    border-radius: 16px;
  }

  .school-hero__copy h1 {
    font-size: 1.16rem;
  }

  .lesson-pill {
    min-width: 104px;
  }

  .student-row {
    min-height: 72px;
  }

  .student-row__action {
    min-width: 108px;
  }

  .student-row__action .button,
  .student-row__action .btn {
    width: 100%;
  }

  details.student-row .toolbar-group select,
  details.student-row .toolbar-group .button,
  details.student-row .toolbar-group .btn {
    width: 100%;
    flex-basis: 100%;
  }

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

  .studentstats-section--wide {
    grid-column: auto;
  }

  .toast-region {
    top: calc(var(--header-height) + 0.5rem);
    right: 0.5rem;
    width: calc(100vw - 1rem);
  }
}

@media (max-width: 360px) {
  .brand__copy {
    display: none;
  }

  .stat-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .school-card {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .student-row {
    grid-template-columns: minmax(0, 1fr) minmax(104px, auto);
    padding-inline: 0.68rem;
  }

  .student-row__action {
    min-width: 104px;
    padding-inline: 0.45rem;
  }
}

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

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

@media (forced-colors: active) {
  .button,
  .btn,
  .panel,
  .card,
  .school-card,
  .stat-card,
  input,
  select,
  textarea {
    border: 1px solid CanvasText;
  }

  .progress__bar,
  .switch__track {
    background: Highlight;
  }
}

@media print {
  body {
    background: #fff;
  }

  body::before,
  .app-header,
  .app-footer,
  .dashboard-nav,
  .page-actions,
  .toolbar-actions,
  .button,
  .btn,
  .toast-region {
    display: none !important;
  }

  .page-shell,
  .container {
    width: 100%;
  }

  .panel,
  .card,
  .stat-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
