/* ============================================================
   智能教学管理系统 - 全局样式
   约定：:root = 浅色（默认），[data-theme="dark"] = 深色覆盖
   ============================================================ */

/* ============ 主题变量 ============ */
:root {
  /* 浅色（默认） */
  --bg: #F1F5F9;
  --bg-2: #FFFFFF;
  --bg-3: #F8FAFC;
  --card: #FFFFFF;
  --card-hover: #F8FAFC;
  --border: #E2E8F0;
  --border-light: #CBD5E1;

  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: rgba(37, 99, 235, 0.1);

  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #06B6D4;
  --purple: #8B5CF6;
  --pink: #EC4899;

  --text: #1E293B;
  --text-2: #475569;
  --text-dim: #64748B;
  --text-mute: #94A3B8;
  --input-bg: #F8FAFC;

  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15);

  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --gradient: linear-gradient(135deg, #3B82F6, #8B5CF6);
  --sidebar-w: 240px;

  color-scheme: light;
}

/* ============ 深色覆盖 ============ */
[data-theme="dark"] {
  --bg: #0F1419;
  --bg-2: #161B22;
  --bg-3: #1C2333;
  --card: #1E2536;
  --card-hover: #252E42;
  --border: #2D3748;
  --border-light: #374151;

  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --primary-soft: rgba(59, 130, 246, 0.12);

  --text: #F1F5F9;
  --text-2: #CBD5E1;
  --text-dim: #94A3B8;
  --text-mute: #64748B;
  --input-bg: #0F1419;

  --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);

  color-scheme: dark;
}

