:root {
  color-scheme: light;
  --canvas: #f3f5f6;
  --surface: #ffffff;
  --surface-subtle: #f8f9fa;
  --surface-strong: #eef1f2;
  --ink: #172125;
  --ink-soft: #354349;
  --muted: #6a767d;
  --line: #dfe4e6;
  --line-strong: #cbd3d6;
  --sidebar: #17383b;
  --sidebar-deep: #102a2d;
  --sidebar-muted: #aac0c2;
  --primary: #14766f;
  --primary-dark: #0d5d58;
  --primary-soft: #e7f3f1;
  --accent: #e36f51;
  --accent-soft: #fff0ec;
  --blue: #3d78b4;
  --blue-soft: #eaf2fa;
  --violet: #785fa0;
  --green: #438562;
  --success: #287a50;
  --success-soft: #e7f4ec;
  --warning: #aa7017;
  --warning-soft: #fff5df;
  --danger: #b83d46;
  --danger-dark: #933038;
  --danger-soft: #fcecee;
  --shadow-sm: 0 1px 2px rgba(23, 33, 37, 0.05);
  --shadow-md: 0 12px 30px rgba(23, 33, 37, 0.1);
  --sidebar-width: 284px;
  --topbar-height: 76px;
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  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;
}

.noscript-message {
  position: fixed;
  z-index: 1200;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--ink);
  padding: 24px;
  text-align: center;
}

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.58;
}

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

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

input,
select {
  min-height: 42px;
  padding: 9px 11px;
}

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

input::placeholder,
textarea::placeholder {
  color: #97a1a6;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 118, 111, 0.13);
}

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

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

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

h2 {
  font-size: 1.2rem;
  line-height: 1.25;
}

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;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.boot-screen {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: var(--surface);
}

.loader {
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  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;
  align-items: flex-start;
  gap: 12px;
  width: min(620px, calc(100% - 28px));
  border: 1px solid #e6bd71;
  border-radius: 8px;
  background: #fff9eb;
  box-shadow: var(--shadow-md);
  color: #73500e;
  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: 11px;
}

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

.brand-lockup strong {
  font-size: 1rem;
  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(--sidebar-muted);
}

.brand-mark {
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 800;
}

.brand-mark-large {
  width: 52px;
  height: 52px;
  font-size: 1.4rem;
}

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

.auth-brand {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  background: var(--sidebar);
  color: #ffffff;
  padding: 48px 54px 38px;
}

.auth-brand-message {
  max-width: 520px;
  padding: 64px 0;
}

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

.auth-kicker {
  color: #8ed2cc;
}

.auth-brand-message h1 {
  max-width: 500px;
  margin-top: 16px;
  font-size: 3.15rem;
  line-height: 1.08;
}

.auth-brand-message p {
  max-width: 470px;
  margin-top: 20px;
  color: #c5d5d6;
  font-size: 1.05rem;
  line-height: 1.65;
}

.auth-brand-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--sidebar-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: 42px;
}

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

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

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

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

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

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

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

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

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

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

.input-shell input {
  min-height: 46px;
  padding-left: 39px;
}

.input-shell .input-icon-button + svg {
  display: none;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.icon-button-dark {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #d5e1e2;
}

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

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

.icon-button-accent:hover:not(:disabled) {
  border-color: #c95c41;
  background: #c95c41;
  color: #ffffff;
}

.text-button {
  min-height: 28px;
  color: var(--primary-dark);
  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;
  flex: none;
}

.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(--line);
  content: "";
}

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

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

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

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

.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(--sidebar);
  color: #ffffff;
}

.sidebar-brand {
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px;
}

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

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

.sidebar-search > svg {
  position: absolute;
  left: 11px;
  width: 16px;
  color: #88a4a6;
}

.sidebar-search input {
  min-height: 38px;
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  font-size: 0.84rem;
  padding-left: 36px;
}

.sidebar-search input::placeholder {
  color: #8fa9ab;
}

.sidebar-search input:focus {
  border-color: rgba(142, 210, 204, 0.65);
  box-shadow: 0 0 0 3px rgba(142, 210, 204, 0.1);
}

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

.subject-item {
  --subject-color: var(--primary);
  position: relative;
  display: grid;
  width: 100%;
  min-height: 62px;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #e7eeee;
  padding: 9px 10px;
  text-align: left;
}

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

.subject-item.active {
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.1);
}

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

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

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

.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.87rem;
}

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

.sidebar-empty {
  display: grid;
  justify-items: center;
  gap: 7px;
  color: var(--sidebar-muted);
  padding: 34px 16px;
  font-size: 0.8rem;
  text-align: center;
}

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

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

.user-avatar {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 50%;
  background: #d7e8e6;
  color: var(--sidebar-deep);
  font-size: 0.77rem;
  font-weight: 800;
}

.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.83rem;
}

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

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

.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: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  padding: 12px 28px;
}

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

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

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

.context-label {
  margin-bottom: 4px;
}

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

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

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

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

.welcome-state h2 {
  margin-top: 7px;
  color: var(--ink);
  font-size: 1.65rem;
}

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

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

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

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

.workspace-tabs {
  position: sticky;
  z-index: 30;
  top: var(--topbar-height);
  display: flex;
  min-height: 56px;
  align-items: end;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 245, 246, 0.97);
  overflow-x: auto;
  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: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  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(--ink);
}

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

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

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

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

