/* ============================================
   心育系统 v2 — 暖玉·Editorial 设计系统
   松石绿 #1A7A7A | 暖白基底 #FDFBF7
   ============================================ */

:root {
  --surface: #FDFBF7;
  --surface-soft: #F6F3EE;
  --surface-hover: #EFEBE4;
  --bg: #F3EFE9;
  --primary: #1A7A7A;
  --primary-light: #2A9D8F;
  --primary-soft: #E8F3F0;
  --primary-gradient: linear-gradient(135deg, #1A7A7A 0%, #2A9D8F 100%);
  --text: #2D2A26;
  --text-secondary: #6B6560;
  --text-muted: #A69E96;
  --border: #E5DED6;
  --border-light: #EDE8E2;
  --border-hover: #D5CCC2;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 4px rgba(42,37,32,0.06);
  --shadow-lg: 0 8px 30px rgba(42,37,32,0.08);
  --danger: #C0423E;
  --danger-soft: #F9EEED;
  --warning: #B8861E;
  --warning-soft: #F8F3E6;
  --success: #3A8A6A;
  --success-soft: #EDF5F0;
  --info: #3A7A9A;
  --info-soft: #E8F1F5;
  --sidebar-width: 260px;
  --header-height: 56px;
  --bottom-nav-height: 56px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-light); }

/* ===== Sidebar ===== */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  min-height: 76px;
}
.sidebar-brand-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--primary-gradient);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(26,122,122,0.2);
}
.sidebar-brand-text { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.3; letter-spacing: 0.3px; }
.sidebar-brand-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav::-webkit-scrollbar { width: 0; }
.sidebar-group-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  color: var(--text-muted); padding: 20px 20px 6px;
  letter-spacing: 1px; opacity: 0.7;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--surface-hover); color: var(--primary); }
.sidebar-link.active {
  background: var(--primary-soft); color: var(--primary);
  border-left-color: var(--primary); font-weight: 600;
}
.sidebar-link .icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.sidebar-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-soft);
}
.sidebar-footer-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.sidebar-footer-info { flex: 1; min-width: 0; }
.sidebar-footer-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer-role { font-size: 11px; color: var(--text-muted); }

/* ===== Main ===== */
.main-wrapper { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-height); padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-back {
  display: flex; align-items: center; gap: 4px;
  color: var(--text-muted); font-size: 13px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  transition: all var(--transition); cursor: pointer;
  white-space: nowrap;
}
.topbar-back:hover { background: var(--surface-hover); color: var(--primary); }
.topbar-title {
  font-size: 16px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 4px; }
.topbar-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: none; background: transparent;
  color: var(--text-muted); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.topbar-btn:hover { background: var(--surface-hover); color: var(--text); }

/* ===== Main content ===== */
.main-content {
  flex: 1; padding: 28px 32px;
  max-width: 1120px; width: 100%;
  margin: 0 auto;
}

/* ===== Cards ===== */
.card-app {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.card-app:hover { box-shadow: var(--shadow-lg); }
.card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px;
  font-size: 14px; font-weight: 600; color: var(--text);
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-soft);
}
.card-body { padding: 20px; }