/* ============ 基础 reset ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: var(--bg);
  color: var(--text);
}

body {
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-hover); }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 5px;
  border: 2px solid var(--bg-2);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* ============================================================
   布局
   ============================================================ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 50;
  transition: width 0.2s;
}

.sidebar-user {
  padding: 1.6rem 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
  background: linear-gradient(180deg, var(--bg-3) 0%, transparent 100%);
}

.sidebar-avatar {
  width: 68px; height: 68px;
  margin: 0 auto 0.7rem;
  border-radius: 50%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.9rem; font-weight: 700; color: #fff;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.35);
  border: 3px solid var(--bg-2);
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }

.sidebar-nickname { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.2rem; word-break: break-all; }
.sidebar-email { font-size: 0.72rem; color: var(--text-dim); word-break: break-all; margin-bottom: 0.6rem; }
.sidebar-plan {
  display: inline-block; padding: 0.25rem 0.75rem;
  border-radius: 12px; font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.3px;
}

.sidebar-identity { margin-top: 0.7rem; }
.sidebar-identity label {
  font-size: 0.7rem; color: var(--text-mute);
  display: block; text-align: left; margin-bottom: 0.25rem;
}

.sidebar-nav { flex: 1; padding: 0.6rem 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.65rem 1.2rem;
  color: var(--text-dim); font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: all 0.15s; cursor: pointer;
  position: relative;
}
.sidebar-nav a:hover { background: var(--primary-soft); color: var(--text); }
.sidebar-nav a.active {
  background: var(--primary-soft); color: var(--primary);
  border-left-color: var(--primary); font-weight: 600;
}
.sidebar-nav a .badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 0.65rem; padding: 0.1rem 0.45rem; border-radius: 8px;
  min-width: 18px; text-align: center;
}
.sidebar-nav .section-title {
  padding: 0.9rem 1.2rem 0.35rem;
  font-size: 0.68rem; text-transform: uppercase;
  color: var(--text-mute); letter-spacing: 1.2px; font-weight: 700;
}

.sidebar-bottom {
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.4rem;
}

.main { flex: 1; margin-left: var(--sidebar-w); overflow-x: hidden; min-width: 0; }

.main-header {
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex; justify-content: space-between;
  align-items: center; gap: 1rem;
}
[data-theme="dark"] .main-header { background: rgba(22, 27, 34, 0.85); }

.main-header h1 { font-size: 1.2rem; font-weight: 700; margin: 0; }
.main-header .subtitle { font-size: 0.82rem; color: var(--text-dim); margin-top: 0.1rem; }

.header-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.menu-toggle-btn { display: none !important; }

.sidebar-mask {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 45; display: none;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.sidebar-mask.show { display: block; }

.main-content { padding: 1.5rem 2rem; max-width: 1400px; margin: 0 auto; }

.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   组件
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.875rem; font-weight: 500;
  transition: all 0.15s; white-space: nowrap; line-height: 1.4;
}
.btn:hover {
  background: var(--card-hover);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover {
  background: var(--primary-hover); color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}
.btn.success { background: var(--success); color: #fff; border-color: var(--success); }
.btn.success:hover { background: #059669; }
.btn.danger { color: var(--danger); border-color: rgba(239, 68, 68, 0.4); }
.btn.danger:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); border-color: var(--danger); }
.btn.warn { color: var(--warning); border-color: rgba(245, 158, 11, 0.4); }
.btn.warn:hover { background: var(--warning); color: #fff; border-color: var(--warning); }

.btn.sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; border-radius: 8px; }
.btn.lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn.block { width: 100%; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem;
  margin-bottom: 1.2rem;
  transition: all 0.2s;
}
.card:hover { border-color: var(--border-light); }
.card h3 {
  font-size: 1rem; font-weight: 700;
  margin-bottom: 1rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; flex-wrap: wrap;
}
.card h4 {
  font-size: 0.92rem; font-weight: 600;
  margin: 0.8rem 0 0.5rem; color: var(--text-2);
}
.card-title {
  display: flex; align-items: center; gap: 0.5rem;
  justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.1rem;
  transition: all 0.2s;
  position: relative; overflow: hidden;
}
.stat::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--gradient);
  opacity: 0; transition: opacity 0.2s;
}
.stat:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.stat:hover::before { opacity: 1; }
.stat .icon { font-size: 1.7rem; margin-bottom: 0.3rem; display: block; }
.stat .value {
  font-size: 1.9rem; font-weight: 800;
  color: var(--primary); line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat .label { color: var(--text-dim); font-size: 0.82rem; margin-top: 0.25rem; }

.stat.stat-clickable { padding: 0.85rem 0.9rem; cursor: pointer; }
.stat.stat-clickable:hover { transform: translateY(-2px); border-color: var(--primary); }
.stat.stat-clickable .icon { font-size: 1.3rem; margin-bottom: 0.2rem; }
.stat.stat-clickable .value { font-size: 1.4rem; }
.stat.stat-clickable .label { font-size: 0.75rem; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.8rem; margin-bottom: 1.5rem;
}
.quick-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 0.9rem;
  text-align: center; cursor: pointer;
  transition: all 0.2s;
}
.quick-item:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
  background: var(--card-hover);
}
.quick-item .icon { font-size: 2rem; margin-bottom: 0.4rem; display: block; }
.quick-item .title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.15rem; }
.quick-item .desc { font-size: 0.75rem; color: var(--text-dim); }

.quick-item[draggable="true"] { cursor: grab; }
.quick-item[draggable="true"]:active { cursor: grabbing; }
.quick-item.dragging { opacity: 0.4; transform: scale(0.96); }
.quick-item.drag-over {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-soft) !important;
}

.tabs {
  display: flex; gap: 0.3rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.3rem; flex-wrap: wrap;
}
.tab {
  padding: 0.6rem 1rem;
  color: var(--text-dim); font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all 0.15s;
  font-weight: 500; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }

.subtabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.subtab {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  transition: all 0.15s; white-space: nowrap;
}
.subtab:hover { border-color: var(--primary); color: var(--primary); }
.subtab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.subtab-pane { display: none; }
.subtab-pane.active { display: block; animation: fadeIn 0.2s ease; }

.field {
  display: block; margin-bottom: 1rem;
  font-size: 0.85rem; color: var(--text-2); font-weight: 500;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  margin-top: 0.4rem;
  font-size: 0.9rem;
  transition: all 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field textarea { resize: vertical; min-height: 80px; }
.field input:disabled, .field select:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============ 通用输入框 ============ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
  appearance: none;
  -webkit-appearance: none;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 36px;
}

select {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 12px;
  padding-right: 2rem;
  cursor: pointer;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input::placeholder, textarea::placeholder {
  color: var(--text-mute);
  opacity: 0.7;
}

select option {
  background-color: var(--card);
  color: var(--text);
}

/* Chrome 自动填充 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px var(--input-bg) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text) !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* 筛选栏紧凑 */
.card > .row > select,
.card > .row > input[type="search"],
.card > .row > input[type="text"] {
  flex: 0 0 auto;
  min-width: 120px;
  max-width: 200px;
  font-size: 0.85rem;
  padding: 0.45rem 0.7rem;
  min-height: 34px;
}

