:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #dce3ea;
  --surface: #ffffff;
  --canvas: #f4f7f9;
  --blue: #1769aa;
  --blue-soft: #eaf3fa;
  --red: #d84a46;
  --green: #238565;
  --amber: #b46b17;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef5f9 0%, #ffffff 52%, #f8eeee 100%);
}
.login-panel {
  width: min(100%, 430px);
  padding: 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 55px rgba(23, 32, 51, .1);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 24px;
  color: white;
  background: var(--blue);
  border-left: 8px solid var(--red);
  font-size: 22px;
  font-weight: 800;
}
.eyebrow, .section-kicker {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}
.login-panel h1, .topbar h1 { margin: 0; letter-spacing: 0; }
.login-panel h1 { font-size: 30px; }
.login-copy { margin: 10px 0 28px; color: var(--muted); }
form { display: grid; gap: 10px; }
label { color: #344054; font-size: 13px; font-weight: 700; }
input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  outline: none;
  color: var(--ink);
  background: #fff;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 105, 170, .12); }
.password-field { position: relative; }
.password-field input { padding-right: 58px; }
.icon-button {
  position: absolute;
  top: 5px;
  right: 5px;
  height: 34px;
  padding: 0 9px;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}
.primary-button, .secondary-button, .text-button {
  min-height: 40px;
  border-radius: 6px;
  font-weight: 750;
}
.primary-button { margin-top: 8px; border: 0; color: #fff; background: var(--blue); }
.primary-button:hover { background: #0f578f; }
.primary-button:disabled { cursor: wait; opacity: .65; }
.secondary-button { padding: 0 14px; border: 1px solid #b9c7d4; color: #23415d; background: white; }
.text-button { padding: 0 8px; border: 0; color: var(--blue); background: transparent; }
.form-error { margin: 2px 0 0; color: #b42318; font-size: 13px; }
.security-note { margin: 20px 0 0; color: #8491a2; font-size: 11px; line-height: 1.5; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px max(24px, calc((100vw - 1380px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 22px; }
.topbar .eyebrow { margin-bottom: 3px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.admin-name { margin-right: 8px; color: var(--muted); font-size: 13px; }
.dashboard-content { width: min(1380px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 42px; }
.loading-view { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 55vh; color: var(--muted); }
.spinner { width: 20px; height: 20px; border: 2px solid #cad6df; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-message { width: min(1380px, calc(100% - 48px)); margin: 20px auto 0; padding: 12px 14px; border: 1px solid #f0b6af; background: #fff2f0; color: #912018; }
.error-message { display: flex; align-items: center; justify-content: space-between; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric {
  min-height: 142px;
  padding: 20px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--blue);
  border-radius: 6px;
  background: var(--surface);
}
.metric-devices { border-top-color: var(--green); }
.metric-android { border-top-color: #4b7fc1; }
.metric-ios { border-top-color: #535967; }
.metric-label { display: block; min-height: 34px; color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { display: block; margin: 4px 0 8px; font-size: 34px; line-height: 1; }
.metric-meta { color: #7b8795; font-size: 12px; }

.data-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, .8fr); gap: 14px; margin-top: 14px; }
.panel, .classes-section { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.panel { min-height: 330px; padding: 22px; }
.panel-heading, .classes-heading { display: flex; justify-content: space-between; gap: 18px; }
.panel-heading h2, .classes-heading h2 { margin: 0; font-size: 18px; }
.panel-note { color: var(--muted); font-size: 12px; }
.activity-chart { display: grid; gap: 12px; margin-top: 26px; }
.activity-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) 34px; align-items: center; gap: 12px; }
.activity-label { color: #526071; font-size: 12px; font-weight: 700; }
.activity-track { width: 100%; height: 10px; overflow: hidden; border: 0; border-radius: 2px; background: #e9eef2; appearance: none; }
.activity-track::-webkit-progress-bar { background: #e9eef2; }
.activity-track::-webkit-progress-value { background: var(--blue); transition: width .35s ease; }
.activity-track::-moz-progress-bar { background: var(--blue); }
.activity-value { text-align: right; font-size: 13px; font-weight: 800; }
.recent-devices { display: grid; gap: 4px; margin-top: 15px; }
.device-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #edf1f4; }
.device-platform { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 4px; color: white; background: #45556a; font-size: 10px; font-weight: 850; text-transform: uppercase; }
.device-platform.android { background: var(--green); }
.device-info strong, .device-info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-info strong { font-size: 12px; }
.device-info span, .device-time { color: var(--muted); font-size: 11px; }

.classes-section { margin-top: 14px; padding: 22px; }
.classes-heading { align-items: flex-end; padding-bottom: 18px; }
.classes-heading p:not(.section-kicker) { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.classes-heading code { color: #42546a; background: #edf2f6; }
.class-tools { display: flex; align-items: center; gap: 10px; }
.search-field { width: min(310px, 34vw); }
.search-field input { min-height: 40px; }
.count-badge { white-space: nowrap; padding: 7px 10px; border-radius: 4px; color: #2e5d82; background: var(--blue-soft); font-size: 12px; font-weight: 800; }
.class-list { display: grid; gap: 8px; }
.class-card { border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.class-card summary { list-style: none; cursor: pointer; }
.class-card summary::-webkit-details-marker { display: none; }
.class-summary { display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(180px, .7fr) minmax(180px, .8fr) 120px 28px; align-items: center; gap: 18px; min-height: 76px; padding: 14px 16px; }
.class-summary:hover { background: #f8fafb; }
.class-name { min-width: 0; }
.class-name strong, .class-name span { display: block; }
.class-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.class-name span { margin-top: 5px; color: var(--blue); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 700; }
.class-info { color: #526071; font-size: 12px; line-height: 1.45; }
.class-info b { display: block; color: var(--ink); font-size: 12px; }
.student-total { font-size: 13px; font-weight: 800; text-align: right; }
.chevron { color: #667585; font-size: 18px; transition: transform .2s ease; }
.class-card[open] .chevron { transform: rotate(90deg); }
.student-area { padding: 0 16px 16px; background: #fafcfd; border-top: 1px solid var(--line); }
.student-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.student-table th { padding: 12px 10px 9px; color: #667085; text-align: left; font-size: 10px; letter-spacing: .04em; }
.student-table td { padding: 11px 10px; border-top: 1px solid #e6ebef; vertical-align: top; }
.student-table td:first-child { font-weight: 750; }
.student-table td:last-child { max-width: 360px; line-height: 1.45; }
.empty-students, .empty-state { padding: 24px; color: var(--muted); text-align: center; font-size: 13px; }
footer { display: flex; justify-content: space-between; gap: 12px; padding: 18px 2px 0; color: #8b96a4; font-size: 11px; }
.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: 1000px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .data-grid { grid-template-columns: 1fr; }
  .recent-panel { min-height: auto; }
  .class-summary { grid-template-columns: minmax(200px, 1fr) minmax(160px, .7fr) 110px 24px; }
  .class-summary .class-info:nth-of-type(3) { display: none; }
}

@media (max-width: 700px) {
  .login-panel { padding: 28px 22px; }
  .topbar { position: static; align-items: flex-start; padding: 14px 16px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .admin-name { display: none; }
  .dashboard-content, .page-message { width: calc(100% - 24px); }
  .dashboard-content { padding-top: 12px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metric { min-height: 126px; padding: 15px; }
  .metric-label { min-height: 38px; }
  .metric strong { font-size: 28px; }
  .panel, .classes-section { padding: 16px; }
  .activity-row { grid-template-columns: 92px minmax(0, 1fr) 28px; gap: 8px; }
  .classes-heading { align-items: stretch; flex-direction: column; }
  .class-tools { align-items: stretch; }
  .search-field { width: 100%; }
  .class-summary { grid-template-columns: minmax(0, 1fr) 75px 20px; gap: 8px; min-height: 70px; padding: 12px; }
  .class-summary .class-info { display: none; }
  .student-area { overflow-x: auto; padding: 0 10px 12px; }
  .student-table { min-width: 650px; }
  footer { flex-direction: column; }
}
