:root {
  color-scheme: light;
  --page: #f4f5f7;
  --surface: #ffffff;
  --surface-subtle: #f7f8f9;
  --text: #172b4d;
  --text-soft: #44546f;
  --muted: #626f86;
  --border: #dcdfe4;
  --border-strong: #b7bec8;
  --navy: #12344d;
  --navy-dark: #0b273b;
  --navy-muted: #b8c7d1;
  --primary: #0c66e4;
  --primary-hover: #0055cc;
  --primary-soft: #e9f2ff;
  --success: #216e4e;
  --success-soft: #dcfff1;
  --warning: #974f0c;
  --warning-soft: #fff3d6;
  --danger: #ae2a19;
  --danger-hover: #8f1f12;
  --danger-soft: #ffeceb;
  --info: #0055cc;
  --info-soft: #e9f2ff;
  --radius-sm: 4px;
  --radius-lg: 8px;
  --overlay-shadow: 0 16px 40px rgba(9, 30, 66, 0.22);
  --sidebar-width: 280px;
  --topbar-height: 72px;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}

body.modal-open {
  overflow: hidden;
}

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

button {
  color: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input,
select {
  min-height: 42px;
  padding: 8px 10px;
}

textarea {
  min-height: 88px;
  padding: 10px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #8993a4;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3,
strong {
  font-weight: 650;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.2;
}

h2 {
  font-size: 1.15rem;
  line-height: 1.3;
}

h3 {
  font-size: 1rem;
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 1.9;
}

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

.mobile-only {
  display: none !important;
}

.noscript-message,
.boot-screen {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--surface);
}

.noscript-message {
  color: var(--text);
  padding: 24px;
  text-align: center;
}

.boot-screen {
  place-content: center;
  justify-items: center;
  gap: 18px;
}

.loader {
  width: 26px;
  height: 26px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.setup-notice {
  position: fixed;
  z-index: 1100;
  top: 16px;
  left: 50%;
  display: flex;
  width: min(620px, calc(100% - 28px));
  align-items: flex-start;
  gap: 12px;
  border: 1px solid #e2b203;
  border-radius: var(--radius-sm);
  background: #fff7d6;
  box-shadow: var(--overlay-shadow);
  color: #5f3811;
  padding: 14px 16px;
  transform: translateX(-50%);
}

.setup-notice > svg {
  margin-top: 2px;
}

.setup-notice div {
  display: grid;
  gap: 2px;
}

.setup-notice code {
  font-size: 0.9em;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-lockup > span:last-child {
  display: grid;
  gap: 1px;
}

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

.brand-lockup small {
  color: var(--muted);
  font-size: 0.72rem;
}

.brand-lockup-light {
  color: #ffffff;
}

.brand-lockup-light small {
  color: var(--navy-muted);
}

.brand-logo {
  width: 34px;
  height: 44px;
  flex: 0 0 34px;
  object-fit: contain;
}

.brand-logo-large {
  width: 52px;
  height: 68px;
}

/* Acceso */

.auth-view {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(380px, 0.82fr) minmax(480px, 1.18fr);
  background: var(--surface);
}

.auth-brand {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  background: var(--navy);
  color: #ffffff;
  padding: 44px 50px 34px;
}

.auth-brand-message {
  max-width: 500px;
  padding: 60px 0;
}

.auth-kicker,
.section-label,
.context-label,
.focus-eyebrow {
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.auth-kicker {
  color: #9fc3dc;
}

.auth-brand-message h1 {
  max-width: 470px;
  margin-top: 14px;
  font-size: 2.65rem;
  font-weight: 600;
  line-height: 1.1;
}

.auth-brand-message p {
  max-width: 440px;
  margin-top: 18px;
  color: #cfdae2;
  font-size: 1rem;
  line-height: 1.6;
}

.auth-brand-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--navy-muted);
  font-size: 0.78rem;
}

.auth-brand-footer span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.auth-access {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 40px;
}

.auth-card {
  width: min(420px, 100%);
}

.mobile-brand-logo {
  display: none;
}

.auth-heading {
  margin-bottom: 26px;
}

.auth-heading h2 {
  margin-top: 8px;
  font-size: 1.75rem;
  font-weight: 600;
}

.auth-heading > p:last-child {
  margin-top: 7px;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 15px;
}

.form-field {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.form-field > span:first-child,
.color-field legend {
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 650;
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
}

.input-shell > svg {
  position: absolute;
  z-index: 1;
  left: 12px;
  width: 17px;
  color: var(--muted);
  pointer-events: none;
}

.input-shell input {
  min-height: 44px;
  padding-left: 38px;
  padding-right: 40px;
}

.input-icon-button {
  position: absolute;
  right: 4px;
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
}

.input-icon-button:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.forgot-button {
  justify-self: end;
  margin-top: -5px;
}

.button,
.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button {
  min-height: 40px;
  gap: 7px;
  padding: 0 14px;
}

.button-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.button-primary:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text-soft);
}

.button-secondary:hover:not(:disabled) {
  border-color: #8590a2;
  background: var(--surface-subtle);
  color: var(--text);
}

.button-quiet {
  border-color: transparent;
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.button-quiet:hover:not(:disabled) {
  border-color: #cce0ff;
  background: #deebff;
}

.button-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.button-danger:hover:not(:disabled) {
  border-color: var(--danger-hover);
  background: var(--danger-hover);
}

.button-google {
  position: relative;
  min-height: 44px;
  border-color: #747775;
  background: var(--surface);
  color: #1f1f1f;
  font-family: "Roboto", Arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 0 40px;
}

.button-google:hover:not(:disabled) {
  background: #f8faff;
}

.button-full {
  width: 100%;
  min-height: 44px;
}

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-color: var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 0;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
  color: var(--text);
}

.icon-button-dark {
  border-color: rgba(255, 255, 255, 0.18);
  background: transparent;
  color: #d9e2e8;
}

.icon-button-dark:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.icon-button-accent {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  border-color: #ffffff;
  background: #ffffff;
  color: var(--navy);
}

.icon-button-accent:hover:not(:disabled) {
  border-color: #dbe5eb;
  background: #edf2f5;
  color: var(--navy-dark);
}

.text-button {
  min-height: 28px;
  color: var(--primary-hover);
  padding: 2px 0;
}

.text-button:hover:not(:disabled) {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.google-logo {
  position: absolute;
  left: 12px;
  width: auto;
  height: 20px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.76rem;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  flex: 1;
  background: var(--border);
  content: "";
}

.form-message {
  min-height: 22px;
  margin-top: 11px;
  color: var(--danger);
  font-size: 0.83rem;
}

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

.register-copy {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Estructura principal */

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

.app-sidebar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  width: var(--sidebar-width);
  height: 100vh;
  min-height: 560px;
  flex-direction: column;
  background: var(--navy);
  color: #ffffff;
}

.sidebar-brand {
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 14px 18px;
}

.sidebar-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--navy-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 16px 16px 9px;
}

.sidebar-search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 12px 12px;
}