.row { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 200px; }
.row.gap-sm { gap: 0.5rem; }
.row.gap-sm > * { min-width: auto; flex: none; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; align-items: center; }
.row.center { justify-content: center; align-items: center; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; border-radius: 10px; overflow: hidden; }
th, td {
  padding: 0.7rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-dim); font-weight: 600;
  font-size: 0.82rem;
  background: var(--bg-3); white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-3); }

.tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem; font-weight: 600;
  background: var(--bg-3); color: var(--primary);
  border: 1px solid var(--border); white-space: nowrap;
}
.tag.success { background: rgba(16,185,129,0.1); color: var(--success); border-color: rgba(16,185,129,0.3); }
.tag.warn { background: rgba(245,158,11,0.1); color: var(--warning); border-color: rgba(245,158,11,0.3); }
.tag.danger { background: rgba(239,68,68,0.1); color: var(--danger); border-color: rgba(239,68,68,0.3); }
.tag.info { background: rgba(6,182,212,0.1); color: var(--info); border-color: rgba(6,182,212,0.3); }
.tag.purple { background: rgba(139,92,246,0.1); color: var(--purple); border-color: rgba(139,92,246,0.3); }
.tag.gray { background: var(--bg-3); color: var(--text-mute); border-color: var(--border); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem; font-weight: 700; line-height: 1.4;
}

.info-box {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem; color: var(--text-2);
  margin-bottom: 1rem; line-height: 1.6;
}
.info-box code {
  background: var(--bg); padding: 0.1rem 0.4rem;
  border-radius: 4px; font-size: 0.8rem;
  color: var(--primary); font-family: 'Consolas', 'Monaco', monospace;
}

.success-box {
  background: rgba(16,185,129,0.1);
  border-left: 3px solid var(--success);
  padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; margin: 0.5rem 0;
}
.error-box {
  background: rgba(239,68,68,0.1);
  border-left: 3px solid var(--danger);
  padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; margin: 0.5rem 0;
}
.warn-box {
  background: rgba(245,158,11,0.1);
  border-left: 3px solid var(--warning);
  padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; margin: 0.5rem 0;
}

.empty { text-align: center; padding: 3rem 1rem; color: var(--text-mute); }
.empty .icon { font-size: 3.5rem; margin-bottom: 0.6rem; display: block; opacity: 0.6; }
.empty .title { font-size: 0.95rem; font-weight: 500; color: var(--text-dim); margin-bottom: 0.3rem; }
.empty .desc { font-size: 0.82rem; }

/* ============ 弹窗 ============ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  display: none; align-items: center; justify-content: center;
  z-index: 9998; padding: 1rem;
  animation: fadeIn 0.2s ease;
}
.modal-bg.show { display: flex; }
.modal {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 1.8rem;
  max-width: 520px; width: 100%;
  max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}
.modal.wide { max-width: 800px; }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal h3 {
  color: var(--text);
  font-size: 1.15rem; font-weight: 700;
  padding-bottom: 0.9rem;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.5rem;
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.7rem;
  margin-top: 1.5rem; padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.modal-footer .btn {
  padding: 0.6rem 1.4rem;
  font-weight: 600;
  border-radius: 10px;
}

/* ============ Toast ============ */
.toast-container {
  position: fixed; top: 1rem; right: 1rem;
  z-index: 99999;
  display: flex; flex-direction: column; gap: 0.5rem;
  pointer-events: none; max-width: 380px;
}
.toast {
  border-radius: 12px;
  padding: 0.85rem 1.2rem;
  font-size: 0.88rem; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--primary);
  color: var(--text);
  animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto; word-break: break-word;
  min-width: 200px;
}
[data-theme="dark"] .toast {
  background: rgba(30, 37, 54, 0.95);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.4rem; vertical-align: middle;
}
.spinner.lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 课表 ============ */
.schedule-grid {
  display: grid;
  grid-template-columns: 90px repeat(7, 1fr);
  gap: 2px; background: var(--border);
  padding: 2px; border-radius: var(--radius);
  overflow: hidden;
}
.schedule-grid .head-cell {
  background: var(--bg-3);
  padding: 0.7rem 0.3rem;
  text-align: center; font-weight: 700;
  font-size: 0.82rem; color: var(--text-dim);
}
.schedule-grid .head-cell.today { background: var(--primary-soft); color: var(--primary); }
.schedule-grid .time-col {
  background: var(--bg-3);
  padding: 0.5rem 0.3rem;
  text-align: center; font-size: 0.72rem;
  color: var(--text-mute);
  display: flex; flex-direction: column; justify-content: center;
}
.schedule-grid .cell {
  background: var(--card);
  min-height: 62px; padding: 0.25rem;
  cursor: pointer; transition: all 0.15s;
  position: relative;
}
.schedule-grid .cell:hover { background: var(--card-hover); }
.schedule-grid .cell.today { background: var(--primary-soft); }
.schedule-grid .add-hint {
  color: var(--text-mute); font-size: 1.4rem;
  text-align: center; padding-top: 1rem;
  opacity: 0; transition: opacity 0.15s;
}
.schedule-grid .cell:hover .add-hint { opacity: 1; }
.schedule-grid .course {
  padding: 0.35rem 0.45rem;
  border-radius: 5px; font-size: 0.72rem;
  line-height: 1.35; margin-bottom: 2px;
  color: #fff; position: relative; cursor: pointer;
}
.schedule-grid .course .course-actions { display: none; position: absolute; top: 2px; right: 2px; }
.schedule-grid .course:hover .course-actions { display: block; }
.schedule-grid .course .course-actions span {
  cursor: pointer; background: rgba(0, 0, 0, 0.4);
  border-radius: 3px; padding: 0 4px; font-size: 0.7rem;
}

