:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  --bg: #f7faf9;
  --sidebar-bg: #d2efcf;
  --workspace-bg: #dcebff;
  --surface: #ffffff;
  --surface-2: #edf5f2;
  --ink: #1f2933;
  --muted: #5f6f73;
  --line: #d8e4e0;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --red: #b42318;
  --yellow: #f2b705;
  --green: #2f855a;
  --cyan: #067c9b;
  --menu-blue: #4f8fdf;
  --menu-blue-dark: #2e73ca;
  --menu-blue-soft: #c9e0ff;
  --action-green: #6fc68a;
  --action-green-dark: #2f855a;
  --action-yellow: #f2d264;
  --action-yellow-dark: #8a6500;
  --action-red: #ea8a84;
  --action-red-dark: #b42318;
  --shadow: 0 14px 34px rgba(30, 45, 43, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--workspace-bg) !important;
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg) !important;
  border-right: 1px solid var(--line);
  padding: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.brand strong {
  display: block;
  font-size: 1.05rem;
}

.brand span,
.small {
  color: var(--muted);
  font-size: 0.86rem;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav button,
.class-pill,
.ghost,
.primary,
.danger,
.link-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 12px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--menu-blue) !important;
  border-color: var(--menu-blue-dark);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(61, 127, 202, 0.18);
}

.nav button:hover {
  background: var(--menu-blue-dark) !important;
}

.nav button.active,
.class-pill.active {
  background: var(--menu-blue-soft) !important;
  border-color: var(--menu-blue-dark);
  color: #184a80;
  font-weight: 700;
  box-shadow: none;
}

.workspace {
  min-width: 0;
  padding: 18px clamp(14px, 3vw, 34px) 34px;
  background: var(--workspace-bg) !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--sidebar-bg), var(--workspace-bg));
}

.login-panel {
  width: min(460px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 18px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.2;
}

.topbar-actions,
.button-row,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.class-select,
.field input,
.field select,
.field textarea,
.table-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

.class-select {
  min-width: 210px;
}

.primary {
  background: var(--action-green) !important;
  border-color: var(--action-green-dark);
  color: #fff;
  font-weight: 700;
  text-align: center;
}

.primary:hover {
  background: var(--action-green-dark) !important;
}

.ghost {
  background: var(--action-yellow) !important;
  border-color: #d5b44d;
  color: var(--action-yellow-dark);
  text-align: center;
  font-weight: 700;
}

.ghost:hover {
  background: #ebca67 !important;
}

.danger {
  background: var(--action-red) !important;
  border-color: var(--action-red-dark);
  color: #fff;
  text-align: center;
  font-weight: 700;
}

.danger:hover {
  background: var(--action-red-dark) !important;
}

.link-button {
  color: var(--teal-dark);
  padding: 0;
  min-height: auto;
  text-decoration: underline;
}

.notice {
  background: #e8f7f3;
  border: 1px solid #b8e4d9;
  color: #115e59;
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 11px 13px;
}

.notice:empty {
  display: none;
}

.grid {
  display: grid;
  gap: 14px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  gap: 16px;
}

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

.card,
.stat,
.lesson-card,
.student-card,
.course-card,
.modal-panel,
.table-wrap {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(20, 33, 32, 0.03);
}

.card,
.lesson-card,
.student-card,
.course-card {
  padding: 16px;
}

.stat {
  min-height: 96px;
  padding: 14px;
}

.stat strong {
  display: block;
  font-size: 1.8rem;
  line-height: 1.1;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title h2,
.section-title h3,
.card h2,
.card h3,
.lesson-card h3,
.student-card h3,
.course-card h3 {
  margin: 0;
  line-height: 1.25;
}

.course-list,
.student-list,
.lesson-list,
.todo-list {
  display: grid;
  gap: 12px;
}

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

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

.badge,
.status,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge {
  background: var(--surface-2);
  color: var(--teal-dark);
}

.tag {
  background: #eef2f7;
  color: #344054;
}

.status.held,
.status.present {
  background: #e7f5ed;
  color: var(--green);
}

.status.planned,
.status.late {
  background: #fff6d7;
  color: #7a5600;
}

.status.cancelled,
.status.absent,
.status.risk {
  background: #ffe9e6;
  color: var(--red);
}

.status.excused {
  background: #e8f4fb;
  color: var(--cyan);
}

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

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #fff;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

th {
  background: #f1f7f5;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table-input {
  max-width: 92px;
  min-height: 38px;
}

.attendance-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.attendance-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 150px 90px 110px 90px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefd;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 10px;
}

.day-column {
  min-height: 240px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.schedule-entry {
  border-left: 4px solid var(--teal);
  background: #f5fbf9;
  border-radius: 8px;
  padding: 8px 9px;
  margin-top: 8px;
}

.seating-grid {
  display: grid;
  gap: 8px;
  max-width: 920px;
}

.seat {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.seat label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 5px;
}

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

.field {
  display: grid;
  gap: 6px;
}

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

.field label {
  color: #344054;
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-panel {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
}

.class-color {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.print-only {
  display: none;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

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

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

@media (max-width: 640px) {
  .workspace {
    padding-inline: 12px;
  }

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

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

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

  .class-select {
    min-width: 0;
  }
}

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

  .sidebar,
  .topbar-actions,
  .button-row,
  .modal,
  .no-print {
    display: none !important;
  }

  .shell {
    display: block;
  }

  .workspace {
    padding: 0;
  }

  .card,
  .stat,
  .lesson-card,
  .student-card,
  .course-card,
  .table-wrap {
    box-shadow: none;
    break-inside: avoid;
  }

  .print-only {
    display: block;
  }
}
