:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --band: #ffffff;
  --text: #18231f;
  --muted: #64706b;
  --line: #dfe4dc;
  --accent: #087a72;
  --accent-strong: #065f59;
  --blue: #356f9e;
  --gold: #b48318;
  --ok: #2c7a48;
  --amber: #b36b15;
  --danger: #b94732;
  --soft: #eef4ef;
  --shadow: 0 16px 36px rgba(28, 40, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.topbar {
  min-height: 88px;
  padding: 22px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--band);
}

.topbar > div:first-child {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.25;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.user-badge {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8faf6;
  color: #40504a;
  font-size: 0.84rem;
  font-weight: 700;
}

.logout-link {
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: none;
}

.logout-link:hover {
  color: var(--accent);
}

.admin-only {
  display: none;
}

body.is-admin .admin-only {
  display: block;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

body.parent-mode {
  background: #f7f6f1;
}

body.parent-mode .topbar {
  min-height: 0;
  padding: 12px 28px 0;
  border: 0;
  background: transparent;
  justify-content: flex-end;
}

body.parent-mode .topbar > div:first-child,
body.parent-mode .user-badge,
body.parent-mode .logout-link,
body.parent-mode #syncNow {
  display: none;
}

body.parent-mode #parentMode {
  min-height: 32px;
  padding: 6px 10px;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.82rem;
}

body.parent-mode.clean-shot #parentMode {
  opacity: 0;
  pointer-events: none;
}

body.parent-mode .search-pane,
body.parent-mode .ops-band {
  display: none;
}

body.parent-mode .layout {
  display: block;
  max-width: 820px;
  padding: 28px;
}

body.parent-mode .detail-pane {
  position: static;
  min-height: auto;
}

body.parent-mode .report-card,
body.parent-mode .lesson-section {
  box-shadow: 0 18px 42px rgba(28, 40, 34, 0.1);
}

body.parent-mode .lesson-list {
  max-height: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 18px;
  padding: 18px;
  max-width: 1440px;
  margin: 0 auto;
}

.search-pane,
.detail-pane,
.ops-band {
  min-width: 0;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(128px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
}

.metric.danger-metric {
  border-color: #f1c7bd;
  background: #fff8f5;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 1.35rem;
}

.search-box {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
}

.search-box label,
.staff-filter label {
  color: var(--muted);
  font-size: 0.9rem;
}

.search-box input,
.staff-filter select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  outline: none;
}

.search-box input:focus,
.staff-filter select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 122, 114, 0.14);
}

.staff-filter {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
}

.staff-filter select:disabled {
  color: #425049;
  background: #f6f8f3;
  opacity: 1;
}

.staff-summary {
  display: grid;
  grid-template-columns: minmax(240px, 1.3fr) repeat(2, minmax(160px, 0.75fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-card {
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(28, 40, 34, 0.06);
}

.summary-card > span,
.summary-focus span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.7rem;
  line-height: 1;
}

.summary-focus {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f7fbf8 100%);
}

.summary-focus strong {
  color: var(--danger);
  font-size: 2.35rem;
}

.summary-focus em {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
}

.summary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.summary-pills span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef5f1;
  color: #40504a;
  font-size: 0.78rem;
  font-weight: 700;
}

.mini-track {
  height: 8px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1e8de;
}