/* ============ 宠物 ============ */
.pet-display {
  background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(139,92,246,0.15));
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 2rem; text-align: center;
  position: relative; overflow: hidden;
}
.pet-display .pet-big-icon {
  font-size: 5rem;
  animation: petFloat 3s ease-in-out infinite;
  display: inline-block;
}
@keyframes petFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.pet-display h3 { color: var(--primary); margin: 0.5rem 0; font-size: 1.3rem; justify-content: center; }
.pet-progress {
  background: var(--bg-2); height: 12px;
  border-radius: 6px; overflow: hidden;
  max-width: 400px; margin: 1rem auto;
}
.pet-progress-bar {
  height: 100%; background: var(--gradient);
  transition: width 0.5s ease;
}

.pet-rank-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.7rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-bottom: 0.5rem;
  transition: all 0.15s;
}
.pet-rank-item:hover { border-color: var(--primary); background: var(--bg-3); }
.pet-rank-item .rank-num {
  font-size: 1.3rem; font-weight: 800;
  color: var(--text-mute); min-width: 40px; text-align: center;
}
.pet-rank-item.top1 .rank-num { color: #FFD700; }
.pet-rank-item.top2 .rank-num { color: #C0C0C0; }
.pet-rank-item.top3 .rank-num { color: #CD7F32; }
.pet-rank-item .pet-rank-name { flex: 1; font-weight: 500; }
.pet-rank-item .pet-rank-exp { color: var(--primary); font-weight: 700; }

/* ============ 数据导入导出 ============ */
.data-manager {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1rem; margin-top: 0.8rem;
}
.data-card {
  background: var(--bg-3);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 1.2rem; text-align: center;
  transition: all 0.2s;
}
.data-card:hover { border-color: var(--primary); border-style: solid; }
.data-card .big-icon { font-size: 2.5rem; margin-bottom: 0.5rem; display: block; }
.data-card .title { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.3rem; }
.data-card .desc { font-size: 0.78rem; color: var(--text-dim); margin-bottom: 0.8rem; line-height: 1.6; }
.data-card .btn { width: 100%; }

.import-drop {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 1.5rem; text-align: center;
  transition: all 0.2s; cursor: pointer; margin-top: 0.6rem;
}
.import-drop:hover { border-color: var(--primary); background: var(--primary-soft); }
.import-drop.dragover { border-color: var(--primary); background: var(--primary-soft); }

/* ============ 工具类 ============ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }

.back-btn {
  padding: 0.35rem 0.6rem !important;
  font-size: 0.95rem !important;
  min-width: 34px; line-height: 1;
}

/* ============ 登录/注册页 ============ */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #E0E7FF 0%, #F1F5F9 100%);
  color: #1E293B;
  padding: 2rem 1rem;
  display: flex; align-items: center; justify-content: center;
}
[data-theme="dark"] .auth-page {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  color: #F1F5F9;
}
.auth-container { max-width: 1180px; width: 100%; }
.auth-container.narrow { max-width: 460px; }
.auth-container.narrow .auth-layout { grid-template-columns: 1fr; }

.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header h1 {
  font-size: 2.2rem; margin-bottom: 0.5rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text; font-weight: 800;
}
.auth-header p { color: var(--text-dim); font-size: 0.95rem; }

.auth-layout {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 2rem; align-items: flex-start;
}
.auth-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}
.auth-box h2 { font-size: 1.2rem; margin-bottom: 1.3rem; text-align: center; }

.divider {
  display: flex; align-items: center; gap: 0.8rem;
  margin: 1rem 0; color: var(--text-mute); font-size: 0.78rem;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.msg { display: none; }
.section-title {
  font-size: 1rem; font-weight: 700;
  margin: 1.5rem 0 0.8rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.section-desc { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 1rem; }

/* ============================================================
   响应式
   ============================================================ */

/* 平板 */
@media (max-width: 900px) and (min-width: 601px) {
  :root { --sidebar-w: 220px; }
  .main-content { padding: 1.2rem 1.5rem; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
}

/* 移动端 ≤ 900px */
@media (max-width: 900px) {
  .sidebar {
    left: auto;
    right: 0;
    width: 280px;
    max-width: 85vw;
    transform: translateX(100%);
    border-right: none;
    border-left: 1px solid var(--border);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  }
  .main { margin-left: 0; }
  .menu-toggle-btn { display: inline-flex !important; font-size: 1.2rem; }

  .main-header {
    padding: 0.85rem 1rem;
    flex-direction: row; align-items: center;
  }
  .main-header h1 { font-size: 1.05rem; }
  .main-header .subtitle { font-size: 0.75rem; }
  .header-actions { flex-shrink: 0; margin-left: auto; }
  .back-btn { display: none !important; }

  .main-content { padding: 1rem; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; margin-bottom: 1rem; }
  .stat { padding: 0.9rem 0.7rem; }
  .stat .icon { font-size: 1.4rem; }
  .stat .value { font-size: 1.5rem; }
  .stat .label { font-size: 0.72rem; }

  .quick-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-bottom: 1rem; }
  .quick-item { padding: 1rem 0.6rem; }
  .quick-item .icon { font-size: 1.7rem; }
  .quick-item .title { font-size: 0.84rem; }
  .quick-item .desc { font-size: 0.7rem; }

  .tabs, .subtabs {
    overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: 2px;
  }
  .tabs::-webkit-scrollbar, .subtabs::-webkit-scrollbar { display: none; }
  .tab, .subtab { flex-shrink: 0; }

  .row { flex-direction: column; gap: 0.6rem; }
  .row > * { width: 100%; min-width: 0; flex: none; }
  .row.gap-sm { flex-direction: row; }
  .row.gap-sm > * { width: auto; flex: none; }
  .row.end { flex-direction: row; justify-content: flex-end; }

  .table-wrap, .card table {
    display: block; overflow-x: auto; white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  table { min-width: 560px; }
  th, td { padding: 0.6rem 0.5rem; font-size: 0.8rem; }

  .modal {
    max-width: 100%; width: 100%;
    margin: 0; padding: 1.2rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    align-self: flex-end; max-height: 92vh;
  }
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal-footer { flex-direction: column-reverse; gap: 0.5rem; }
  .modal-footer .btn { width: 100%; }

  .schedule-grid { min-width: 700px; }
  .card:has(.schedule-grid) { overflow-x: auto; }

  .pet-display { padding: 1.5rem 1rem; }
  .pet-display .pet-big-icon { font-size: 3.5rem; }

  .data-manager { grid-template-columns: 1fr; }

  .sidebar-nav a { padding: 0.7rem 1.2rem; font-size: 0.92rem; }
  .sidebar-user { padding: 1.2rem 1rem; }
  .sidebar-avatar { width: 56px; height: 56px; font-size: 1.5rem; }

  .toast-container { top: 0.5rem; right: 0.5rem; left: 0.5rem; max-width: none; }

  /* 输入框统一 16px 防 iOS 缩放 */
  input, select, textarea {
    font-size: 16px !important;
    padding: 0.5rem 0.7rem;
    min-height: 38px;
    border-radius: 8px;
  }
  select {
    padding-right: 1.8rem;
    background-size: 11px;
    min-width: 0;
    max-width: 100%;
  }

  .card > .row > select,
  .card > .row > input[type="search"],
  .card > .row > input[type="text"] {
    flex: 1 1 calc(50% - 0.25rem);
    max-width: none;
    min-width: 0;
  }

  .auth-layout { grid-template-columns: 1fr; }
  .auth-header h1 { font-size: 1.6rem; }
  .auth-box { padding: 1.5rem; }
}

/* 小屏 ≤ 480px */
@media (max-width: 480px) {
  .main-header h1 { font-size: 0.95rem; }
  .main-header .subtitle { display: none; }
  .main-content { padding: 0.8rem; }
  .card { padding: 1rem; border-radius: 10px; }
  .card h3 { font-size: 0.95rem; }
  .card h4 { font-size: 0.88rem; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .stat { padding: 0.7rem 0.6rem; }
  .stat .value { font-size: 1.3rem; }

  .quick-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .quick-item { padding: 0.9rem 0.5rem; }
  .quick-item .icon { font-size: 1.5rem; }
  .quick-item .title { font-size: 0.78rem; }
  .quick-item .desc { display: none; }

  .btn { padding: 0.5rem 0.9rem; font-size: 0.82rem; }
  .btn.sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }

  .modal { padding: 1rem; }
  .modal h3 { font-size: 1rem; }

  .toast { font-size: 0.8rem; padding: 0.65rem 0.9rem; }

  .sidebar-bottom .btn { font-size: 0.82rem; padding: 0.55rem; }

  .data-card { padding: 1rem; }
  .data-card .big-icon { font-size: 2rem; }
  .data-card .title { font-size: 0.88rem; }

  .auth-page { padding: 1rem 0.8rem; }
  .auth-box { padding: 1.2rem; }
  .auth-header h1 { font-size: 1.4rem; }
}

/* 触摸优化 */
@media (hover: none) {
  .sidebar-nav a:hover { background: none; }
  .sidebar-nav a:active { background: var(--primary-soft); }
  .quick-item:active { transform: scale(0.97); }
  .btn:active { transform: scale(0.97); }
  .card:hover { border-color: var(--border); }
}

/* ============================================================
   补丁：模块专属样式
   ============================================================ */

/* 作业提交预览 */
#sh-preview img { transition: transform 0.15s; }
#sh-preview img:hover { transform: scale(1.05); }

.modal pre::-webkit-scrollbar,
.modal div[style*="overflow-y:auto"]::-webkit-scrollbar { width: 6px; height: 6px; }
.modal pre::-webkit-scrollbar-thumb,
.modal div[style*="overflow-y:auto"]::-webkit-scrollbar-thumb {
  background: var(--border-light); border-radius: 3px;
}

/* 签到 */
#att-summary {
  background: var(--bg-3);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
}
#att-roster-list .tag { min-width: 52px; text-align: center; }
#attendance-sessions-list .card > div[style*="display:flex"] > div:first-child { min-width: 0; }
@media (max-width: 600px) {
  #att-summary { font-size: 0.78rem; }
  #att-summary span { display: block; margin-bottom: 0.2rem; }
}

/* 课程资源 */
#res-file-info {
  padding: 0.4rem 0.6rem;
  background: var(--bg-3);
  border-radius: 6px;
  min-height: 1.8em;
}
.modal a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* 家长查看孩子 tab */
.child-tab-pane { animation: fadeIn 0.2s ease; }

/* PC 端强制侧边栏 */
@media (min-width: 901px) {
  .sidebar {
    transform: translateX(0) !important;
    left: 0 !important;
    right: auto !important;
    border-right: 1px solid var(--border) !important;
    border-left: none !important;
  }
  .main { margin-left: var(--sidebar-w, 240px) !important; }
  .sidebar-mask { display: none !important; }
  .menu-toggle-btn { display: none !important; }
}

/* ============================================================
   主题锁定（防止"忽明忽暗"）
   ============================================================ */
html[data-theme] {
  background-color: var(--bg) !important;
  color: var(--text) !important;
}

html[data-theme] body {
  background-color: var(--bg);
  color: var(--text);
}

img, video, svg, canvas { color-scheme: normal; }

*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

::selection {
  background: var(--primary-soft);
  color: var(--text);
}

/* 打印 */
@media print {
  html, body { background: #fff !important; color: #000 !important; }
}