/* ============================================================
   个人家教管理系统 — 设计体系（教师端 / 学生端通用）
   设计语言：slate 灰色系 + 靛蓝主色，8px 间距基准
   ============================================================ */
:root {
  /* 颜色 */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-border: #c7d2fe;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #0f172a;
  --text-body: #334155;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --border: #e5e7eb;
  --border-soft: #eef0f3;

  --green: #16a34a;  --green-bg: #ecfdf3;
  --orange: #d97706; --orange-bg: #fffaeb;
  --gray: #64748b;   --gray-bg: #f1f5f9;
  --blue: #2563eb;   --blue-bg: #eff6ff;
  --red: #dc2626;    --red-bg: #fef2f2;

  /* 圆角分级 */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;

  /* 柔和多层阴影 */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 4px 8px rgba(15, 23, 42, .06), 0 16px 40px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
svg { flex-shrink: 0; vertical-align: -3px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.brand-logo {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--primary); color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .35);
}
.brand-text { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.3; }
.brand-text small { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; }

.sidebar nav { flex: 1; padding: 12px; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  min-height: 42px;
  padding: 9px 12px; margin-bottom: 2px;
  border-radius: var(--r-sm);
  color: var(--text-2); font-size: 14px; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.sidebar nav a:hover { background: var(--bg); color: var(--text); }
.sidebar nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.sidebar .side-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.side-user { font-size: 13px; color: var(--text-2); }
.copyright {
  padding: 0 18px 12px;
  font-size: 11px; color: var(--text-3);
  letter-spacing: .2px;
}
.side-foot a {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--text-3);
  transition: color .15s;
}
.side-foot a:hover { color: var(--red); }

.main { flex: 1; margin-left: 232px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: none;
  align-items: center; gap: 12px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
  padding: 10px 16px;
  position: sticky; top: 0; z-index: 30;
}
.menu-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border: 1px solid var(--border); background: #fff;
  border-radius: var(--r-sm); cursor: pointer; color: var(--text-body);
  transition: border-color .15s, color .15s;
}
.menu-btn:hover { border-color: var(--primary); color: var(--primary); }
.top-title { font-weight: 700; font-size: 16px; color: var(--text); }