.stat-card {
  display: flex;
  min-width: 0;
  min-height: 116px;
  align-items: flex-start;
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

.stat-icon {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 7px;
}

.stat-students .stat-icon {
  background: var(--blue-soft);
  color: var(--blue);
}

.stat-average .stat-icon {
  background: var(--primary-soft);
  color: var(--primary);
}

.stat-approved .stat-icon {
  background: var(--success-soft);
  color: var(--success);
}

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

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

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

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

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

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

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

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

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

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

.page-heading {
  min-height: 62px;
  margin-bottom: 18px;
}

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

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

.subtle-badge,
.status-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  white-space: nowrap;
}

.subtle-badge {
  background: var(--surface-strong);
  color: var(--ink-soft);
}

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

.stacked-progress {
  display: flex;
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--surface-strong);
}

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

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

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

.progress-pending {
  background: #a8b1b5;
}

.progress-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 0.76rem;
}

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

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

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

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

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

.pending-dot {
  background: #a8b1b5;
}

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

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

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

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

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

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

.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.82rem;
}

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

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

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

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

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

.attendance-ring {
  display: grid;
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  place-items: center;
  border: 8px solid var(--primary-soft);
  border-radius: 50%;
  color: var(--primary-dark);
  font-size: 1rem;
  font-weight: 800;
}

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

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

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

.recent-heading {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

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

.data-toolbar {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 11px 14px;
}

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

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

.search-control input {
  min-height: 40px;
  background: var(--surface-subtle);
  padding-left: 36px;
}

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

.select-control select {
  width: 142px;
  min-height: 40px;
  background: var(--surface-subtle);
}

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

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

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

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

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

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

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

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

.student-avatar {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
}

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

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

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

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

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

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

.mini-progress {
  width: 82px;
  height: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-strong);
}

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

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

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

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

.status-badge.pending {
  background: var(--surface-strong);
  color: var(--muted);
}

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

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

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

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

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

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

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

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

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

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

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

.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: 108px;
  min-width: 108px;
  text-align: center;
}

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

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

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

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

.gradebook-row.dirty td:first-child {
  box-shadow: inset 3px 0 0 var(--warning);
}

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

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

.attendance-stats {
  display: flex;
  min-height: 50px;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  padding: 10px 16px;
}

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

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

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

.attendance-list {
  display: grid;
}

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

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

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

.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.84rem;
}

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

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

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

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

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

.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(--blue-soft);
  color: var(--blue);
}

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

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

.history-panel > .section-heading {
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  padding: 12px 15px;
}

.history-list {
  display: grid;
}

.history-item {
  display: grid;
  min-height: 58px;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  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: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--primary-dark);
  font-size: 0.68rem;
  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.78rem;
}

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

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

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

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

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 31, 34, 0.62);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(600px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(16, 31, 34, 0.24);
}

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

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

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

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

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

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

.student-form-grid {
  grid-template-columns: minmax(160px, 0.8fr) minmax(240px, 1.4fr) minmax(160px, 0.8fr);
}

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

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

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

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

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

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

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

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

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

.color-blue span {
  background: var(--blue);
}

.color-coral span {
  background: var(--accent);
}

.color-violet span {
  background: var(--violet);
}

.color-green span {
  background: var(--green);
}

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

.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.78rem;
}

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

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

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

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

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

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

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

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

.toast-region {
  position: fixed;
  z-index: 300;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(380px, calc(100% - 36px));
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 28px;
  align-items: start;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--primary);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--ink);
  padding: 12px 10px 12px 12px;
  pointer-events: auto;
  animation: toast-in 180ms ease-out;
}

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

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

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

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

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

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

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

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

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

.toast-close:hover {
  background: var(--surface-strong);
  color: var(--ink);
}

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

.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: 16px;
  height: 16px;
  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;
}

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

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

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

  .history-panel {
    width: 100%;
  }

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

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

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

  .auth-brand {
    display: none;
  }

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

  .mobile-brand-mark {
    display: inline-grid;
    margin-bottom: 28px;
  }

  .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 - 48px));
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

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

  .sidebar-backdrop {
    position: fixed;
    z-index: 45;
    inset: 0;
    background: rgba(16, 31, 34, 0.5);
  }

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

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

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

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

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

  h1 {
    font-size: 1.25rem;
  }

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

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

  .topbar {
    gap: 10px;
    padding: 10px 14px;
  }

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

  .topbar-actions {
    gap: 5px;
  }

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

  .compact-action span {
    display: none;
  }

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

  .workspace-tabs {
    margin-right: -14px;
    margin-left: -14px;
    padding: 0 8px;
  }

  .tab-button {
    min-height: 46px;
    font-size: 0.8rem;
    padding: 0 10px;
  }

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

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

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

  .stat-card {
    min-height: 112px;
    gap: 9px;
    padding: 13px 11px;
  }

  .stat-icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

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

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

  .surface-section {
    padding: 16px;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 14px;
  }

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

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

  .save-status {
    min-height: 20px;
  }

  .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: 5px;
  }

  .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 tbody {
    display: grid;
  }

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

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

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

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

  .students-table td:first-child {
    min-height: 48px;
    justify-content: flex-start;
    padding-top: 0;
    padding-bottom: 10px;
  }

  .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 - 120px);
  }

  .actions-col {
    width: 100%;
  }

  .row-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: 4px;
  }

  .attendance-page-heading {
    align-items: stretch;
  }

  .date-navigation {
    width: 100%;
  }

  .date-navigation input {
    min-width: 0;
    flex: 1;
  }

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

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

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

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

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

  .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 - 18px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
  }

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

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

  .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;
  }

  .modal-dialog-small .modal-footer {
    padding-right: 16px;
    padding-left: 16px;
  }

  .toast-region {
    right: 12px;
    bottom: 12px;
    width: calc(100% - 24px);
  }
}

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

  .stat-card {
    min-height: 98px;
  }

  .progress-legend {
    display: grid;
  }

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

  .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;
  }
}
