/* ===== 全局变量与重置 ===== */
:root {
  --primary: #4f8cff;
  --primary-dark: #3b6fd6;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ===== 通用组件 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border: none; border-radius: var(--radius-sm);
  background: #eef1f6; color: var(--text); cursor: pointer; font-weight: 500;
  transition: opacity .15s, transform .05s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-2); }
.btn-block { width: 100%; padding: 13px; font-size: 15px; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.form-control {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; outline: none; transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%239ca3af' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-confirmed { background: #dbeafe; color: #2563eb; }
.badge-completed { background: #d1fae5; color: #059669; }
.badge-absent { background: #fee2e2; color: #dc2626; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }
.badge-paid { background: #d1fae5; color: #059669; }
.badge-active { background: #d1fae5; color: #059669; }
.badge-exhausted { background: #f3f4f6; color: #6b7280; }

/* 管理端列表筛选条 + 已隐藏行置灰 */
.filter-row { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.section-h { font-size: 16px; font-weight: 700; margin: 24px 0 12px; padding-left: 10px; border-left: 4px solid var(--primary); }
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; color: #334155; user-select: none; }
.row-muted { opacity: .5; }
.row-muted td { background: #fafafa; }

.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-icon { font-size: 40px; margin-bottom: 10px; }

/* ===== Toast ===== */
#toast {
  position: fixed; left: 50%; top: 30%; transform: translateX(-50%);
  background: rgba(31,41,55,.92); color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; z-index: 9999; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 80%; text-align: center;
}
#toast.show { opacity: 1; }

/* ===== 学生端布局（移动优先） ===== */
.app {
  max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg);
  position: relative; padding-bottom: 62px;
}
.navbar {
  background: #fff; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; border-bottom: 1px solid var(--border);
}
.navbar .title { font-size: 16px; font-weight: 600; }
.navbar .nav-link { color: var(--primary); font-size: 14px; }
.page { padding: 14px; }
.page-np { padding: 0; }

.section-title { font-size: 15px; font-weight: 600; margin: 6px 2px 12px; display: flex; align-items: center; justify-content: space-between; }
.section-title a { font-size: 13px; color: var(--primary); font-weight: 400; }

/* 课程卡片 */
.course-card {
  background: var(--card); border-radius: var(--radius); padding: 15px; margin-bottom: 12px;
  box-shadow: var(--shadow); position: relative; overflow: hidden; border-left: 4px solid var(--primary);
}
.course-card .c-name { font-size: 16px; font-weight: 600; margin-bottom: 5px; }
.course-card .c-type { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 4px; background: #eef4ff; color: var(--primary); margin-bottom: 8px; }
.course-card .c-price { font-size: 18px; font-weight: 700; color: var(--danger); }
.course-card .c-price small { font-size: 12px; font-weight: 400; color: var(--text-3); }
.course-card .c-meta { color: var(--text-2); font-size: 12px; margin-top: 4px; }

/* 课包卡片 */
.enr-card { background: var(--card); border-radius: var(--radius); padding: 15px; margin-bottom: 12px; box-shadow: var(--shadow); }
.enr-card .e-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.enr-card .e-name { font-weight: 600; font-size: 15px; }
.enr-credit { display: flex; align-items: baseline; gap: 6px; margin: 8px 0; }
.enr-credit .num { font-size: 28px; font-weight: 700; color: var(--primary); }
.enr-credit .label { color: var(--text-2); font-size: 13px; }
.progress { height: 8px; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s; }

/* 列表项 */
.list-item { background: var(--card); border-radius: var(--radius); padding: 14px 15px; margin-bottom: 10px; box-shadow: var(--shadow); }
.list-item .li-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.list-item .li-title { font-weight: 600; font-size: 15px; }
.list-item .li-sub { color: var(--text-2); font-size: 12px; margin-top: 3px; }

/* 底部 Tab */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: #fff; border-top: 1px solid var(--border);
  display: flex; z-index: 100;
}
.tabbar a {
  flex: 1; text-align: center; padding: 9px 0 11px; color: var(--text-3); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar a .ic { font-size: 20px; }
.tabbar a.active { color: var(--primary); }

/* 支付页 */
.pay-card { background: #fff; border-radius: var(--radius); padding: 24px 18px; text-align: center; box-shadow: var(--shadow); }
.pay-amount { font-size: 36px; font-weight: 700; color: var(--text); margin: 14px 0; }
.pay-amount small { font-size: 16px; }

/* 支付方式选择 */
.pay-methods { display: flex; gap: 12px; }
.pay-method {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 8px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; cursor: pointer; transition: all .15s;
}
.pay-method .pm-icon { font-size: 20px; }
.pay-method .pm-name { font-weight: 600; color: var(--text); }
.pay-method.active { border-color: var(--primary); background: #eef4ff; }
.pay-method.active .pm-name { color: var(--primary-dark); }

/* 时段选择 */
.slot-item {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px 15px; margin-bottom: 9px; display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}
.slot-item:active { background: #f8faff; }
.slot-item.selected { border-color: var(--primary); background: #f0f6ff; }
.slot-item .s-time { font-weight: 600; }
.slot-item .s-meta { font-size: 12px; color: var(--text-2); }
.slot-item .s-cap { font-size: 12px; color: var(--text-3); }

/* ===== 管理端布局（PC 优先） ===== */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; background: #1e293b; color: #cbd5e1; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .sb-brand { padding: 20px 18px; font-size: 16px; font-weight: 700; color: #fff; border-bottom: 1px solid #334155; }
.sidebar a { display: block; padding: 12px 18px; color: #94a3b8; font-size: 14px; border-left: 3px solid transparent; }
.sidebar a:hover { background: #283548; color: #fff; }
.sidebar a.active { background: #283548; color: #fff; border-left-color: var(--primary); }
.sidebar .sb-logout { position: absolute; bottom: 0; width: 100%; }
/* 侧边栏分组（可折叠），减少类目数量、避免眼花 */
.sidebar details.sb-group > summary {
  display: block; padding: 12px 18px; color: #94a3b8; font-size: 14px;
  cursor: pointer; list-style: none; user-select: none; border-left: 3px solid transparent;
}
.sidebar details.sb-group > summary::-webkit-details-marker { display: none; }
.sidebar details.sb-group > summary::before { content: "\25B8  "; }
.sidebar details.sb-group[open] > summary::before { content: "\25BE  "; }
.sidebar details.sb-group > summary:hover { background: #283548; color: #fff; }
.sidebar details.sb-group[open] > summary { color: #fff; border-left-color: var(--primary); }
.sidebar .sb-group a { padding-left: 36px; font-size: 13px; }
.admin-content { flex: 1; padding: 26px 32px; overflow-x: auto; }
.admin-content h1 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-card .s-label { color: var(--text-2); font-size: 13px; margin-bottom: 8px; }
.stat-card .s-value { font-size: 26px; font-weight: 700; }
.stat-card .s-value.primary { color: var(--primary); }
.stat-card .s-value.success { color: var(--success); }
.stat-card .s-value.warning { color: var(--warning); }
.stat-card .s-value.danger { color: var(--danger); }

/* 表格 */
.table-wrap { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { background: #f8fafc; text-align: left; padding: 11px 14px; color: var(--text-2); font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.data td { padding: 11px 14px; border-bottom: 1px solid #f3f4f6; white-space: nowrap; }
table.data tr:hover td { background: #fafbfc; }
table.data tr:last-child td { border-bottom: none; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; display: none; align-items: center; justify-content: center; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius); padding: 22px; width: 90%; max-width: 420px; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.modal .modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* 工具类 */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.text-bold { font-weight: 600; }
.hidden { display: none; }

/* 登录页 */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #4f8cff 0%, #6d5dd6 100%); padding: 20px; }
.auth-card { background: #fff; border-radius: 16px; padding: 30px 24px; width: 100%; max-width: 380px; box-shadow: 0 12px 40px rgba(0,0,0,.15); }
.auth-card .ac-title { text-align: center; font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.auth-card .ac-sub { text-align: center; color: var(--text-2); font-size: 13px; margin-bottom: 24px; }
.auth-card .ac-switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-2); }
.auth-card .ac-switch a { color: var(--primary); }

.admin-auth { background: linear-gradient(135deg, #1e293b 0%, #334155 100%); }
.admin-auth .auth-card { max-width: 360px; }
a.course-card { display: block; color: inherit; }
a.list-item { display: block; color: inherit; }