.content { padding: 24px 28px 40px; max-width: 1180px; width: 100%; margin: 0 auto; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.page-head h1 { font-size: 21px; font-weight: 700; color: var(--text); letter-spacing: .2px; }
.page-head .sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.page-head > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* 统计卡片：图标 + 大数字 */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.stat-icon {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
}
.stat-icon svg { width: 21px; height: 21px; }
.stat-icon.ic-blue   { background: var(--blue-bg);   color: var(--blue); }
.stat-icon.ic-green  { background: var(--green-bg);  color: var(--green); }
.stat-icon.ic-orange { background: var(--orange-bg); color: var(--orange); }
.stat-card .label { color: var(--text-2); font-size: 12.5px; }
.stat-card .value {
  font-size: 24px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 1px;
}

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
th {
  color: var(--text-3); font-weight: 500; font-size: 12px;
  letter-spacing: .3px;
  background: #fafbfc;
}
thead tr th:first-child { border-top-left-radius: var(--r-sm); }
thead tr th:last-child { border-top-right-radius: var(--r-sm); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
td.wrap, th.wrap { white-space: normal; min-width: 150px; line-height: 1.55; }
td b { color: var(--text); font-weight: 600; }

/* ---------- 状态标签：小圆点 + 柔和底色 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.5;
}
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.tag-已完成, .tag-已批准, .tag-green { background: var(--green-bg); color: var(--green); }
.tag-请假, .tag-待审批, .tag-orange { background: var(--orange-bg); color: var(--orange); }
.tag-取消, .tag-gray { background: var(--gray-bg); color: var(--gray); }
.tag-待上课, .tag-blue { background: var(--blue-bg); color: var(--blue); }
.tag-已拒绝, .tag-red { background: var(--red-bg); color: var(--red); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px;
  padding: 7px 15px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500; font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn:focus-visible { outline: 2px solid var(--primary-border); outline-offset: 1px; }
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 3px rgba(79, 70, 229, .3); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text-body); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--red); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }

input:not([type]), input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 15px;
  border: 1.5px solid transparent;
  border-radius: 14px;
  font-size: 14px; font-family: inherit; color: var(--text);
  background: #f1f5f9;
  box-shadow: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
  appearance: none;
  -webkit-appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }

input:hover, select:hover, textarea:hover { background: #e8edf3; }

input:focus, select:focus, textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

input:disabled, select:disabled, textarea:disabled {
  background: #e2e8f0; color: var(--text-3); cursor: not-allowed;
}

/* 下拉框：自定义箭头，去掉浏览器默认样式 */
select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}
select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* 日期 / 时间选择器 */
input[type=date], input[type=time] { color-scheme: light; cursor: pointer; }
input[type=date]::-webkit-calendar-picker-indicator,
input[type=time]::-webkit-calendar-picker-indicator {
  opacity: .45; cursor: pointer; transition: opacity .15s;
}
input[type=date]:hover::-webkit-calendar-picker-indicator,
input[type=time]:hover::-webkit-calendar-picker-indicator { opacity: .8; }

/* 数字输入框：隐藏原生步进箭头，保持简洁 */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

textarea { resize: vertical; min-height: 76px; line-height: 1.6; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal-mask.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
  padding: 22px 24px;
  animation: modal-in .18s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 16px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.confirm-text { color: var(--text-body); line-height: 1.7; }

/* ---------- 提示 / 空状态 ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--text-3); padding: 40px 16px; font-size: 13.5px; text-align: center;
}
.empty-icon { color: #cbd5e1; display: flex; }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff;
  padding: 10px 20px; border-radius: var(--r-sm);
  font-size: 13.5px; z-index: 200;
  box-shadow: var(--shadow-lg);
  max-width: 90vw;
  animation: modal-in .18s ease;
}
.toast.error { background: var(--red); }

.muted { color: var(--text-3); font-size: 12.5px; }
.money { font-variant-numeric: tabular-nums; }
.text-danger { color: var(--red); font-weight: 600; }
.text-ok { color: var(--green); font-weight: 600; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .form-row { margin-bottom: 0; min-width: 136px; }

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(79, 70, 229, .16), transparent 60%),
    radial-gradient(500px 380px at 85% 85%, rgba(37, 99, 235, .12), transparent 60%),
    radial-gradient(400px 300px at 80% 15%, rgba(99, 102, 241, .10), transparent 60%),
    linear-gradient(160deg, #f8faff 0%, #eef1f8 100%);
}
.login-card {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  box-shadow: 0 2px 4px rgba(15, 23, 42, .04), 0 24px 64px rgba(30, 41, 82, .10);
  width: 100%; max-width: 400px;
  padding: 40px 36px 36px;
}
.login-card .logo {
  display: flex; align-items: center; justify-content: center;
  width: 60px; height: 60px; margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 18px rgba(79, 70, 229, .35);
}
.login-card .logo svg { width: 30px; height: 30px; }
.login-card h1 { text-align: center; font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--text-2); font-size: 13px; margin-bottom: 28px; }
.login-card .btn-block { min-height: 44px; font-size: 14.5px; }
.login-error {
  display: none;
  background: var(--red-bg); color: var(--red);
  padding: 10px 12px; border-radius: var(--r-sm);
  font-size: 13px; margin-bottom: 16px;
}
.login-copy { text-align: center; margin-top: 22px; font-size: 11.5px; color: var(--text-3); letter-spacing: .2px; }

/* ---------- 周课表格子 ---------- */
.week-table td, .week-table th { white-space: normal; vertical-align: top; min-width: 108px; }
.lesson-chip {
  display: block;
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: 6px 9px; margin-bottom: 6px;
  font-size: 12px; line-height: 1.5; color: var(--text-body);
}
.lesson-chip.dim { background: var(--gray-bg); border-left-color: var(--text-3); color: var(--text-2); }
.lesson-chip b { display: block; color: var(--text); font-weight: 600; }

/* ---------- 月历 ---------- */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.cal-title { font-size: 16px; font-weight: 700; color: var(--text); min-width: 110px; text-align: center; }
.cal-nav { display: flex; gap: 8px; align-items: center; }
.cal-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.cal-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { margin-bottom: 6px; }
.cal-head div { text-align: center; font-size: 12.5px; color: var(--text-3); font-weight: 500; padding: 4px 0; }

.cal-cell {
  min-height: 92px;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  padding: 6px 7px;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color .15s, box-shadow .15s;
}
.cal-cell:hover { border-color: var(--primary-border); box-shadow: var(--shadow-sm); }
.cal-out { background: transparent; border: none; box-shadow: none; }
.cal-today { border-color: var(--primary); background: var(--primary-soft); }
.cal-day { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.cal-today .cal-day {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff;
}
.cal-chips { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-chip {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; line-height: 1.4;
  padding: 2px 6px; border-radius: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-time { font-weight: 600; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.cal-label { overflow: hidden; text-overflow: ellipsis; }
.cal-chip.st-blue   { background: var(--blue-bg);   color: var(--blue); }
.cal-chip.st-green  { background: var(--green-bg);  color: var(--green); }
.cal-chip.st-orange { background: var(--orange-bg); color: var(--orange); }
.cal-chip.st-gray   { background: var(--gray-bg);   color: var(--gray); text-decoration: line-through; }
.cal-more { font-size: 11px; color: var(--text-3); padding-left: 4px; }

@media (max-width: 768px) {
  .cal-grid { gap: 4px; }
  .cal-cell { min-height: 64px; padding: 4px 5px; border-radius: 7px; }
  .cal-chip { font-size: 10.5px; padding: 1px 4px; gap: 3px; }
  .cal-time { display: none; } /* 小屏只显示标签 */
}

/* ---------- 课时评价星星 / 作业文件 ---------- */
.stars { display: flex; gap: 6px; font-size: 28px; line-height: 1; }
.stars .star { color: #e2e8f0; cursor: pointer; transition: color .12s, transform .12s; user-select: none; }
.stars .star:hover { transform: scale(1.15); }
.stars .star.on { color: #f59e0b; }
.stars-static { color: #f59e0b; font-size: 13px; letter-spacing: 1px; }
.stars-static .stars-off { color: #e2e8f0; }
.hw-files { margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.hw-file-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg); border-radius: 8px; padding: 7px 12px; font-size: 13px;
}

/* ============================================================
   响应式
   ≤1024px：侧边栏收为抽屉，顶栏出现
   ≤768px ：手机布局，触摸目标 ≥40px
   ============================================================ */
.mask { display: none; }

@media (max-width: 1024px) {
  .sidebar {
    width: 248px;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .mask.open {
    display: block; position: fixed; inset: 0;
    background: rgba(15, 23, 42, .4); z-index: 35;
  }
  .main { margin-left: 0; }
  .topbar { display: flex; }
  .content { padding: 20px 18px 36px; }
  .grid.cols-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  body { font-size: 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card { padding: 14px 16px; gap: 12px; }
  .stat-icon { width: 38px; height: 38px; border-radius: 10px; }
  .stat-card .value { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: var(--r-md); }
  .page-head h1 { font-size: 19px; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  /* 表格横向滚动 + 右侧渐变提示 */
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    background:
      linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)) left / 40px 100% no-repeat local,
      linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right / 40px 100% no-repeat local,
      linear-gradient(to right, rgba(15, 23, 42, .10), rgba(15, 23, 42, 0)) left / 14px 100% no-repeat scroll,
      linear-gradient(to left, rgba(15, 23, 42, .12), rgba(15, 23, 42, 0)) right / 14px 100% no-repeat scroll;
    background-color: #fff;
  }
  th, td { padding: 10px 12px; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px 14px 32px; }
}