.sidebar-search > svg {
  position: absolute;
  left: 10px;
  width: 16px;
  color: #93a9b8;
}

.sidebar-search input {
  min-height: 36px;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.08);
  color: #ffffff;
  font-size: 0.82rem;
  padding-left: 34px;
}

.sidebar-search input::placeholder {
  color: #9eb1be;
}

.sidebar-search input:focus {
  border-color: #9fc3dc;
  box-shadow: 0 0 0 1px #9fc3dc;
}

.subject-list {
  display: grid;
  min-height: 0;
  flex: 1;
  align-content: start;
  gap: 2px;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 0 8px 14px;
}

.subject-item {
  --subject-color: var(--primary);
  position: relative;
  display: grid;
  width: 100%;
  min-height: 58px;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #edf2f5;
  padding: 8px 9px;
  text-align: left;
}

.subject-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.subject-item.active {
  background: rgba(255, 255, 255, 0.12);
}

.subject-item.active::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 3px;
  background: var(--subject-color);
  content: "";
}

.subject-icon {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--subject-color);
  color: #ffffff;
}

.subject-icon svg {
  width: 15px;
  height: 15px;
}

.subject-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.subject-copy strong,
.subject-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject-copy strong {
  font-size: 0.84rem;
}

.subject-copy small {
  color: var(--navy-muted);
  font-size: 0.69rem;
}

.sidebar-empty {
  display: grid;
  justify-items: center;
  gap: 7px;
  color: var(--navy-muted);
  font-size: 0.78rem;
  padding: 32px 14px;
  text-align: center;
}

