:root {
  color-scheme: light;
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #17213f;
  --muted: #7b87a4;
  --line: #dfe5ef;
  --navy: #151d44;
  --violet: #532cff;
  --violet-soft: #f0edff;
  --teal: #009b70;
  --teal-soft: #e9fbf5;
  --sky: #0798ba;
  --sky-soft: #e7f8fc;
  --orange: #ff4b10;
  --orange-soft: #fff0ea;
  --slate: #536173;
  --slate-soft: #eef2f6;
  --rose: #a012f0;
  --rose-soft: #f7e9ff;
  --red: #c2413a;
  --red-soft: #ffebe8;
  --amber: #b7791f;
  --amber-soft: #fff5db;
  --green: #18864b;
  --green-soft: #e8f6ee;
  --shadow: 0 22px 55px rgba(36, 44, 66, 0.08);
  --radius: 8px;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--navy);
  font-size: clamp(1.35rem, 2.2vw, 1.85rem);
  line-height: 1.18;
  font-weight: 900;
}

h2 {
  color: var(--navy);
  font-size: 1.05rem;
  line-height: 1.2;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 28px 10px 24px 28px;
  background: var(--surface);
  box-shadow: 18px 0 42px rgba(38, 47, 70, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 900;
}

.brand strong {
  display: block;
  color: var(--navy);
  font-size: 1.05rem;
  font-weight: 900;
}

.brand span {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  margin-top: 3px;
  padding: 0 8px;
  border: 1px solid var(--violet);
  border-radius: 6px;
  color: var(--violet);
  font-size: 0.75rem;
  font-weight: 800;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.tab-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px 0 0 8px;
  background: transparent;
  color: #7180a4;
  font-weight: 800;
  text-align: left;
}

.tab-button span {
  display: inline-grid;
  width: 22px;
  place-items: center;
  color: #5567ff;
  font-size: 1.15rem;
}

.tab-button.is-active {
  color: var(--navy);
  background: #f8f9ff;
}

.tab-button.is-active::after {
  position: absolute;
  top: 8px;
  right: 0;
  bottom: 8px;
  width: 4px;
  border-radius: 999px;
  background: var(--violet);
  content: "";
}

.side-note {
  display: grid;
  gap: 4px;
  margin: auto 12px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafbff;
}

.side-note strong {
  color: var(--navy);
}

.side-note span {
  color: var(--muted);
  font-size: 0.82rem;
}

.main-area {
  min-width: 0;
  padding: 34px 7vw 48px 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  margin-bottom: 40px;
}

.clock {
  min-width: 174px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  text-align: center;
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #7d88aa;
  font-weight: 800;
}

.avatar {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 4px solid #d6f3f5;
  border-radius: 50%;
  background: #fff4e7;
  color: #904d1b;
  font-size: 0.86rem;
  font-weight: 900;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--violet);
  font-size: 0.85rem;
  font-weight: 900;
}

.rooms-head,
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

#classroomCountText {
  color: var(--navy);
  font-size: 0.8em;
}

.room-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-actions input {
  width: 190px;
}

.room-form {
  display: flex;
  gap: 10px;
}

.room-form input {
  width: 180px;
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(230px, 1fr));
  gap: 18px;
}

.room-card {
  position: relative;
  min-height: 182px;
  padding: 22px 20px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.room-card::after {
  position: absolute;
  right: 20px;
  top: 38px;
  width: 108px;
  height: 108px;
  border-radius: 20px;
  background: currentColor;
  opacity: 0.08;
  transform: rotate(12deg);
  content: "";
}

.room-card h2 {
  position: relative;
  z-index: 1;
  min-height: 54px;
  padding-right: 48px;
  color: #17213f;
  font-size: 1.15rem;
  font-weight: 900;
}

.room-card .level {
  position: relative;
  z-index: 1;
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  margin: 6px 0 13px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff;
  color: currentColor;
  font-size: 0.74rem;
  font-weight: 900;
  box-shadow: 0 7px 18px rgba(36, 44, 66, 0.08);
}

.room-meta {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
  color: currentColor;
  font-size: 0.82rem;
  font-weight: 900;
}

.room-menu {
  position: absolute;
  z-index: 2;
  top: 18px;
  right: 18px;
  display: grid;
  width: 38px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  color: #6f7890;
  font-size: 1.2rem;
  font-weight: 900;
}

.open-room {
  position: relative;
  z-index: 1;
  display: inline-flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff;
  font-weight: 900;
  font-size: 0.95rem;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.25);
  transition: all 0.2s ease;
}

.open-room:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.35);
}

.open-room:active {
  transform: translateY(1px);
}