/* ===== Stats grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px; text-align: center;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}
.stat-card:hover { border-color: var(--primary-soft); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.stat-card .num { font-size: 30px; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat-card .label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ===== Buttons ===== */
.btn-app {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none;
  transition: all var(--transition);
  font-family: inherit; line-height: 1.4;
}
.btn-primary-app { background: var(--primary); color: #fff; box-shadow: 0 1px 3px rgba(26,122,122,0.2); }
.btn-primary-app:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: 0 3px 8px rgba(26,122,122,0.25); }
.btn-outline-app { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline-app:hover { background: var(--primary-soft); }
.btn-ghost-app { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost-app:hover { background: var(--surface-hover); color: var(--text); }
.btn-sm-app { padding: 4px 10px; font-size: 12px; }
.btn-danger-app { background: var(--danger); color: #fff; }
.btn-danger-app:hover { background: #C0423E; opacity: 0.9; }
.btn-warning-app { background: var(--warning); color: #fff; }
.btn-warning-app:hover { opacity: 0.9; }

/* ===== Form controls ===== */
.form-control-app {
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: 13px;
  background: var(--surface); color: var(--text); font-family: inherit;
  transition: border-color var(--transition); width: 100%;
}
.form-control-app:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
select.form-control-app { cursor: pointer; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-sm); }
.table-wrapper table th:first-child,
.table-wrapper table td:first-child { padding-left: 16px; }
.table-wrapper table th,
.table-wrapper table td { white-space: nowrap; padding: 10px 12px; font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
table th {
  text-align: left; font-weight: 600; font-size: 11px;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}
table td { border-bottom: 1px solid var(--border-light); padding: 10px 12px; }
table tr:hover { background: var(--surface-hover); }
table tr:last-child td { border-bottom: none; }

/* Sticky action column */
.table-wrapper table th:last-child,
.table-wrapper table td:last-child {
  position: sticky; right: 0; z-index: 1;
}
.table-wrapper table th:last-child { z-index: 2; }
.table-wrapper table td:last-child {
  background: var(--surface);
  box-shadow: -4px 0 12px rgba(42,37,32,0.06);
}
.table-wrapper table tr:hover td:last-child { background: var(--surface-soft); }

/* ===== Risk badges ===== */
.risk-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.risk-高风险 { background: var(--danger-soft); color: var(--danger); }
.risk-中风险 { background: var(--warning-soft); color: var(--warning); }
.risk-低风险 { background: var(--success-soft); color: var(--success); }

/* ===== Filter bar ===== */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filter-bar select, .filter-bar input {
  padding: 5px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: 12px;
  background: var(--surface); color: var(--text); font-family: inherit;
}
.filter-label {
  font-size: 12px; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 2px;
  font-weight: 400; white-space: nowrap;
}
.filter-label input[type="date"] { width: 120px; padding: 5px 8px; font-size: 12px; }
.filter-bar .date-range { display: inline-flex; align-items: center; gap: 4px; }
.filter-bar .date-range .dash { flex-shrink: 0; font-size: 14px; color: var(--text-muted); align-self: center; line-height: 1; margin-top: 14px; }

/* ===== Flash messages ===== */
.flash-container { padding: 0 32px; max-width: 1120px; margin: 12px auto 0; width: 100%; }
.alert {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 8px;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.alert-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #f0d8d6; }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid #d4e8dd; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border: 1px solid #ede4cc; }
.alert-info { background: var(--info-soft); color: var(--info); border: 1px solid #d4e0e8; }
.alert-close { margin-left: auto; background: none; border: none; font-size: 18px; cursor: pointer; line-height: 1; opacity: 0.5; color: inherit; }
.alert-close:hover { opacity: 1; }

/* ===== Breadcrumb ===== */
.breadcrumb { display: flex; align-items: center; gap: 6px; padding: 0 32px; margin-top: 12px; max-width: 1120px; width: 100%; margin-left: auto; margin-right: auto; font-size: 12px; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .current { font-weight: 600; color: var(--text-secondary); }

/* ===== Pagination ===== */
.pagination-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border-light); }
.pagination-actions { display: flex; gap: 6px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 16px; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 6px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid var(--border); color: var(--text-secondary); text-decoration: none; transition: all var(--transition); }
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; display: block; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ===== Page header ===== */
.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 18px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }

/* ===== Form actions ===== */
.form-actions-sticky { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 0; margin-top: 20px; border-top: 1px solid var(--border); }

/* ===== Modal overlay ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(42,37,32,0.5);
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg);
  max-width: 480px; width: 100%;
  box-shadow: 0 20px 60px rgba(42,37,32,0.15);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.modal-head h3 { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; padding: 0; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 24px 24px; font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 0 24px 20px; }

/* ===== Section divider ===== */
.section-title {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

/* ===== Grade advancement banner ===== */
.advance-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.advance-banner h3 { font-size: 17px; font-weight: 700; }
.advance-banner p { font-size: 13px; opacity: 0.85; margin-top: 4px; line-height: 1.5; }
.advance-banner .btn-advance {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff; padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  font-family: inherit; white-space: nowrap;
  backdrop-filter: blur(4px);
}
.advance-banner .btn-advance:hover { background: rgba(255,255,255,0.3); }


/* ===== Survey form specific ===== */
.responsive-grid { display: grid; gap: 12px; }
.responsive-grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) {
  .responsive-grid.two { grid-template-columns: 1fr; }
}
.toolbar-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.upload-note {
  background: var(--info-soft); padding: 12px 16px;
  border-radius: var(--radius-sm); margin-bottom: 20px;
  font-size: 13px; color: var(--info); line-height: 1.6;
}
.student-list { list-style: none; padding: 0; margin: 0; }
.student-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
  gap: 12px;
}
.student-item:hover { background: var(--surface-hover); }
.student-item:last-child { border-bottom: none; }
.student-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.student-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.student-name-area { flex: 1; min-width: 0; }
.student-name { font-size: 14px; font-weight: 600; color: var(--text); display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.student-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.student-actions { display: flex; gap: 6px; flex-shrink: 0; }
.class-checkbox-grid { display: flex; flex-direction: column; gap: 12px; }
.grade-group { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.grade-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--surface-soft); border-bottom: 1px solid var(--border); }
.grade-classes { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
.class-checkbox-item {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border-light);
  cursor: pointer; font-size: 13px; transition: all 0.15s; user-select: none;
}
.class-checkbox-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.class-checkbox-item input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--primary); cursor: pointer; }
.class-checkbox-item:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .main-content { padding: 20px; max-width: 100%; }
  .flash-container { padding: 0 20px; }
  .breadcrumb { padding: 0 20px; }
}

@media (max-width: 768px) {
  body { font-size: 16px; line-height: 1.7; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(42,37,32,0.25); z-index: 99; }
  .sidebar-overlay.open { display: block; }
  .main-wrapper { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .main-content { padding: 16px; max-width: 100%; }
  .flash-container { padding: 0 16px; }
  .breadcrumb { padding: 0 16px; }
  .bottom-nav { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-card .num { font-size: 22px; }
  .desktop-only { display: none; }
  .page-header h2 { font-size: 16px; }
  .form-actions-sticky { bottom: var(--bottom-nav-height); }
  .main-content { padding-bottom: calc(var(--bottom-nav-height) + 24px); }
  .filter-bar { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .filter-bar select { flex: 1 1 calc(50% - 8px); min-width: 0; }
  .filter-bar .date-range { display: flex; flex: 1 1 100%; gap: 6px; align-items: flex-end; }
  .filter-bar .date-range .filter-label { flex: 1; min-width: 0; }
  .filter-bar .date-range .dash { flex-shrink: 0; font-size: 16px; color: var(--text-muted); align-self: flex-end; line-height: 36px; margin-bottom: 0; }
  .advance-banner { padding: 20px; }
  .advance-banner .btn-advance { width: 100%; text-align: center; }
  .modal-box { margin: auto 12px; }
  table th, table td { padding: 10px 12px; font-size: 15px; }
}

@media (max-width: 480px) {
  body { font-size: 17px; line-height: 1.8; }
  .main-content { padding: 12px; }
  .filter-bar select, .filter-bar input { font-size: 16px; padding: 8px 12px; }
  .btn-app { font-size: 16px; padding: 10px 20px; }
  .form-group label { font-size: 13px; }
  .question-item { padding: 14px; }
  .option-group { gap: 4px; }
  .option-btn { padding: 6px 10px; font-size: 12px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .student-item { flex-direction: column; align-items: flex-start; gap: 6px; }
  .student-actions { width: 100%; justify-content: flex-end; }
  .form-actions-sticky { flex-direction: column; }
  .form-actions-sticky .btn-app { width: 100%; justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .stat-card { padding: 12px; }
  .stat-card .num { font-size: 20px; }
}

/* ===== Bottom nav (mobile only) ===== */
.bottom-nav { display: none; }
@media (max-width: 768px) {
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 50;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 6px 12px;
    font-size: 10px; color: var(--text-muted);
    text-decoration: none; transition: color var(--transition);
    border-radius: var(--radius-sm);
  }
  .bottom-nav a i { font-size: 18px; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a:hover { color: var(--primary); }
}

/* ===== Sidebar overlay (desktop always hidden) ===== */
@media (min-width: 769px) {
  .sidebar-overlay { display: none !important; }
}
