:root {
  font-family: "Leelawadee UI", "Noto Sans Thai", Tahoma, sans-serif;
  color: #514c60;
  background: #faf8fc;
  font-size: 14px;
  --purple: #8770ad;
  --border: #eae4ef;
  --muted: #8c8498;
  --green: #348b6a;
  --peach: #fff0e6;
  --lavender: #f1eafa;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
button,
a,
input,
select,
textarea {
  outline-offset: 4px;
}
button {
  border: 1px solid var(--border);
  background: white;
  color: inherit;
  border-radius: 12px;
  padding: 10px 16px;
  transition:
    background 0.16s,
    transform 0.16s;
}
button:hover:not(:disabled) {
  background: #f4eef9;
  transform: translateY(-1px);
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #b49bd7;
}
.primary {
  background: var(--purple);
  border-color: var(--purple);
  color: white;
  box-shadow: 0 4px 10px #8770ad20;
}
.primary:hover:not(:disabled) {
  background: #735b99;
}
.danger {
  color: #b95667;
}
.soft {
  background: var(--lavender);
  color: #745a99;
  border-color: transparent;
}
.small {
  padding: 7px 11px;
  font-size: 12px;
}
.icon-btn {
  padding: 8px 12px;
}
.muted,
small {
  color: var(--muted);
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 27px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
h2 {
  font-size: 19px;
  margin-bottom: 5px;
}
h3 {
  font-size: 16px;
}
p {
  line-height: 1.8;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  color: #a395b5;
  font-weight: 700;
}
label {
  display: block;
  font-size: 13px;
  color: #736880;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid #e4ddeb;
  border-radius: 10px;
  background: #fff;
  padding: 11px 12px;
  color: #514c60;
  margin-top: 6px;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #c3aee0;
  border-color: transparent;
}
textarea {
  resize: vertical;
  min-height: 85px;
}
input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--purple);
  margin: 0;
}
.field {
  margin-bottom: 17px;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.between {
  justify-content: space-between;
}
.wrap {
  flex-wrap: wrap;
}
.grow {
  flex: 1;
}
.stack {
  display: grid;
  gap: 16px;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.hidden {
  display: none !important;
}
.badge {
  font-size: 11px;
  border-radius: 20px;
  background: #f2edf8;
  color: #80669d;
  padding: 5px 11px;
  white-space: nowrap;
}
.layout {
  display: grid;
  grid-template-columns: 225px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  padding: 30px 18px 20px;
  background: #fff;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.brand {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 0 6px 30px;
}
.brand img {
  width: 43px;
  height: 47px;
  object-fit: contain;
}
.brand b {
  font-size: 20px;
  color: #6f5b8c;
}
.brand small {
  display: block;
  font-size: 10px;
  letter-spacing: 1px;
  margin-top: 2px;
}
.nav-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #b1a7bd;
  padding: 0 14px;
  margin: 15px 0 10px;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  margin: 4px 0;
  padding: 12px 14px;
  color: #8a8096;
}
.nav-btn.active {
  color: #785c9e;
  background: #f0e8f9;
  font-weight: 600;
}
.nav-icon {
  font-size: 19px;
  width: 24px;
  text-align: center;
}
.sidebar-pet {
  margin-top: auto;
  padding-top: 25px;
  text-align: center;
}
.sidebar-pet img {
  width: 112px;
  display: block;
  margin: 0 auto -5px;
}
.pet-note {
  border: 1px dashed #dfd3e9;
  border-radius: 15px;
  background: #fcfaff;
  padding: 12px 8px;
  font-size: 11px;
  color: #9c89b2;
}
.sidebar-bottom {
  border-top: 1px solid var(--border);
  margin-top: 20px;
  padding-top: 15px;
}
.main {
  min-width: 0;
}
.topbar {
  height: 80px;
  padding: 0 36px;
  background: #ffffffbd;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.crumb {
  font-size: 12px;
  color: #9d92aa;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: #f6e6dc;
  border-radius: 50%;
  font-size: 17px;
}
.content {
  padding: 28px 36px 38px;
  max-width: 1700px;
  margin: auto;
}
.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 15px;
}
.page-title p {
  font-size: 12px;
  margin: 0;
  color: #9c91a7;
}
.hero {
  position: relative;
  border: 1px solid #eadff3;
  border-radius: 21px;
  background: linear-gradient(110deg, #f1eafb, #f9f1ed);
  padding: 28px 30px;
  min-height: 170px;
  overflow: hidden;
  margin-bottom: 22px;
}
.hero h2 {
  font-size: 24px;
  color: #6f578c;
  margin: 12px 0 7px;
}
.hero p {
  font-size: 13px;
  color: #9b85a9;
  margin: 0;
}
.hero img {
  position: absolute;
  width: 165px;
  height: 170px;
  object-fit: contain;
  right: 43px;
  bottom: -9px;
  transform: rotate(4deg);
}
.hero .spark {
  position: absolute;
  right: 220px;
  top: 32px;
  color: #ccb67d;
  font-size: 25px;
}
.hero-tag {
  display: inline-block;
  font-size: 10px;
  border-radius: 12px;
  background: #ffffffb3;
  color: #9b82b4;
  padding: 5px 10px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-bottom: 24px;
}
.stat {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: white;
  padding: 19px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 13px;
  background: var(--lavender);
  font-size: 20px;
}
.stat:nth-child(2) .stat-icon {
  background: #e9f4ed;
}
.stat:nth-child(3) .stat-icon {
  background: #fff1e4;
}
.stat strong {
  font-size: 25px;
  font-weight: 600;
  margin-right: 5px;
}
.stat small {
  font-size: 11px;
}
.stat-label {
  font-size: 11px;
  color: #998da5;
  margin-bottom: 3px;
}
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 19px;
  padding: 23px;
  margin-bottom: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 23px;
}
.card-head p {
  font-size: 11px;
  color: #a395b2;
  margin: 4px 0 0;
}
.toolbar {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}
.date-btn {
  min-width: 135px;
  text-align: left;
  font-size: 12px;
  white-space: nowrap;
}
.week-range {
  font-size: 13px;
  font-weight: 600;
  color: #857196;
}
.table-wrap {
  overflow: auto;
  padding-bottom: 8px;
}
.timetable {
  border-collapse: separate;
  border-spacing: 7px;
  width: 100%;
  min-width: 1000px;
  table-layout: fixed;
}
.timetable th {
  font-weight: 500;
  font-size: 11px;
  color: #9b8fa7;
  padding: 4px 0 9px;
}
.timetable th:first-child {
  width: 90px;
}
.timetable td {
  padding: 0;
}
.day-label {
  border-radius: 11px;
  text-align: center;
  padding: 16px 5px;
  background: #fff4d9;
  color: #b48e42;
  font-size: 12px;
}
.day-label small {
  display: block;
  font-size: 10px;
  color: inherit;
  margin-top: 5px;
}
.day-1 {
  background: #fceaf2;
  color: #bc7c9a;
}
.day-2 {
  background: #e9f4ed;
  color: #6a9b7a;
}
.day-3 {
  background: #fff0e1;
  color: #bd9061;
}
.day-4 {
  background: #eaf0fd;
  color: #7b94c6;
}
.lesson {
  width: 100%;
  height: 91px;
  padding: 9px 5px;
  border-radius: 11px;
  background: #fcfaff;
  border: 1px dashed #e7dcef;
  text-align: center;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.lesson b {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.lesson small {
  font-size: 9px;
}
.lesson .plus {
  color: #baa4d0;
  font-size: 16px;
}
.lesson.filled {
  background: #f2ecfa;
  border: 1px solid #e9def4;
}
.lesson.done {
  background: #edf7f0;
  border: 1px solid #d9ebdf;
}
.lesson.done .lesson-status {
  color: #559b72;
}
.lesson-status {
  font-size: 9px;
  color: #b9a2c9;
}
.today .day-label {
  box-shadow: 0 0 0 2px #b59bd3;
}
.legend {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 11px;
  color: #9a8da6;
  margin-top: 15px;
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c7b8d8;
  margin-right: 5px;
}
.dot.present {
  background: #61af88;
}
.dot.absent {
  background: #d7818d;
}
.dot.leave {
  background: #83a6d3;
}
.dot.late {
  background: #dbb55b;
}
.dot.other {
  background: #aa92c5;
}
.footer {
  text-align: center;
  color: #b3a8bd;
  font-size: 10px;
  margin-top: 25px;
}
.empty {
  text-align: center;
  padding: 35px 15px;
  color: #9b8ca8;
}
.empty img {
  width: 110px;
}
.empty h3 {
  color: #7f6b91;
  margin-top: 15px;
}
.empty p {
  font-size: 12px;
}
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 17px;
}
.class-card {
  margin: 0;
  padding: 23px;
}
.class-card .class-icon {
  font-size: 25px;
  background: #f2eaf8;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  margin-bottom: 17px;
}
.class-card h2 {
  font-size: 23px;
}
.class-card p {
  font-size: 12px;
  color: #a193ad;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  color: #9b8aa9;
  font-weight: 500;
  font-size: 11px;
  background: #faf7fd;
  padding: 13px 12px;
  white-space: nowrap;
}
.data-table td {
  padding: 13px 12px;
  border-bottom: 1px solid #f0ebf4;
}
.data-table input {
  margin: 0;
  min-width: 95px;
}
.data-table th:first-child {
  border-radius: 10px 0 0 10px;
}
.data-table th:last-child {
  border-radius: 0 10px 10px 0;
}
.notice {
  font-size: 12px;
  background: #fcf6e9;
  color: #a08654;
  border-radius: 12px;
  padding: 12px 15px;
  line-height: 1.8;
  margin: 15px 0;
}
.notice.purple {
  background: #f4eef9;
  color: #8c74a3;
}
.status-buttons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.status-btn {
  font-size: 11px;
  padding: 7px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.status-btn.selected {
  background: #e6f3eb;
  border-color: #80bd9b;
  color: #3c835a;
}
.status-btn.selected.absent {
  background: #fbe9ed;
  border-color: #dc9aa8;
  color: #b05870;
}
.status-btn.selected.leave {
  background: #eaf1fb;
  border-color: #9cb8dd;
  color: #6284b4;
}
.status-btn.selected.late {
  background: #fff6dc;
  border-color: #dbbd72;
  color: #aa8936;
}
.status-btn.selected.other {
  background: #eee6f8;
  border-color: #ba9fd8;
  color: #8b6aa7;
}
.attendance-person {
  display: flex;
  align-items: center;
  gap: 9px;
}
.number {
  font-size: 11px;
  color: #b4a7bf;
  min-width: 18px;
}
.person-name {
  font-size: 13px;
}
.person-name small {
  display: block;
  font-size: 10px;
  margin-top: 3px;
}
.attendance-note {
  font-size: 12px;
  max-width: 280px;
}
.data-table input.attendance-note {
  display: block;
  margin-top: 12px;
}
.progress {
  height: 5px;
  border-radius: 5px;
  background: #f0eaf5;
  overflow: hidden;
  margin: 10px 0;
}
.progress span {
  display: block;
  height: 100%;
  background: #a792be;
  transition: width 0.2s;
}
.modal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 23px 26px;
  border-bottom: 1px solid var(--border);
  background: #fcf9ff;
  border-radius: 20px 20px 0 0;
}
.modal-top h2 {
  margin: 0;
}
.modal-top p {
  font-size: 12px;
  color: #9e8cad;
  margin: 5px 0 0;
}
.modal-body {
  padding: 24px 26px;
}
.modal-bottom {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 16px 26px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: #fff;
  border-radius: 0 0 20px 20px;
}
.modal-bottom small {
  margin-right: auto;
}
dialog {
  border: 1px solid #e6ddeb;
  border-radius: 21px;
  padding: 0;
  width: min(880px, 94vw);
  max-height: 90vh;
  color: #514c60;
  box-shadow: 0 30px 90px #53405c30;
}
dialog::backdrop {
  background: #45374c55;
  backdrop-filter: blur(3px);
}
dialog.narrow {
  width: min(470px, 94vw);
}
#calendar {
  width: 330px;
  z-index: 10;
  padding: 20px;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 15px;
}
.calendar-grid button {
  padding: 9px 0;
  border: 0;
  font-size: 12px;
  border-radius: 9px;
}
.calendar-grid small {
  text-align: center;
  font-size: 10px;
  padding: 5px 0;
}
.calendar-grid button.selected {
  background: var(--purple);
  color: white;
}
.calendar-grid button.today-date {
  box-shadow: inset 0 0 0 1px #b3a0ce;
}
.calendar-title select {
  padding: 5px;
  margin: 0;
  width: auto;
  font-size: 12px;
}
.calendar-title {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: space-between;
}
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #fffdfb;
}
.auth-art {
  background: radial-gradient(ellipse at 40% 45%, #fff7e9, #f2e9f9 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 50px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.auth-art .eyebrow {
  margin-bottom: 26px;
}
.auth-art img {
  width: min(340px, 80%);
  filter: drop-shadow(0 15px 16px #a88c7920);
}
.auth-art h1 {
  font-size: 32px;
  color: #7a658f;
  margin-top: 26px;
}
.auth-art p {
  font-size: 14px;
  color: #a18cac;
}
.auth-art:before,
.auth-art:after {
  content: "✧";
  position: absolute;
  font-size: 65px;
  color: #dcc8a0;
  top: 15%;
  left: 15%;
  transform: rotate(10deg);
}
.auth-art:after {
  top: auto;
  left: auto;
  bottom: 20%;
  right: 13%;
  font-size: 35px;
  color: #bfa6d8;
}
.auth-form {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 35px;
}
.auth-panel {
  width: 350px;
}
.auth-panel .brand {
  margin: 0 0 45px;
}
.auth-panel h2 {
  font-size: 25px;
}
.auth-panel > p {
  font-size: 13px;
  color: #a194ab;
  margin-bottom: 30px;
}
.auth-panel .primary {
  width: 100%;
  padding: 13px;
}
.auth-foot {
  text-align: center;
  font-size: 11px;
  color: #b3a6bd;
  margin-top: 25px;
}
.error {
  background: #fff0f2;
  color: #b75b72;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 12px;
  margin-bottom: 15px;
}
.loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: #9b82b4;
}
#toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%) translateY(90px);
  background: #5e4c72;
  color: white;
  border-radius: 13px;
  padding: 13px 24px;
  z-index: 100;
  transition: transform 0.25s;
  max-width: 90vw;
  font-size: 13px;
  box-shadow: 0 5px 20px #5e4c7230;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
}
.filters {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 23px;
}
.filters label {
  min-width: 140px;
}
.filters select,
.filters input {
  max-width: 230px;
}
.filter-date button {
  display: block;
  margin-top: 6px;
}
.permissions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.check-label {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}
.upload {
  border: 1px dashed #cbb9dd;
  border-radius: 14px;
  background: #faf7fd;
  padding: 22px;
  text-align: center;
  margin-bottom: 18px;
}
.upload p {
  font-size: 12px;
  margin: 6px 0;
  color: #a08cb1;
}
.upload input {
  max-width: 300px;
  font-size: 12px;
  background: #fff;
}
.schedule-edit {
  min-width: 950px;
}
.schedule-edit input {
  min-width: 100px;
  font-size: 12px;
  padding: 9px;
}
.schedule-edit input[type="time"] {
  min-width: 105px;
}
.form-actions {
  margin-top: 20px;
  justify-content: flex-end;
}
.section-note {
  font-size: 12px;
  color: #a193ac;
}
.record-count {
  font-size: 12px;
}
.mobile-brand {
  display: none;
}
.sort-select {
  width: auto;
  margin: 0;
  padding: 8px;
  font-size: 12px;
}
.saved-tag {
  font-size: 10px;
  color: #639777;
}
.inline-error {
  color: #b45d71;
  font-size: 12px;
  margin: 0 0 14px;
}
.modal-search {
  max-width: 250px;
  margin: 0;
}
.class-choice {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  margin: 10px 0;
}
.lock-note {
  font-size: 12px;
  color: #9b8ca8;
}
.auth-switch {
  display: block;
  margin: 15px auto 0;
  background: none;
  border: 0;
  color: #9983ad;
  font-size: 11px;
}
@media (min-width: 1500px) {
  .lesson {
    height: 105px;
    font-size: 12px;
  }
  .lesson small {
    font-size: 10px;
  }
}
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 185px minmax(0, 1fr);
  }
  .sidebar {
    padding: 25px 12px;
  }
  .brand b {
    font-size: 17px;
  }
  .content {
    padding: 24px;
  }
  .topbar {
    padding: 0 24px;
  }
  .hero img {
    right: 20px;
    width: 145px;
  }
  .hero .spark {
    right: 165px;
  }
  .stat {
    padding: 15px;
    gap: 10px;
  }
}
@media (max-width: 760px) {
  .layout {
    display: block;
  }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand,
  .sidebar .nav-label,
  .sidebar-pet,
  .sidebar-bottom {
    display: none;
  }
  .sidebar nav {
    display: flex;
    overflow: auto;
    gap: 4px;
  }
  .nav-btn {
    white-space: nowrap;
    margin: 0;
    padding: 10px 13px;
    width: auto;
    font-size: 12px;
  }
  .nav-icon {
    font-size: 16px;
    width: auto;
  }
  .topbar {
    height: 64px;
    padding: 0 18px;
  }
  .mobile-brand {
    display: block;
    color: #7b638f;
    font-weight: 600;
  }
  .crumb {
    display: none;
  }
  .content {
    padding: 20px 16px;
  }
  .hero {
    padding: 22px;
    min-height: 175px;
  }
  .hero h2 {
    font-size: 20px;
    max-width: 65%;
    line-height: 1.6;
  }
  .hero p {
    font-size: 11px;
    max-width: 60%;
  }
  .hero img {
    width: 125px;
    right: 4px;
    bottom: 0;
  }
  .hero .spark {
    display: none;
  }
  .stats {
    gap: 8px;
  }
  .stat {
    display: block;
    padding: 13px 10px;
  }
  .stat-icon {
    display: none;
  }
  .stat strong {
    font-size: 22px;
  }
  .stat-label {
    font-size: 10px;
  }
  .stat small {
    font-size: 9px;
  }
  .card {
    padding: 17px;
  }
  .card-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
  }
  .page-title {
    align-items: flex-start;
  }
  h1 {
    font-size: 23px;
  }
  .page-title .badge {
    display: none;
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
  .modal-body {
    padding: 18px;
  }
  .modal-top {
    padding: 18px;
  }
  .modal-bottom {
    padding: 14px 18px;
  }
  .data-table td {
    padding: 12px 8px;
  }
  .status-buttons {
    min-width: 265px;
  }
  .auth {
    grid-template-columns: 1fr;
  }
  .auth-art {
    padding: 30px 20px 10px;
    min-height: 250px;
  }
  .auth-art img {
    width: 140px;
  }
  .auth-art h1 {
    font-size: 23px;
    margin: 10px 0 5px;
  }
  .auth-art .eyebrow {
    margin-bottom: 8px;
  }
  .auth-art p {
    font-size: 11px;
    margin: 0 0 10px;
  }
  .auth-form {
    padding: 28px;
  }
  .auth-panel .brand {
    display: none;
  }
  .auth-panel h2 {
    font-size: 21px;
  }
  .auth-panel > p {
    margin-bottom: 20px;
  }
  .auth-foot {
    margin-bottom: 0;
  }
  .filters label {
    min-width: 125px;
  }
  .legend {
    gap: 10px;
    flex-wrap: wrap;
  }
  .week-range {
    font-size: 12px;
  }
  .user-chip .user-name {
    font-size: 12px;
  }
  .user-chip small {
    font-size: 9px;
  }
  .toolbar {
    gap: 6px;
  }
}
/* Device-specific timetable: no horizontal scrolling, including portrait tablets. */
.timetable {
  min-width: 0;
  border-spacing: 5px;
}
.timetable th:first-child {
  width: 8%;
}
.timetable th small {
  font-size: 9px;
  overflow-wrap: anywhere;
}
.lesson {
  min-width: 0;
}
.lesson b {
  white-space: normal;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.lesson-number,
.lesson-time {
  display: none;
}
@media (min-width: 761px) and (max-width: 1100px) {
  .layout {
    display: block;
  }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 10px 20px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand,
  .sidebar .nav-label,
  .sidebar-pet,
  .sidebar-bottom {
    display: none;
  }
  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }
  .nav-btn {
    margin: 0;
    font-size: 12px;
    padding: 8px 12px;
  }
  .mobile-brand {
    display: block;
    color: #7b638f;
    font-weight: 600;
  }
  .crumb {
    display: none;
  }
  .timetable {
    border-spacing: 3px;
  }
  .timetable th:first-child {
    width: 9%;
  }
  .lesson {
    font-size: 10px;
    padding: 7px 3px;
    height: 96px;
  }
  .lesson-status {
    font-size: 8px;
  }
  .day-label {
    font-size: 10px;
  }
  .day-label small {
    font-size: 8px;
  }
  .card-head {
    flex-wrap: wrap;
  }
}
@media (max-width: 760px) {
  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
    gap: 3px;
  }
  .nav-btn {
    min-width: 0;
    padding: 9px 5px;
    gap: 5px;
    font-size: 10px;
  }
  .nav-icon {
    font-size: 14px;
  }
  .timetable,
  .timetable tbody {
    display: block;
    width: 100%;
  }
  .timetable thead {
    display: none;
  }
  .timetable tbody tr {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 20px;
  }
  .timetable td {
    display: block;
    min-width: 0;
  }
  .timetable td:first-child {
    grid-column: 1 / -1;
  }
  .day-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 13px;
    font-size: 12px;
  }
  .day-label small {
    margin: 0;
    font-size: 11px;
  }
  .lesson {
    height: 98px;
    padding: 8px 2px;
    border-radius: 9px;
    gap: 5px;
    font-size: 9px;
  }
  .lesson-symbol {
    display: none;
  }
  .lesson-number {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #89709e;
  }
  .lesson-time {
    display: block;
    font-size: 7px !important;
    letter-spacing: -0.3px;
    white-space: nowrap;
  }
  .lesson-status {
    font-size: 7px;
  }
  .lesson b {
    line-height: 1.5;
  }
  .status-buttons {
    min-width: 0;
  }
  .data-table:not(.schedule-edit),
  .data-table:not(.schedule-edit) tbody {
    display: block;
  }
  .data-table:not(.schedule-edit) thead {
    display: none;
  }
  .data-table:not(.schedule-edit) tr {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }
  .data-table:not(.schedule-edit) td {
    border: 0;
    padding: 5px;
  }
  #att-rows td {
    width: 100%;
  }
  #roster-rows td {
    width: calc(50% - 4px);
  }
  #roster-rows td:first-child,
  #roster-rows td:last-child {
    width: 100%;
  }
  #roster-rows input {
    min-width: 0;
  }
  .modal-bottom {
    flex-wrap: wrap;
  }
  .modal-search {
    max-width: 100%;
  }
  .schedule-edit,
  .schedule-edit tbody {
    display: block;
    min-width: 0;
  }
  .schedule-edit thead {
    display: none;
  }
  .schedule-edit tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px;
  }
  .schedule-edit td {
    display: block;
    border: 0;
    padding: 0;
  }
  .schedule-edit td:first-child {
    grid-column: 1/-1;
    font-weight: 600;
  }
  .schedule-edit td:first-child::before {
    content: "คาบ ";
  }
  .schedule-edit td:nth-child(2)::before {
    content: "เริ่ม";
  }
  .schedule-edit td:nth-child(3)::before {
    content: "สิ้นสุด";
  }
  .schedule-edit td:nth-child(4)::before {
    content: "จันทร์";
  }
  .schedule-edit td:nth-child(5)::before {
    content: "อังคาร";
  }
  .schedule-edit td:nth-child(6)::before {
    content: "พุธ";
  }
  .schedule-edit td:nth-child(7)::before {
    content: "พฤหัสบดี";
  }
  .schedule-edit td:nth-child(8)::before {
    content: "ศุกร์";
  }
  .schedule-edit td::before {
    font-size: 11px;
    color: #9b8aa9;
  }
  .schedule-edit input,
  .schedule-edit input[type="time"] {
    min-width: 0;
    width: 100%;
  }
}
#toast {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
  visibility: visible;
}
@media (max-width: 760px) {
  .lesson {
    font-size: 10px;
  }
  .lesson-time {
    font-size: 8px !important;
  }
  .lesson-status {
    font-size: 8px;
  }
}
@media (max-width: 360px) {
  .lesson-time {
    font-size: 7px !important;
  }
  .lesson-status {
    font-size: 7px;
  }
}
.scope-panel {
  display: grid;
  gap: 16px;
}
.scope-panel > label {
  max-width: 420px;
}
.scope-panel .section-note {
  margin: 0;
}
.scope-panel .toolbar {
  align-items: end;
}
.scope-panel .toolbar label {
  min-width: 200px;
}
.term-line {
  display: grid;
  gap: 6px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.term-line small {
  font-size: 12px;
}
.term-editor {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.term-editor .date-btn,
#year-start,
#year-end {
  display: block;
  margin-top: 6px;
}
.report-totals {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.report-totals > span {
  background: #faf7fd;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
}
summary {
  cursor: pointer;
  color: #80669d;
  padding: 10px 0;
}
.mobile-summary-label {
  display: none;
}
@media (max-width: 760px) {
  .term-editor {
    grid-template-columns: 1fr 1fr;
  }
  .term-editor > label:first-child {
    grid-column: 1/-1;
  }
  .scope-panel .toolbar {
    align-items: stretch;
  }
  .scope-panel .toolbar label {
    min-width: 0;
    width: 100%;
  }
  .mobile-summary-label {
    display: inline;
  }
  #student-summary td:first-child {
    width: 100%;
  }
}
@media (max-width: 760px) {
  .term-editor {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .term-editor .date-btn {
    min-width: 0;
    width: 100%;
    font-size: 11px;
    padding: 10px 6px;
  }
  .scope-panel .toolbar button {
    max-width: 100%;
    white-space: normal;
  }
}
/* Rich per-day timetable details and optional attendance. */
.lesson {
  height: 120px;
  gap: 5px;
}
.lesson b {
  -webkit-line-clamp: 3;
}
.lesson-class {
  font-size: 11px;
  color: #79618f;
}
.lesson-room {
  font-size: 10px;
}
.lesson.no-attendance {
  background: #f5f4f7;
  border: 1px dashed #dedbe3;
  color: #8c8595;
}
.lesson.no-attendance .lesson-status {
  color: #9c93a6;
}
.lesson.no-attendance.done {
  background: #edf7f0;
}
.template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}
.template-actions p {
  width: 100%;
}
.schedule-edit {
  min-width: 0;
  table-layout: fixed;
}
.schedule-edit th:first-child {
  width: 54px;
}
.schedule-edit th:nth-child(2),
.schedule-edit th:nth-child(3) {
  width: 96px;
}
.schedule-edit th:last-child {
  width: 42px;
}
.schedule-edit td {
  padding: 10px 5px;
  vertical-align: top;
}
.schedule-edit input,
.schedule-edit input[type="time"] {
  min-width: 0;
  font-size: 11px;
  padding: 9px 5px;
}
.slot-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 6px 0;
}
.slot-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 5px 0;
}
.schedule-edit .slot-check input {
  width: 16px;
  min-width: 16px;
  height: 16px;
  padding: 0;
}
.period-label {
  text-align: center;
}
@media (max-width: 1050px) {
  .schedule-edit,
  .schedule-edit tbody {
    display: block;
    min-width: 0;
  }
  .schedule-edit thead {
    display: none;
  }
  .schedule-edit tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 15px;
  }
  .schedule-edit td {
    display: block;
    border: 0;
    padding: 0;
  }
  .schedule-edit td:first-child {
    grid-column: 1/-1;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .schedule-edit td:first-child input {
    width: 55px;
  }
  .schedule-edit td:first-child::before {
    content: "คาบ";
  }
  .schedule-edit td:nth-child(2)::before {
    content: "เริ่ม";
  }
  .schedule-edit td:nth-child(3)::before {
    content: "สิ้นสุด";
  }
  .schedule-edit td:nth-child(4)::before {
    content: "จันทร์";
  }
  .schedule-edit td:nth-child(5)::before {
    content: "อังคาร";
  }
  .schedule-edit td:nth-child(6)::before {
    content: "พุธ";
  }
  .schedule-edit td:nth-child(7)::before {
    content: "พฤหัสบดี";
  }
  .schedule-edit td:nth-child(8)::before {
    content: "ศุกร์";
  }
  .schedule-edit td::before {
    font-size: 12px;
    color: #8c74a3;
    display: block;
    margin-bottom: 5px;
  }
  .schedule-edit input {
    width: 100%;
  }
}
@media (max-width: 760px) {
  .lesson {
    height: 120px;
    font-size: 10px;
    gap: 4px;
  }
  .lesson-class {
    font-size: 9px;
  }
  .lesson-room {
    font-size: 8px;
  }
  .template-actions button {
    max-width: 100%;
  }
}