.room-card.teal {
  color: var(--teal);
  background: linear-gradient(90deg, var(--teal-soft), #fff);
}

.room-card.violet {
  color: var(--violet);
  background: linear-gradient(90deg, var(--violet-soft), #fff);
}

.room-card.slate {
  color: var(--slate);
  background: linear-gradient(90deg, var(--slate-soft), #fff);
}

.room-card.sky {
  color: var(--sky);
  background: linear-gradient(90deg, var(--sky-soft), #fff);
}

.room-card.rose {
  color: var(--rose);
  background: linear-gradient(90deg, var(--rose-soft), #fff);
}

.room-card.orange {
  color: var(--orange);
  background: linear-gradient(90deg, var(--orange-soft), #fff);
}

.panel {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.metric strong {
  color: var(--navy);
  font-size: 2rem;
  line-height: 1;
}

.metric-present {
  border-color: #b7e2ca;
  background: var(--green-soft);
}

.metric-absent {
  border-color: #f0bbb6;
  background: var(--red-soft);
}

.metric-leave {
  border-color: #f1d287;
  background: var(--amber-soft);
}

.setup-panel,
.settings-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr;
  gap: 12px;
  align-items: end;
}

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

.section-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.field.compact {
  min-width: 92px;
}

label {
  color: #344054;
  font-size: 0.86rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(83, 44, 255, 0.12);
}

.inline-form,
.toolbar,
.action-row {
  display: flex;
  gap: 8px;
}

.inline-form {
  align-items: end;
}

.inline-form input {
  width: min(230px, 42vw);
}

.student-form {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.student-form .field.compact {
  min-width: 0;
}

.import-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.import-box input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--violet);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.import-box span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 900;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.button {
  padding: 0 14px;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  place-items: center;
  padding: 0;
  font-size: 1.25rem;
}

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

.primary,
.create-room {
  background: var(--violet);
  color: #fff;
}

.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.danger {
  border-color: #f0bbb6;
  background: #fff;
  color: var(--red);
}

.save {
  min-width: 148px;
  background: var(--violet);
  color: #fff;
}

.back-button {
  white-space: nowrap;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.subject-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.subject-chip.is-selected {
  border-color: #b9acff;
  background: var(--violet-soft);
  color: var(--violet);
}

.subject-chip button {
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 900;
}

.subject-chip .remove-subject {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
}

.subject-chip .remove-subject:hover {
  background: rgba(0, 0, 0, 0.06);
}

.work-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.student-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 520px;
  overflow: auto;
}

.student-card {
  display: grid;
  grid-template-columns: 54px 1fr 38px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.student-number {
  display: inline-grid;
  width: 42px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--violet-soft);
  color: var(--violet);
  font-weight: 900;
}

.student-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-student {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #f0bbb6;
  border-radius: 8px;
  background: #fff;
  color: var(--red);
  font-weight: 900;
}

.attendance-table-wrap,
.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  background: #f1f5f9;
  color: #334155;
  font-size: 0.84rem;
}

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

.attendance-table th:nth-child(1),
.attendance-table td:nth-child(1) {
  width: 76px;
  text-align: center;
}

.attendance-table th:nth-child(3),
.attendance-table td:nth-child(3) {
  width: 260px;
}

.attendance-table th:nth-child(4),
.attendance-table td:nth-child(4) {
  width: 180px;
}

.status-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(66px, 1fr));
  gap: 6px;
}

.status-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #475467;
  font-weight: 900;
}

.status-button[data-status="present"].is-active {
  border-color: #8ad0a9;
  background: var(--green-soft);
  color: var(--green);
}

.status-button[data-status="absent"].is-active {
  border-color: #efaaa4;
  background: var(--red-soft);
  color: var(--red);
}

.status-button[data-status="leave"].is-active {
  border-color: #e6bf61;
  background: var(--amber-soft);
  color: var(--amber);
}

.note-input {
  min-width: 140px;
}

.action-row {
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

.save-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 900;
}

.badge.present {
  background: var(--green-soft);
  color: var(--green);
}

.badge.absent {
  background: var(--red-soft);
  color: var(--red);
}

.badge.leave {
  background: var(--amber-soft);
  color: var(--amber);
}

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

.empty-state {
  display: grid;
  min-height: 120px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

td.empty-state {
  display: table-cell;
  height: 120px;
}

.settings-panel {
  max-width: 920px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: end;
}

.script-note {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--muted);
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef2f7;
  color: #26364d;
}

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

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

  .main-area {
    padding-right: 28px;
  }
}

@media (max-width: 920px) {
  .app-frame {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    padding: 14px;
  }

  .brand {
    min-height: auto;
    margin-bottom: 14px;
  }

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

  .tab-button {
    justify-content: center;
    padding: 0 8px;
    border-radius: 8px;
  }

  .tab-button span {
    display: none;
  }

  .tab-button.is-active::after {
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 0;
    width: auto;
    height: 3px;
  }

  .side-note {
    display: none;
  }

  .main-area {
    padding: 20px 16px 36px;
  }

  .topbar {
    margin-bottom: 20px;
  }

  .rooms-head,
  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .room-actions input,
  .room-form input {
    width: 100%;
  }

  .room-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

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

  .setup-panel,
  .work-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .student-list {
    max-height: 320px;
  }
}

@media (max-width: 640px) {
  .topbar,
  .section-head,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    justify-content: stretch;
  }

  .clock {
    text-align: left;
  }

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

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

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

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

  .toolbar,
  .inline-form {
    flex-wrap: wrap;
  }

  .student-form {
    grid-template-columns: 78px minmax(0, 1fr) auto;
  }

  .import-box {
    grid-template-columns: 1fr;
  }

  .inline-form input {
    width: calc(100vw - 104px);
  }

  .button.save,
  .create-room {
    width: 100%;
  }
}