.sidebar-account {
  display: flex;
  min-height: 68px;
  align-items: center;
  gap: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 10px 12px;
}

.user-avatar {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 50%;
  background: #dbe5eb;
  color: var(--navy);
  font-size: 0.74rem;
  font-weight: 750;
}

.account-copy {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 1px;
}

.account-copy strong,
.account-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy strong {
  font-size: 0.8rem;
}

.account-copy small {
  color: var(--navy-muted);
  font-size: 0.67rem;
}

.sidebar-account .icon-button {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.app-content {
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 40;
  top: 0;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 24px;
}

.topbar-context {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.topbar-context > div {
  min-width: 0;
}

.topbar-context h1,
.topbar-context p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-label {
  margin-bottom: 3px;
  color: var(--muted);
}

.topbar-actions,
.page-heading-actions,
.toolbar-actions,
.date-navigation {
  display: flex;
  align-items: center;
  gap: 7px;
}

.workspace-shell {
  width: min(100%, 1580px);
  margin: 0 auto;
  padding: 0 24px 40px;
}

.welcome-state {
  display: grid;
  min-height: calc(100vh - var(--topbar-height) - 64px);
  max-width: 520px;
  place-content: center;
  justify-items: center;
  margin: 0 auto;
  color: var(--muted);
  text-align: center;
}

.welcome-state .section-label {
  margin-top: 16px;
}

.welcome-state h2 {
  margin-top: 6px;
  color: var(--text);
  font-size: 1.5rem;
}

.welcome-state p:not(.section-label) {
  max-width: 390px;
  margin-top: 8px;
}

.welcome-state .button {
  margin-top: 20px;
}

.empty-icon {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
}

.empty-icon svg {
  width: 22px;
  height: 22px;
}

.workspace-tabs {
  position: sticky;
  z-index: 30;
  top: var(--topbar-height);
  display: flex;
  min-height: 54px;
  align-items: end;
  gap: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--page);
  scrollbar-width: none;
}

.workspace-tabs::-webkit-scrollbar {
  display: none;
}

.tab-button {
  position: relative;
  display: inline-flex;
  min-width: max-content;
  min-height: 48px;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 650;
  padding: 0 14px;
}

.tab-button::after {
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  background: transparent;
  content: "";
}

.tab-button:hover {
  color: var(--text);
}

.tab-button.active {
  color: var(--primary-hover);
}

.tab-button.active::after {
  background: var(--primary);
}

.workspace-page {
  padding-top: 20px;
}

/* Resumen */

.teacher-focus {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 15px 17px;
}

.teacher-focus-copy {
  min-width: 0;
}

.focus-eyebrow {
  color: var(--muted);
}

.teacher-focus h2 {
  margin-top: 4px;
  font-size: 1.08rem;
}

.teacher-focus p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.quick-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
}

.quick-action {
  min-height: 38px;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.stat-card {
  display: flex;
  min-width: 0;
  min-height: 102px;
  align-items: center;
  gap: 12px;
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 18px;
}

.stat-card:first-child {
  border-left: 0;
}

.stat-icon {
  display: inline-grid;
  width: 28px;
  height: 32px;
  flex: 0 0 28px;
  place-items: center;
  color: var(--muted);
}

.stat-students .stat-icon {
  color: var(--info);
}

.stat-average .stat-icon,
.stat-approved .stat-icon {
  color: var(--success);
}

.stat-risk .stat-icon {
  color: var(--warning);
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.stat-copy small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.stat-copy strong {
  color: var(--text);
  font-size: 1.55rem;
  line-height: 1.15;
}

.stat-copy > span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 14px;
  margin-top: 14px;
}

.surface-section,
.data-surface,
.history-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.surface-section {
  min-width: 0;
  padding: 18px;
}

.section-heading,
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2,
.page-heading h2 {
  margin-top: 4px;
}

.page-heading {
  min-height: 58px;
  margin-bottom: 14px;
}

.page-heading > div:first-child {
  min-width: 0;
}

.page-heading > div:first-child > p:last-child:not(.section-label) {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.subtle-badge,
.status-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  white-space: nowrap;
}

.subtle-badge {
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-soft);
}

.performance-summary {
  margin-top: 18px;
}

.stacked-progress {
  display: flex;
  width: 100%;
  height: 7px;
  overflow: hidden;
  background: #ebecf0;
}

