:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #667085;
  --line: #dfe5ec;
  --blue: #2563eb;
  --blue-dark: #1e40af;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 18px 48px rgba(22, 34, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: #142033;
  color: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f6c04d;
  color: #111827;
  font-weight: 800;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.2;
  margin: 0;
}

.brand p,
.week-card p,
.role-card p {
  margin: 5px 0 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

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

.nav-tab {
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.76);
  cursor: pointer;
}

.nav-tab.active {
  background: #fff;
  color: #142033;
  font-weight: 700;
}

.week-card,
.role-card {
  margin-top: auto;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.role-card {
  margin-top: 0;
}

.week-card span,
.role-card span {
  display: block;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  margin-bottom: 6px;
}

.main {
  padding: 26px;
  min-width: 0;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  margin: 0;
  font-size: 28px;
}

.top-actions,
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.primary-button {
  color: #fff;
  background: var(--blue);
}

.primary-button:hover {
  background: var(--blue-dark);
}

.secondary-button {
  background: #eef4ff;
  color: var(--blue-dark);
  border-color: #c7d7fe;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.teacher-layout,
.parent-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
}

.panel,
.report-card,
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

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

.panel h3,
.report-card h3,
.report-section h4 {
  margin: 0;
}

.panel p,
.report-card p {
  margin: 5px 0 0;
  color: var(--muted);
}

.pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef4ff;
  color: var(--blue-dark);
}

.status-badge.submitted {
  background: #e7f8ef;
  color: var(--green);
}

.student-list {
  display: grid;
  gap: 8px;
}

.class-tools {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.mini-editor {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff, #fff);
}

.mini-editor strong {
  display: block;
  font-size: 14px;
}

.mini-editor span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.inline-form,
.student-add-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}

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

.student-add-grid button {
  grid-column: 1 / -1;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.student-list-blank,
.student-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  cursor: pointer;
}

.student-item.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.student-item strong {
  display: block;
}

.student-item span {
  color: var(--muted);
  font-size: 13px;
}

.compact .student-item {
  grid-template-columns: 1fr;
}

.history-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

.history-table-wrap .admin-table {
  margin: 0;
}

.trend-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(42px, 1fr));
  gap: 10px;
  align-items: end;
  min-height: 110px;
  margin: 12px 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.trend-bar {
  display: grid;
  align-content: end;
  gap: 6px;
  min-height: 86px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}

.trend-bar span {
  display: block;
  width: 100%;
  min-height: 8px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #2563eb, #60a5fa);
}

.exam-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  margin-bottom: 14px;
}

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

.exam-card {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.exam-card strong {
  display: block;
  margin: 8px 0 3px;
  font-size: 24px;
}

.exam-card span {
  color: var(--muted);
  font-size: 13px;
}

.admin-segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.segment {
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segment.active {
  background: #fff;
  color: var(--blue-dark);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
  font-weight: 700;
}

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

.admin-group-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-group-card strong {
  display: block;
  margin-bottom: 8px;
}

.group-meter {
  height: 8px;
  margin: 10px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.group-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

#student-list-empty {
  margin-bottom: 6px;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

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

textarea {
  resize: vertical;
}

.report-card {
  padding: 24px;
}

.report-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.pet-card {
  min-width: 150px;
  text-align: center;
  padding: 14px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.pet {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: #f97316;
  color: #fff;
  font-weight: 900;
}

.report-metrics,
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.report-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.report-metrics span,
.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.report-metrics strong,
.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.report-section {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.parent-reply {
  display: grid;
  gap: 12px;
}

.stat-card {
  padding: 18px;
}

.stat-card.warn strong {
  color: var(--amber);
}

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

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

.admin-table th {
  font-size: 13px;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.tag.ok {
  background: #e7f8ef;
  color: var(--green);
}

.tag.warn {
  background: #fff7ed;
  color: var(--amber);
}

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

  .sidebar {
    min-height: auto;
  }

  .week-card {
    margin-top: 0;
  }

  .report-metrics,
  .dashboard-grid,
  .exam-grid,
  .admin-group-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 620px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .report-header {
    display: grid;
  }

  .form-grid,
  .report-metrics,
  .dashboard-grid,
  .exam-grid,
  .admin-group-grid,
  .exam-form {
    grid-template-columns: 1fr;
  }

  .admin-table {
    display: block;
    overflow-x: auto;
  }

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