:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e6eaf1;
  --primary: #2563eb;
  --primary-soft: #e8f0ff;
  --danger: #dc2626;
  --shadow: 0 8px 24px rgba(31, 41, 55, 0.06);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 32px) 28px;
}

/* 顶部 */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.brand-mark span {
  display: block;
  width: 4px;
  border-radius: 4px;
  background: #ffffff;
}

.brand-mark span:nth-child(1) { height: 12px; opacity: 0.75; }
.brand-mark span:nth-child(2) { height: 20px; }
.brand-mark span:nth-child(3) { height: 15px; opacity: 0.85; }

.brand-text h1 {
  margin: 0;
  font-size: clamp(19px, 2.4vw, 24px);
  line-height: 1.25;
  letter-spacing: 0.01em;
}

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

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.filter-chip:focus-visible,
.status-btn:focus-visible,
.link-btn:focus-visible,
.delete-record:focus-visible,
.pick-close:focus-visible,
.student-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: #374151;
}

.btn-ghost:hover {
  border-color: #cbd5e1;
  background: #f9fafb;
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  border-color: #fecaca;
  background: #fef2f2;
}

/* 概览卡片 */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card::after {
  content: "";
  position: absolute;
  top: -28px;
  right: -22px;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.05);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.stat-value {
  margin-top: 6px;
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 750;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.stat-meter {
  height: 6px;
  margin-top: 10px;
  border-radius: 999px;
  background: #eef1f6;
  overflow: hidden;
}

.stat-meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.35s ease;
}

/* 随机点名提示 */
.pick-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #1d4ed8, #4f46e5);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(29, 78, 216, 0.2);
}

.pick-label {
  font-size: 11px;
  opacity: 0.8;
}

.pick-name {
  margin-top: 2px;
  font-size: 24px;
  font-weight: 750;
  line-height: 1.2;
}

.pick-note {
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.82;
}

.pick-close {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
  font-size: 12px;
}

.pick-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* 主区域 */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}