.stacked-progress span {
  width: 0;
  height: 100%;
  transition: width 180ms ease;
}

.progress-approved {
  background: var(--success);
}

.progress-risk {
  background: var(--danger);
}

.progress-pending {
  background: #8993a4;
}

.progress-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 0.74rem;
}

.progress-legend span,
.attendance-stats > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.progress-legend strong,
.attendance-stats strong {
  color: var(--text);
}

.legend-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
}

.approved-dot {
  background: var(--success);
}

.risk-dot {
  background: var(--danger);
}

.pending-dot {
  background: #8993a4;
}

.late-dot {
  background: var(--warning);
}

.justified-dot {
  background: var(--info);
}

.compact-list {
  display: grid;
  margin-top: 17px;
}

.compact-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  border-top: 1px solid var(--border);
  padding: 10px 0;
}

.compact-row:first-child {
  border-top: 0;
}

.compact-row .student-avatar {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
}

.compact-row-copy {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 1px;
}

.compact-row-copy strong,
.compact-row-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-row-copy strong {
  font-size: 0.8rem;
}

.compact-row-copy small {
  color: var(--muted);
  font-size: 0.7rem;
}

.compact-value {
  font-size: 0.78rem;
  font-weight: 700;
}

.empty-compact {
  display: grid;
  min-height: 100px;
  place-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.attendance-overview {
  display: grid;
  margin-top: 16px;
}

.attendance-ring-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.attendance-ring {
  display: grid;
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  place-items: center;
  border: 6px solid #dce8f5;
  border-radius: 50%;
  color: var(--primary-hover);
  font-size: 0.92rem;
  font-weight: 750;
}

.attendance-ring-copy {
  display: grid;
  gap: 2px;
}

.attendance-ring-copy strong {
  font-size: 0.86rem;
}

.attendance-ring-copy span {
  color: var(--muted);
  font-size: 0.74rem;
}

.recent-heading {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* Datos y tablas */

.data-surface {
  min-width: 0;
  overflow: hidden;
}

.data-toolbar {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  padding: 9px 12px;
}

.search-control {
  position: relative;
  display: flex;
  width: min(350px, 100%);
  align-items: center;
}

.search-control > svg {
  position: absolute;
  left: 10px;
  width: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search-control input {
  min-height: 38px;
  background: var(--surface);
  padding-left: 34px;
}

.select-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
}

.select-control select {
  width: 140px;
  min-height: 38px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

.students-table {
  min-width: 900px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

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

tbody tr:hover td {
  background: #fafbfc;
}

.student-cell {
  display: flex;
  min-width: 190px;
  align-items: center;
  gap: 9px;
}

.student-avatar {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 50%;
  background: #deebff;
  color: var(--primary-hover);
  font-size: 0.7rem;
  font-weight: 750;
}

.student-primary {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.student-primary strong,
.student-primary small {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-primary strong {
  font-size: 0.82rem;
}

.student-primary small {
  color: var(--muted);
  font-size: 0.69rem;
}

.grade-progress {
  display: grid;
  min-width: 90px;
  gap: 4px;
}

.grade-progress small {
  color: var(--muted);
  font-size: 0.69rem;
}

.mini-progress {
  width: 80px;
  height: 4px;
  overflow: hidden;
  background: #ebecf0;
}

.mini-progress span {
  display: block;
  height: 100%;
  background: var(--primary);
}

.average-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.status-badge.approved {
  background: var(--success-soft);
  color: var(--success);
}

.status-badge.risk {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-badge.pending {
  background: #ebecf0;
  color: var(--muted);
}

.actions-col {
  width: 88px;
  text-align: right;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.row-actions .icon-button {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
}

.row-actions .delete-action:hover {
  border-color: #f5b7af;
  background: var(--danger-soft);
  color: var(--danger);
}

.inline-empty-state {
  display: grid;
  min-height: 290px;
  place-content: center;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  padding: 26px;
  text-align: center;
}

.inline-empty-state strong {
  margin-top: 7px;
  color: var(--text);
}

.inline-empty-state > span:last-child {
  font-size: 0.8rem;
}

.save-status,
.toolbar-note {
  color: var(--muted);
  font-size: 0.74rem;
}

.save-status.dirty {
  color: var(--warning);
  font-weight: 650;
}

.gradebook-help {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px 14px;
}

.gradebook-help .toolbar-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.gradebook-help svg {
  width: 14px;
  height: 14px;
}

.gradebook-wrap {
  max-height: calc(100vh - 252px);
  min-height: 250px;
}

.gradebook-table {
  min-width: 760px;
}

.gradebook-table th {
  position: sticky;
  z-index: 3;
  top: 0;
}

.gradebook-table th:first-child,
.gradebook-table td:first-child {
  position: sticky;
  z-index: 2;
  left: 0;
  min-width: 220px;
  background: var(--surface);
}

.gradebook-table th:first-child {
  z-index: 4;
  background: var(--surface-subtle);
}

.gradebook-table .period-column {
  width: 106px;
  min-width: 106px;
  text-align: center;
}

.gradebook-table .period-column span,
.gradebook-table .period-column small {
  display: block;
}

.gradebook-table .period-column small {
  margin-top: 2px;
  color: var(--primary-hover);
  font-size: 0.62rem;
}

.gradebook-table .summary-column {
  width: 110px;
  min-width: 110px;
}

.grade-cell {
  text-align: center;
}

.gradebook-input {
  width: 76px;
  min-height: 36px;
  margin: 0 auto;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  text-align: center;
}

.gradebook-input.dirty {
  border-color: #cf8d16;
  background: var(--warning-soft);
}

.gradebook-row.dirty td:first-child {
  box-shadow: inset 3px 0 0 #cf8d16;
}

/* Asistencia */

.attendance-page-heading {
  align-items: flex-end;
}

.autosave-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  color: var(--success);
  font-size: 0.68rem;
  font-weight: 650;
}

.autosave-note svg {
  width: 14px;
  height: 14px;
}

.date-navigation input {
  width: 150px;
}

.period-control {
  display: grid;
  min-width: 168px;
  gap: 2px;
}

.period-control span {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
}

.period-control select {
  min-height: 38px;
}

.attendance-stats {
  display: flex;
  min-height: 46px;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px 22px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.76rem;
  padding: 8px 14px;
}

.attendance-pending {
  margin-left: auto;
}

.attendance-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
}

.attendance-toolbar {
  flex-wrap: wrap;
}

.attendance-list {
  display: grid;
}

.attendance-row {
  display: grid;
  min-height: 64px;
  grid-template-columns: minmax(190px, 1fr) auto;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}

.attendance-row:last-child {
  border-bottom: 0;
}

.attendance-student {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.attendance-student-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.attendance-student-copy strong,
.attendance-student-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attendance-student-copy strong {
  font-size: 0.82rem;
}

.attendance-student-copy small {
  color: var(--muted);
  font-size: 0.68rem;
}

.attendance-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(82px, 1fr));
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.attendance-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  padding: 0 8px;
}

.attendance-button:first-child {
  border-left: 0;
}

.attendance-button:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.attendance-button.active.presente {
  background: var(--success-soft);
  color: var(--success);
}

.attendance-button.active.retardo {
  background: var(--warning-soft);
  color: var(--warning);
}

.attendance-button.active.falta {
  background: var(--danger-soft);
  color: var(--danger);
}

.attendance-button.active.justificado {
  background: var(--info-soft);
  color: var(--info);
}

.attendance-button svg {
  width: 14px;
  height: 14px;
}

.history-panel {
  align-self: start;
  overflow: hidden;
}

.history-panel > .section-heading {
  min-height: 58px;
  border-bottom: 1px solid var(--border);
  padding: 10px 13px;
}

.history-list {
  display: grid;
}

.history-item {
  display: grid;
  min-height: 56px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 10px;
  text-align: left;
}

.history-item:last-child {
  border-bottom: 0;
}

.history-item:hover,
.history-item.active {
  background: var(--surface-subtle);
}

.history-item.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.history-date-block {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--primary-hover);
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  text-transform: uppercase;
}

.history-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.history-copy strong {
  font-size: 0.76rem;
}

.history-copy small {
  color: var(--muted);
  font-size: 0.66rem;
}

.history-rate {
  color: var(--success);
  font-size: 0.72rem;
  font-weight: 700;
}

.history-empty {
  display: grid;
  min-height: 140px;
  place-items: center;
  color: var(--muted);
  font-size: 0.76rem;
  padding: 16px;
  text-align: center;
}

/* Formularios y ventanas */

.modal {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 30, 66, 0.58);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(600px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--overlay-shadow);
}

.modal-dialog-wide {
  width: min(900px, 100%);
}

.modal-dialog-subject {
  width: min(720px, 100%);
}

.modal-dialog-small {
  width: min(430px, 100%);
}

.modal-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 13px 18px;
}

.modal-header h2 {
  margin-top: 3px;
}

.modal-form {
  display: grid;
  gap: 18px;
  padding: 18px;
}

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

.student-form-grid {
  grid-template-columns: minmax(140px, 0.7fr) minmax(110px, 0.5fr) minmax(250px, 1.3fr) minmax(150px, 0.7fr);
}

.form-field-wide {
  grid-column: 1 / -1;
}

.color-field {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.color-options {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.color-swatch {
  position: relative;
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  cursor: pointer;
}

.color-swatch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.color-swatch span {
  width: 24px;
  height: 24px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--border-strong);
}

.color-swatch input:checked + span {
  box-shadow: 0 0 0 2px var(--text);
}

.color-swatch input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.color-teal span {
  background: #14766f;
}

.color-blue span {
  background: #3d78b4;
}

.color-coral span {
  background: #c75c3d;
}

.color-violet span {
  background: #6554c0;
}

.color-green span {
  background: #438562;
}

.acta-weight-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border-left: 3px solid var(--info);
  background: var(--info-soft);
  color: var(--text-soft);
  padding: 10px 12px;
  font-size: 0.77rem;
}

.acta-weight-note svg {
  flex: 0 0 auto;
  width: 16px;
  color: var(--info);
}

.rounding-settings {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: 14px;
}

.rounding-settings-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.rounding-settings-heading h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
}

.rounding-settings-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.rounding-example {
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  color: var(--text);
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 700;
}

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

.period-weights-field {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--border);
  padding: 14px;
}