.mini-track div {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.mini-track.homework div {
  background: var(--blue);
}

.staff-leaderboard {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.staff-chip {
  min-height: 54px;
  display: grid;
  align-content: center;
  gap: 3px;
  text-align: left;
  background: #fff;
}

.staff-chip strong {
  font-size: 0.92rem;
}

.staff-chip span {
  color: var(--muted);
  font-size: 0.78rem;
}

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

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

th,
td {
  height: 46px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 0.92rem;
}

th {
  background: #f0f3ed;
  color: #3b4741;
  font-weight: 600;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: var(--soft);
}

.empty-cell {
  color: var(--muted);
  text-align: center;
  cursor: default;
}

.detail-pane {
  position: sticky;
  top: 18px;
  align-self: start;
  min-height: 560px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

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

.detail-empty.compact {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.detail-pane h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.detail-meta {
  display: grid;
  gap: 7px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.report-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.report-card.danger {
  border-color: #edc3b8;
}

.report-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfdf9 0%, #ffffff 100%);
}

.report-head h2 {
  margin: 4px 0 6px;
  font-size: 1.45rem;
  line-height: 1.2;
}

.report-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.eyebrow {
  display: inline-block;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 700;
}

.risk-bubble {
  flex: 0 0 auto;
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #edf5f4;
  color: var(--ok);
  font-size: 0.82rem;
  font-weight: 800;
}

.risk-bubble.danger {
  background: #fff0ec;
  color: var(--danger);
}

.risk-bubble.warn {
  background: #fff4df;
  color: var(--amber);
}

.report-score {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcf8;
}

.report-score div {
  min-height: 84px;
  display: grid;
  align-content: center;
  justify-items: center;
  border: 1px solid #dfe8dc;
  border-radius: 8px;
  background: #ffffff;
}

.report-score span {
  color: var(--muted);
  font-size: 0.78rem;
}

.report-score strong {
  margin-top: 5px;
  color: var(--accent);
  font-size: 2.1rem;
  line-height: 1;
}

.report-score p {
  margin: 0;
  align-self: center;
  color: #33433c;
  font-size: 0.98rem;
  line-height: 1.7;
}

.progress-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
}

.progress-tile {
  min-height: 138px;
  padding: 18px;
  background: #ffffff;
}

.progress-tile + .progress-tile {
  border-left: 1px solid var(--line);
}

.tile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
}

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

.tile-top em {
  flex: 0 0 auto;
  font-style: normal;
  color: var(--muted);
  font-size: 0.76rem;
}

.tile-top em.ok {
  color: var(--ok);
}

.progress-number {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.progress-tile strong {
  display: block;
  margin-top: 12px;
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
}

.progress-number > span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.progress-tile small {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

.progress-track {
  width: 100%;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 99px;
  background: #e2e8de;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
}

.progress-tile.homework .progress-fill {
  background: var(--blue);
}

.parent-note {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #f4faf7;
}

.parent-note.danger {
  background: #fff6f2;
}

.parent-note strong {
  color: var(--text);
  font-size: 0.9rem;
}

.parent-note span {
  color: #3f4d47;
  font-size: 0.92rem;
  line-height: 1.6;
}

.report-foot {
  padding: 11px 18px;
  color: var(--muted);
  font-size: 0.78rem;
}

.lesson-section {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 0;
}

.section-title h2 {
  margin: 0;
}

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

.lesson-list {
  max-height: 320px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding: 14px;
}

.lesson {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.lesson.done {
  border-color: #d6e5d8;
  background: #f8fcf7;
}

.lesson strong {
  font-size: 0.9rem;
}

.lesson span {
  color: var(--muted);
  font-size: 0.78rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  width: max-content;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf5f4;
  color: var(--ok);
  font-size: 0.78rem;
  font-weight: 700;
}

.pill.warn {
  background: #fff3df;
  color: var(--amber);
}

.pill.danger {
  background: #fff0ec;
  color: var(--danger);
}

.ops-band {
  border-top: 1px solid var(--line);
  background: var(--band);
}

.ops-grid {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.import-panel,
.log-panel {
  min-height: 188px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.import-panel h2,
.log-panel h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.import-panel p {
  min-height: 46px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.import-panel input {
  display: block;
  width: 100%;
  margin-bottom: 12px;
}

.sync-log {
  display: grid;
  gap: 8px;
  max-height: 160px;
  overflow: auto;
  color: var(--muted);
  font-size: 0.84rem;
}

.log-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #18231f;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .detail-pane {
    position: static;
    min-height: auto;
  }

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

  .control-row,
  .staff-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

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

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