.side-column {
  display: grid;
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: clamp(16px, 2vw, 22px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

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

.panel-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.panel-desc {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.filters,
.record-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #4b5563;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.filter-chip:hover {
  border-color: #bfdbfe;
  color: var(--primary);
}

.filter-chip.is-active {
  background: var(--primary-soft);
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.roll-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.roll-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: #eef1f6;
  overflow: hidden;
}

.roll-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.3s ease;
}

/* 学生卡片 */
.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.student-card {
  --card-bg: #f0fdf4;
  --card-border: #bbf7d0;
  --card-accent: #16a34a;
  position: relative;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: var(--card-bg);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.student-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(31, 41, 55, 0.09);
}

.student-card.is-picked {
  box-shadow: 0 0 0 3px #f59e0b, 0 10px 22px rgba(245, 158, 11, 0.22);
}

.color-0 { --card-bg: #f0fdf4; --card-border: #bbf7d0; --card-accent: #16a34a; }
.color-1 { --card-bg: #eff6ff; --card-border: #bfdbfe; --card-accent: #2563eb; }
.color-2 { --card-bg: #fffbeb; --card-border: #fde68a; --card-accent: #d97706; }
.color-3 { --card-bg: #f5f3ff; --card-border: #ddd6fe; --card-accent: #7c3aed; }

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--card-accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
}

.identity {
  min-width: 0;
}

.student-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.student-no {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
  color: #6b7280;
  font-size: 11px;
  white-space: nowrap;
}

.group-pill {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.9);
  color: #4b5563;
  font-size: 10px;
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 12px 0 8px;
}

.status-badge {
  padding: 3px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge[data-status="present"] { background: #dcfce7; color: #15803d; }
.status-badge[data-status="late"] { background: #fef3c7; color: #b45309; }
.status-badge[data-status="leave"] { background: #dbeafe; color: #1d4ed8; }
.status-badge[data-status="absent"] { background: #fee2e2; color: #b91c1c; }

.card-hint {
  color: #6b7280;
  font-size: 10px;
  white-space: nowrap;
}

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

.status-btn {
  min-width: 0;
  padding: 7px 0;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.72);
  color: #4b5563;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.status-btn:hover {
  background: #ffffff;
  transform: translateY(-1px);
}

.status-btn.is-active {
  border-color: transparent;
  color: #ffffff;
}

.status-btn[data-status="present"].is-active { background: #16a34a; }
.status-btn[data-status="late"].is-active { background: #d97706; }
.status-btn[data-status="leave"].is-active { background: #2563eb; }
.status-btn[data-status="absent"].is-active { background: #dc2626; }

.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  min-width: 0;
}

.link-btn {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card-note {
  min-width: 0;
  color: #6b7280;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty,
.empty-record {
  margin: 14px 0 0;
  padding: 22px 12px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

/* 记录表单 */
.count-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.record-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #eef1f6;
  border-radius: 14px;
  background: #fbfcfe;
}

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

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #dfe4ec;
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
  resize: vertical;
  min-height: 74px;
  line-height: 1.5;
}

.field select:focus,
.field textarea:focus {
  border-color: #93b4f7;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hint,
.updated {
  color: var(--muted);
  font-size: 11px;
}

.record-filter {
  margin: 14px 0 4px;
}

.record-list {
  display: grid;
  gap: 10px;
  max-height: 380px;
  margin: 12px 0 0;
  padding: 0 2px 0 0;
  list-style: none;
  overflow-y: auto;
}

.record-list::-webkit-scrollbar {
  width: 6px;
}

.record-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #dbe0e8;
}

.record-item {
  padding: 11px 12px;
  border: 1px solid #e9edf3;
  border-radius: 12px;
  background: #fbfcfe;
}

.record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.record-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.type-praise { background: #dcfce7; color: #15803d; }
.type-remind { background: #fef3c7; color: #b45309; }
.type-homework { background: #e0e7ff; color: #4338ca; }
.type-talk { background: #fce7f3; color: #be185d; }

.delete-record {
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 11px;
}

.delete-record:hover {
  color: var(--danger);
}

.record-student {
  margin-top: 7px;
  color: #4b5563;
  font-size: 11px;
  font-weight: 600;
}

.record-content {
  margin: 4px 0 0;
  color: #374151;
  font-size: 12px;
  line-height: 1.55;
  word-break: break-word;
}

/* 统计条 */
.section-title {
  margin: 0 0 10px;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
}

.stat-bars {
  display: grid;
  gap: 9px;
}

.stat-bars.compact {
  gap: 7px;
}

.bar-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 9px;
}

.bar-label {
  color: #4b5563;
  font-size: 11px;
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: #eef1f6;
  overflow: hidden;
}

.stat-bars.compact .bar-track {
  height: 6px;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 0.35s ease;
  background: #9ca3af;
}

.bar-fill.present { background: #22c55e; }
.bar-fill.late { background: #f59e0b; }
.bar-fill.leave { background: #3b82f6; }
.bar-fill.absent { background: #ef4444; }
.bar-fill.none { background: #9ca3af; }
.bar-fill.praise { background: #22c55e; }
.bar-fill.remind { background: #f59e0b; }
.bar-fill.homework { background: #6366f1; }
.bar-fill.talk { background: #ec4899; }

.bar-value {
  color: #4b5563;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

.footer {
  margin-top: 22px;
  color: #9ca3af;
  font-size: 11px;
  text-align: center;
}

/* 轻提示 */
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 22px;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: #111827;
  color: #ffffff;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 响应式 */
@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-column {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 16px 12px 22px;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .btn {
    flex: 1 1 auto;
    padding: 8px 10px;
  }

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

  .student-card {
    padding: 11px;
  }

  .avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    border-radius: 9px;
    font-size: 13px;
  }

  .card-hint {
    display: none;
  }

  .group-pill {
    display: none;
  }

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

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

  .pick-name {
    font-size: 21px;
  }
}

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