.period-weights-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.period-weights-heading h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

.period-weights-field > p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.period-weights-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.period-weight-input {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.period-weight-input > span {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 650;
}

.percentage-input {
  position: relative;
}

.percentage-input input {
  width: 100%;
  padding-right: 28px;
}

.percentage-input > span {
  position: absolute;
  top: 50%;
  right: 10px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.period-weight-total {
  flex: 0 0 auto;
  border: 1px solid var(--success);
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  padding: 3px 9px;
  font-size: 0.74rem;
  font-weight: 700;
}

.period-weight-total.invalid {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.period-weights-field .period-weight-message {
  min-height: 18px;
  margin-top: 8px;
  color: var(--success);
  font-weight: 650;
}

.period-weights-field .period-weight-message.invalid {
  color: var(--danger);
}

.modal-subsection {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.modal-subsection-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-subsection-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.grade-input-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.modal-footer .danger-left {
  margin-right: auto;
}

.confirm-content {
  display: grid;
  justify-items: center;
  padding: 26px 24px 18px;
  text-align: center;
}

.confirm-icon {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
}

.confirm-content h2 {
  margin-top: 13px;
}

.confirm-content p {
  margin-top: 8px;
  color: var(--muted);
}

.modal-dialog-small .modal-footer {
  border-top: 0;
  padding: 0 18px 18px;
}

.toast-region {
  position: fixed;
  z-index: 300;
  right: 16px;
  bottom: 16px;
  display: grid;
  width: min(370px, calc(100% - 32px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 26px;
  align-items: start;
  gap: 9px;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--overlay-shadow);
  color: var(--text);
  padding: 11px 9px 11px 11px;
  pointer-events: auto;
  animation: toast-in 160ms ease-out;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warning {
  border-left-color: var(--warning);
}

.toast > svg {
  color: var(--success);
}

.toast.error > svg {
  color: var(--danger);
}

.toast.warning > svg {
  color: var(--warning);
}

.toast-copy {
  display: grid;
  gap: 2px;
}

.toast-copy strong {
  font-size: 0.8rem;
}

.toast-copy span {
  color: var(--muted);
  font-size: 0.74rem;
}

.toast-close {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.toast-close:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

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

.button.is-loading,
.icon-button.is-loading,
.text-button.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.button.is-loading::after,
.icon-button.is-loading::after,
.text-button.is-loading::after {
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: #ffffff;
  content: "";
  animation: spin 650ms linear infinite;
}

.button-secondary.is-loading::after,
.button-google.is-loading::after,
.icon-button.is-loading::after,
.text-button.is-loading::after {
  color: var(--primary);
}

.button-google.is-loading .google-logo {
  visibility: hidden;
}

/* Adaptación */

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

  .stat-card:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .stat-card:nth-child(4) {
    border-top: 1px solid var(--border);
  }

  .overview-grid,
  .attendance-layout {
    grid-template-columns: 1fr;
  }

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

  .history-item:nth-child(odd) {
    border-right: 1px solid var(--border);
  }
}

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

  .auth-brand {
    display: none;
  }

  .auth-access {
    padding: 30px 22px;
  }

  .mobile-brand-logo {
    display: block;
    margin-bottom: 24px;
  }

  .mobile-only {
    display: inline-grid !important;
  }

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

  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-width), calc(100vw - 44px));
    transform: translateX(-102%);
    transition: transform 160ms ease;
  }

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

  .sidebar-backdrop {
    position: fixed;
    z-index: 45;
    inset: 0;
    background: rgba(9, 30, 66, 0.52);
  }

  .topbar {
    padding-right: 18px;
    padding-left: 18px;
  }

  .workspace-shell {
    padding-right: 18px;
    padding-left: 18px;
  }

  .teacher-focus {
    align-items: flex-start;
    flex-direction: column;
  }

  .quick-actions {
    width: 100%;
  }

  .attendance-row {
    grid-template-columns: 1fr;
  }

  .attendance-actions {
    width: 100%;
  }

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

@media (max-width: 700px) {
  :root {
    --topbar-height: 64px;
  }

  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }

  h1 {
    font-size: 1.15rem;
  }

  .auth-access {
    align-items: start;
    padding: 24px 18px;
  }

  .auth-heading h2 {
    font-size: 1.55rem;
  }

  .topbar {
    gap: 9px;
    padding: 8px 12px;
  }

  .topbar-context {
    min-width: 0;
    flex: 1;
  }

  .topbar-context .context-label {
    max-width: 54vw;
    font-size: 0.6rem;
  }

  .topbar-actions {
    gap: 4px;
  }

  .compact-action {
    width: 38px;
    min-height: 38px;
    padding: 0;
  }

  .compact-action span {
    display: none;
  }

  .workspace-shell {
    padding-right: 10px;
    padding-bottom: 24px;
    padding-left: 10px;
  }

  .workspace-tabs {
    position: fixed;
    z-index: 80;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    min-height: calc(62px + env(safe-area-inset-bottom));
    align-items: start;
    border-top: 1px solid var(--border);
    border-bottom: 0;
    background: var(--surface);
    padding: 5px 4px calc(4px + env(safe-area-inset-bottom));
  }

  .tab-button {
    min-width: 0;
    min-height: 52px;
    flex: 1;
    flex-direction: column;
    gap: 3px;
    font-size: 0.64rem;
    padding: 6px 2px;
  }

  .tab-button::after {
    top: -6px;
    right: 10px;
    bottom: auto;
    left: 10px;
  }

  .tab-button svg {
    width: 18px;
    height: 18px;
  }

  .workspace-page {
    padding-top: 14px;
  }

  .teacher-focus {
    min-height: 0;
    gap: 13px;
    padding: 13px 14px;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .quick-action {
    width: 100%;
  }

  .quick-action:first-child {
    grid-column: 1 / -1;
  }

  .stats-grid {
    margin-top: 10px;
  }

  .stat-card {
    min-height: 96px;
    gap: 8px;
    padding: 12px 10px;
  }

  .stat-copy strong {
    font-size: 1.35rem;
  }

  .surface-section {
    padding: 14px;
  }

  .page-heading {
    min-height: 0;
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 12px;
  }

  .page-heading > .button,
  .page-heading-actions {
    width: 100%;
  }

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

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

  .search-control,
  .select-control,
  .select-control select {
    width: 100%;
  }

  .select-control {
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
  }

  .students-table {
    min-width: 0;
  }

  .students-table thead {
    display: none;
  }

  .students-table,
  .students-table tbody,
  .students-table tr,
  .students-table td {
    display: block;
    width: 100%;
  }

  .students-table tr {
    border-bottom: 1px solid var(--border);
    padding: 11px 12px;
  }

  .students-table tr:last-child {
    border-bottom: 0;
  }

  .students-table td {
    display: flex;
    min-height: 34px;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 0;
    padding: 4px 0;
    text-align: right;
  }

  .students-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.66rem;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
  }

  .students-table td:first-child {
    min-height: 46px;
    justify-content: flex-start;
    padding-bottom: 9px;
  }

  .students-table td:first-child::before,
  .students-table td:last-child::before {
    display: none;
  }

  .student-cell {
    width: 100%;
  }

  .student-primary strong,
  .student-primary small {
    max-width: calc(100vw - 112px);
  }

  .actions-col {
    width: 100%;
  }

  .row-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .gradebook-help {
    display: grid;
    justify-content: stretch;
  }

  .gradebook-wrap {
    max-height: none;
    min-height: 0;
    overflow: visible;
    background: var(--page);
    padding: 8px;
  }

  .gradebook-table,
  .gradebook-table tbody,
  .gradebook-table tr,
  .gradebook-table td {
    display: block;
    width: 100%;
  }

  .gradebook-table {
    min-width: 0;
  }

  .gradebook-table thead {
    display: none;
  }

  .gradebook-table tbody {
    display: grid;
    gap: 8px;
  }

  .gradebook-table .gradebook-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 12px;
  }

  .gradebook-table .gradebook-row > td {
    position: static;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 0;
  }

  .gradebook-table .gradebook-row > td:first-child {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--border);
    padding-bottom: 9px;
  }

  .grade-cell,
  .grade-summary {
    display: grid !important;
    gap: 4px;
  }

  .grade-cell::before,
  .grade-summary::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
  }

  .gradebook-input {
    width: 100%;
    min-height: 44px;
    margin: 0;
    font-size: 0.95rem;
  }

  .grade-summary {
    min-height: 46px;
    align-content: center;
    border: 1px solid var(--border) !important;
    background: var(--surface-subtle) !important;
    padding: 7px 9px !important;
  }

  .gradebook-row.dirty td:first-child {
    box-shadow: none;
  }

  .gradebook-table .gradebook-row.dirty {
    border-left: 3px solid #cf8d16;
  }

  .attendance-page-heading {
    gap: 12px;
  }

  .date-navigation {
    display: grid;
    width: 100%;
    grid-template-columns: 40px minmax(0, 1fr) 40px auto;
  }

  .date-navigation input {
    width: 100%;
  }

  .date-navigation .period-control {
    grid-column: 1 / -1;
    width: 100%;
  }

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

  .attendance-pending {
    margin-left: 0;
  }

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

  .attendance-button {
    min-height: 44px;
  }

  .attendance-button:nth-child(3) {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .attendance-button:nth-child(4) {
    border-top: 1px solid var(--border);
  }

  .attendance-toolbar .toolbar-actions {
    width: 100%;
  }

  .attendance-toolbar .toolbar-actions .button {
    flex: 1;
  }

  .history-list {
    grid-template-columns: 1fr;
  }

  .history-item:nth-child(odd) {
    border-right: 0;
  }

  .modal {
    align-items: end;
    padding: 0;
  }

  .modal-dialog {
    width: 100%;
    max-height: calc(100vh - 16px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .modal-form,
  .modal-header {
    padding-right: 15px;
    padding-left: 15px;
  }

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

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

  .rounding-settings-heading {
    display: grid;
  }

  .rounding-example {
    width: fit-content;
  }

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

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

  .modal-footer .button {
    width: 100%;
  }

  .modal-footer .danger-left {
    margin-right: 0;
  }

  .toast-region {
    right: 10px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    width: calc(100% - 20px);
  }
}

@media (max-width: 420px) {
  .rounding-controls {
    grid-template-columns: 1fr;
  }

  .topbar-actions > .compact-action {
    display: none;
  }

  .topbar-actions > .icon-button {
    display: inline-grid;
  }

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

  .stat-card,
  .stat-card:nth-child(3),
  .stat-card:nth-child(4) {
    min-height: 82px;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .stat-card:first-child {
    border-top: 0;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .quick-action:first-child {
    grid-column: auto;
  }

  .date-navigation {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .date-navigation #todayBtn {
    grid-column: 1 / -1;
  }

  .grade-input-grid {
    grid-template-columns: 1fr;
  }
}

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