:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #9ca3af;
  --line: #eef1f4;
  --accent: #3b82f6;
  --accent-soft: #eff6ff;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
}

/* ===== 登录 ===== */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 36px 40px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-box .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--accent); margin-bottom: 8px; }
.login-box .muted { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-box .input { margin-bottom: 14px; }
.login-box .button { width: 100%; }

/* ===== 品牌 ===== */
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; color: var(--accent); }
.brand-mark { width: 26px; height: 26px; background: var(--accent); color: #fff; border-radius: 7px; display: grid; place-items: center; font-size: 13px; font-weight: 700; }

/* ===== 布局 ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 18px 18px 14px; }
.nav { flex: 1; padding: 4px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: 7px; cursor: pointer;
  font-size: 13.5px; color: #4b5563; margin-bottom: 2px; user-select: none;
}
.nav-item .ic { width: 20px; text-align: center; margin-right: 10px; opacity: 0.8; flex-shrink: 0; }
.nav-item .label { display: flex; align-items: center; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .count { font-size: 11px; background: var(--line); padding: 1px 8px; border-radius: 10px; color: var(--muted); }
.nav-item.active .count { background: var(--accent); color: #fff; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  padding: 12px 28px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; gap: 12px; align-items: center; position: sticky; top: 0; z-index: 20;
}
.search-box { flex: 1; max-width: 380px; position: relative; }
.search-box input {
  width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13.5px; background: #f8fafc; outline: none; color: var(--text);
}
.search-box input:focus { border-color: var(--accent); background: #fff; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

.content { flex: 1; overflow-y: auto; padding: 20px 28px; max-width: 820px; width: 100%; }
.page-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.page-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.section-title { font-size: 15px; font-weight: 700; margin: 20px 0 10px; color: var(--text); }

/* ===== 表单 ===== */
.input, .select, .textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fff; color: var(--text); outline: none; font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); }
.textarea { min-height: 96px; resize: vertical; }
.button {
  padding: 8px 18px; border-radius: 8px; border: none; font-size: 13px; font-weight: 600;
  cursor: pointer; background: var(--accent); color: #fff; white-space: nowrap;
}
.button:hover { opacity: 0.9; }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button.secondary { background: #fff; color: #4b5563; border: 1px solid var(--line); }
.button.ghost { background: transparent; color: var(--muted); border: none; }
.button.ghost:hover { color: var(--danger); background: #fef2f2; }

/* ===== 快速添加 ===== */
.quick-add { display: flex; gap: 8px; margin-bottom: 18px; }
.quick-add input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fff; outline: none; color: var(--text);
}
.quick-add input:focus { border-color: var(--accent); }
.quick-add button { padding: 10px 20px; }

/* ===== 任务列表（Vikunja 风格） ===== */
.task-list { display: flex; flex-direction: column; }
.task-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; margin-bottom: 8px; transition: box-shadow 0.15s, border-color 0.15s;
  position: relative;
}
.task-row:hover { box-shadow: var(--shadow); border-color: #dbe2ea; }

/* 领域彩色竖条 */
.task-row::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 3px 3px 0; background: var(--dc, #e5e7eb);
}
.task-row.dm-teaching { --dc: #3b82f6; }
.task-row.dm-school { --dc: #8b5cf6; }
.task-row.dm-project { --dc: #10b981; }
.task-row.dm-family { --dc: #f59e0b; }
.task-row.dm-career { --dc: #ec4899; }
.task-row.dm-daily { --dc: #64748b; }

.task-row.done { opacity: 0.55; }
.task-row.done .task-title { text-decoration: line-through; color: var(--muted); }

/* 勾选圆圈 */
.task-check {
  width: 20px; height: 20px; border: 2px solid #d1d5db; border-radius: 50%;
  flex-shrink: 0; cursor: pointer; margin-top: 1px;
  display: grid; place-items: center; font-size: 11px; color: transparent;
  transition: all 0.18s;
}
.task-check:hover { border-color: var(--accent); }
.task-check.checked { background: var(--accent); border-color: var(--accent); color: #fff; }
.task-check.checked::after { content: "✓"; }
.task-check.canceled { background: var(--danger); border-color: var(--danger); color: #fff; }
.task-check.canceled::after { content: "✕"; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 500; line-height: 1.5; word-break: break-word; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; align-items: center; }

/* 彩色圆点标签 */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; padding: 2px 9px; border-radius: 20px;
  background: #f3f4f6; color: #4b5563; font-weight: 500;
}
.tag .dot { width: 7px; height: 7px; border-radius: 50%; }
.tag.dm-teaching { background: #eff6ff; color: #2563eb; } .tag.dm-teaching .dot { background: #3b82f6; }
.tag.dm-school { background: #f5f3ff; color: #7c3aed; } .tag.dm-school .dot { background: #8b5cf6; }
.tag.dm-project { background: #ecfdf5; color: #059669; } .tag.dm-project .dot { background: #10b981; }
.tag.dm-family { background: #fffbeb; color: #d97706; } .tag.dm-family .dot { background: #f59e0b; }
.tag.dm-career { background: #fdf2f8; color: #db2777; } .tag.dm-career .dot { background: #ec4899; }
.tag.dm-daily { background: #f1f5f9; color: #475569; } .tag.dm-daily .dot { background: #64748b; }
.tag.project { background: #eef2ff; color: #4338ca; }
.tag.due { background: #fff7ed; color: #c2410c; }
.tag.due.overdue { background: #fef2f2; color: #dc2626; }
.tag.done-time { background: #ecfdf5; color: #059669; }
.tag.canceled { background: #fef2f2; color: #dc2626; }

.task-next { font-size: 12.5px; color: #6b7280; margin-top: 4px; }

/* 操作按钮：hover 才显示 */
.task-actions {
  display: flex; gap: 4px; flex-shrink: 0;
  opacity: 0; transition: opacity 0.15s;
}
.task-row:hover .task-actions { opacity: 1; }
.icon-btn {
  width: 28px; height: 28px; border: none; background: transparent; border-radius: 6px;
  cursor: pointer; font-size: 14px; color: #9ca3af;
  display: grid; place-items: center;
}
.icon-btn:hover { background: #f3f4f6; color: #374151; }
.icon-btn.danger:hover { background: #fef2f2; color: var(--danger); }

/* ===== 归档 ===== */
.archive-date {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: #4b5563;
  margin: 16px 0 8px;
}
.archive-date:first-child { margin-top: 0; }
.badge { font-size: 11px; background: var(--line); padding: 1px 8px; border-radius: 10px; color: var(--muted); font-weight: 500; }

/* ===== 复盘 ===== */
.review-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 8px; }
.review-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; text-align: center;
}
.review-card .num { font-size: 26px; font-weight: 800; color: var(--accent); }
.review-card .label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.review-card.warn .num { color: var(--warn); }
.review-card.danger .num { color: var(--danger); }
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-range { font-size: 14px; color: var(--muted); font-weight: 600; padding: 0 8px; white-space: nowrap; }

/* ===== 空状态 ===== */
.empty-state {
  background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 36px 20px; text-align: center; color: var(--muted); font-size: 14px;
}

/* ===== 弹窗 ===== */
.dialog-layer {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.dialog-layer.open { display: flex; }
.modal {
  background: var(--panel); border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; padding: 22px 24px; box-shadow: 0 10px 40px rgba(0,0,0,0.12);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h2 { font-size: 17px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: #4b5563; margin-bottom: 5px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

/* AI 建议 */
.ai-suggestion {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 9px;
  padding: 12px 14px; margin-bottom: 10px;
}
.ai-kind {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: #eef2ff; color: #4338ca;
}
.ai-payment .ai-kind { background: #ecfdf5; color: #047857; }
.ai-lesson .ai-kind { background: #eff6ff; color: #2563eb; }
.ai-task .ai-kind { background: #fef3c7; color: #b45309; }
.ai-suggestion .task-next { color: #d97706; font-size: 12px; margin-top: 4px; }

/* 弹窗内的删除按钮 */
.button.danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.button.danger:hover { background: #fee2e2; }

/* 学情分数区（仅考试显示） */
.record-score { display: inline-flex; align-items: center; gap: 4px; }

/* ===== 日程表周历 ===== */
.legend { display: flex; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.day-col {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 360px; display: flex; flex-direction: column;
}
.day-col.today { border-color: var(--accent); border-width: 2px; }
.day-col.weekend { background: #fafafa; }
.day-header {
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center;
}
.day-header .date { font-size: 11px; color: var(--muted); font-weight: 400; }
.schedule-item {
  margin: 6px 8px; padding: 8px 10px; border-radius: 6px;
  font-size: 12px; line-height: 1.4; cursor: pointer;
}
.schedule-item:hover { opacity: 0.85; }
.schedule-item.class { background: #dbeafe; border-left: 3px solid #3b82f6; }
.schedule-item.tutor { background: #f3e8ff; border-left: 3px solid #8b5cf6; }
.schedule-item.meeting { background: #fef3c7; border-left: 3px solid #f59e0b; }
.schedule-item.off { background: #fef2f2; border-left: 3px solid #ef4444; text-align: center; color: #dc2626; font-weight: 600; }
.schedule-item.task { background: #e0e7ff; border-left: 3px solid #4f46e5; }
.schedule-item .time { font-weight: 700; font-size: 11px; color: var(--muted); }
.schedule-item .title { font-weight: 600; margin-top: 2px; }
.schedule-item .note { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #1f2937; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 移动端 ===== */
@media (max-width: 768px) {
  .sidebar { width: 88px; }
  .sidebar .brand h1, .sidebar-footer { display: none; }
  .sidebar .brand { justify-content: center; padding: 14px 0; }
  .nav-item { flex-direction: column; justify-content: center; padding: 8px 2px; gap: 2px; }
  .nav-item .label { flex-direction: column; gap: 2px; }
  .nav-item .txt { display: block; font-size: 10.5px; }
  .nav-item .ic { margin-right: 0; width: auto; }
  .nav-item .count { display: none; }
  .content { padding: 14px 12px; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; }
  .search-box { max-width: none; order: 2; }
  .task-actions { opacity: 1; }
  .review-grid { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .week-grid { grid-template-columns: repeat(7, 1fr); overflow-x: auto; }
  .day-col { min-height: 200px; min-width: 120px; }
  .schedule-item { padding: 5px 6px; font-size: 11px; }
}

/* ===== 首页课时不足提醒 ===== */
.home-alerts { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.alert-row {
  padding: 10px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; border: 1px solid;
}
.alert-row.warn { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.alert-row.danger { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }

/* ===== 学生卡片 ===== */
.student-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.student-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s;
}
.student-card:hover { box-shadow: var(--shadow); border-color: #dbe2ea; }
.student-card.warn { border-color: #fcd34d; }
.student-card.danger { border-color: #fca5a5; background: #fffbfb; }
.student-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.student-name { font-size: 16px; font-weight: 700; }
.student-alert {
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px;
  background: #fef2f2; color: #b91c1c;
}
.student-card.warn .student-alert { background: #fffbeb; color: #92400e; }
.student-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.student-stats { display: flex; gap: 12px; margin-top: 12px; }
.stat { flex: 1; text-align: center; }
.stat .num { font-size: 20px; font-weight: 800; color: var(--accent); }
.stat .num.alert { color: var(--danger); }
.stat .num.money { color: #dc2626; font-size: 16px; }
.stat .label { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ===== 学生详情 ===== */
.student-detail-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px;
}
.dstat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; text-align: center;
}
.dstat .num { font-size: 24px; font-weight: 800; color: var(--accent); }
.dstat .num.money { color: #dc2626; font-size: 18px; }
.dstat .label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dstat.alert { border-color: #fca5a5; }
.dstat.alert .num { color: var(--danger); }

/* 页签 */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 9px 18px; font-size: 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; user-select: none;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* 流水行 */
.tab-toolbar { margin-bottom: 14px; }
.inline-form {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px;
}
.inline-form .input { width: auto; flex: 1; min-width: 90px; }
.inline-form input[type="date"] { flex: 0 0 auto; }
.inline-form input[type="time"] { flex: 0 0 auto; width: 100px; }
.inline-form .select { width: auto; flex: 0 0 auto; }
.flow-row {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 14px; margin-bottom: 8px;
}
.flow-date { font-size: 12.5px; font-weight: 700; color: var(--accent); width: 92px; flex-shrink: 0; padding-top: 2px; }
.flow-body { flex: 1; min-width: 0; }
.flow-title { font-size: 14px; font-weight: 500; }
.flow-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* 移动端适配：标签页文字与流式记录 */
@media (max-width: 768px) {
  .student-detail-stats { grid-template-columns: repeat(2, 1fr); }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form .input, .inline-form .select { width: 100%; flex: none; }
  .flow-date { width: auto; min-width: 72px; }
  .student-grid { grid-template-columns: 1fr; }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .topbar-actions .button { flex: 0 0 auto; padding: 8px 12px; font-size: 12.5px; }
}
