:root {
  --bg: #F5F2EC;
  --card: #FFFFFF;
  --ink: #26302A;
  --sub: #6F7871;
  --faint: #A9B0AA;
  --line: #E9E3D9;
  --hover: #F8F6F1;
  --primary: #5E8063;
  --primary-dark: #4A6A4F;
  --primary-soft: #E6EEE5;
  --accent: #C9826B;
  --amber: #B98A2E;
  --amber-soft: #F8EED9;
  --red: #BD5B54;
  --red-soft: #F7E3E1;
  --blue: #4F7EA8;
  --blue-soft: #E3EDF6;
  --side: #26302A;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(40, 50, 40, .04), 0 6px 24px rgba(40, 50, 40, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--sub); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
  font-weight: 500; white-space: nowrap; transition: all .15s;
}
.btn:hover { background: var(--hover); border-color: #DAD3C7; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: #EBC9C5; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0, 0, 0, .04); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; height: 44px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], input[type=tel], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; outline: none; transition: border .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(94, 128, 99, .14); }
input[type=color] { width: 48px; height: 38px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
label.f { display: block; }
label.f > span { display: block; font-size: 12.5px; color: var(--sub); margin-bottom: 6px; font-weight: 500; }
label.f > span i { color: var(--red); font-style: normal; margin-left: 2px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.preset { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px; }
.preset:hover, .preset.on { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 20% 10%, #E4ECE2 0, transparent 40%), radial-gradient(circle at 90% 90%, #F1E2D9 0, transparent 40%), var(--bg); }
.login-card { width: 100%; max-width: 360px; padding: 40px 32px 28px; background: var(--card); border-radius: 24px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { font-size: 22px; margin: 18px 0 4px; }
.login-card input { margin: 24px 0 8px; height: 44px; text-align: center; }
.login-card .err { color: var(--red); min-height: 20px; font-size: 13px; margin-bottom: 8px; }
.login-card .hint { color: var(--faint); font-size: 12px; margin: 16px 0 0; }
.logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center;
  box-shadow: 0 10px 24px rgba(47, 102, 66, .3); }
.logo.sm { width: 38px; height: 38px; font-size: 18px; border-radius: 12px; margin: 0; box-shadow: none; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.side { width: 220px; flex-shrink: 0; background: var(--side); color: #DCE3DD; display: flex; flex-direction: column; padding: 22px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-name { font-weight: 700; color: #fff; font-size: 15px; }
.brand-sub { font-size: 12px; color: #8E9A91; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #B8C3BB; transition: all .15s; }
.side nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.side nav a.on { background: rgba(255, 255, 255, .1); color: #fff; font-weight: 600; }
.side nav a.on .ic { color: #F3C58A; }
.ic { width: 18px; text-align: center; font-size: 15px; }
.logout { background: none; border: 0; color: #8E9A91; padding: 10px 12px; text-align: left; cursor: pointer; border-radius: 10px; }
.logout:hover { color: #fff; background: rgba(255, 255, 255, .05); }

.main { flex: 1; min-width: 0; padding: 28px 32px 48px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head h2 { margin: 0; font-size: 24px; letter-spacing: .5px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.panel h3 { margin: 0 0 16px; font-size: 15px; display: flex; align-items: center; justify-content: space-between; }
.panel h3 small { font-weight: 400; color: var(--faint); font-size: 12.5px; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-top: 18px; }

/* ---------- 概览 ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; right: -24px; top: -24px; width: 80px; height: 80px; border-radius: 50%; background: var(--c, var(--primary)); opacity: .08; }
.stat .k { font-size: 12.5px; color: var(--sub); }
.stat .v { font-size: 30px; font-weight: 700; margin-top: 4px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--faint); margin-top: 2px; }

.today-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.today-row:last-child { border-bottom: 0; }
.today-row .t { width: 92px; font-weight: 600; font-variant-numeric: tabular-nums; }
.today-row .t small { display: block; font-weight: 400; color: var(--faint); font-size: 12px; }
.today-row .c { flex: 1; min-width: 0; }
.today-row .c b { font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.meter { display: flex; align-items: center; gap: 8px; width: 160px; }
.meter .track { flex: 1; height: 6px; background: #F0ECE5; border-radius: 6px; overflow: hidden; }
.meter .fill { height: 100%; border-radius: 6px; }
.meter span { font-size: 12.5px; color: var(--sub); min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

.bars { display: flex; align-items: flex-end; gap: 12px; height: 180px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-col .b { width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, #8DAE90, var(--primary)); min-height: 4px; transition: height .4s; }
.bar-col.today .b { background: linear-gradient(180deg, #E0A48F, var(--accent)); }
.bar-col .n { font-size: 12px; font-weight: 600; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.bar-col .l { font-size: 12px; color: var(--faint); margin-top: 6px; }

.hrow { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.hrow .name { width: 88px; font-size: 13px; }
.hrow .track { flex: 1; height: 10px; border-radius: 10px; background: #F3F0EA; overflow: hidden; }
.hrow .fill { height: 100%; border-radius: 10px; }
.hrow .cnt { width: 36px; text-align: right; font-size: 12.5px; color: var(--sub); font-variant-numeric: tabular-nums; }

.alert-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.alert-row:last-child { border-bottom: 0; }
.alert-row:hover .nm { color: var(--primary); }
.alert-row .nm { flex: 1; font-weight: 500; }

/* ---------- 徽标 / 头像 ---------- */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge.green { background: var(--primary-soft); color: var(--primary); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gray { background: #EFECE6; color: var(--sub); }
.av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; flex-shrink: 0; font-size: 14px; }
.av.lg { width: 56px; height: 56px; font-size: 22px; }

/* ---------- 排课表 ---------- */
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-nav .range { min-width: 150px; text-align: center; font-weight: 600; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.day { background: rgba(255, 255, 255, .55); border-radius: var(--radius); min-height: 420px; display: flex; flex-direction: column; }
.day-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px; }
.day-head .w { font-weight: 600; }
.day-head .d { font-size: 12px; color: var(--faint); }
.day.today { background: #fff; box-shadow: var(--shadow); }
.day.today .w { color: var(--accent); }
.day-add { width: 26px; height: 26px; border-radius: 8px; border: 1px dashed #D3CBBE; background: none; color: var(--faint); cursor: pointer; line-height: 1; }
.day-add:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.day-body { padding: 0 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.blk { border-radius: 12px; padding: 9px 10px 9px 12px; cursor: pointer; border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 9%, #fff); transition: transform .12s, box-shadow .12s; }
.blk:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(40, 50, 40, .08); }
.blk .bt { font-size: 12px; color: var(--sub); font-variant-numeric: tabular-nums; }
.blk .bn { font-weight: 600; margin: 1px 0 2px; font-size: 13.5px; }
.blk .bm { display: flex; justify-content: space-between; font-size: 12px; color: var(--sub); }
.blk .bm b { color: var(--ink); font-weight: 600; }
.blk.full .bm b { color: var(--accent); }
.blk.past { opacity: .6; }
.blk.cancelled { opacity: .5; background: repeating-linear-gradient(-45deg, #fff, #fff 6px, #F4F1EC 6px, #F4F1EC 12px); border-left-color: #C9C3B8; }
.blk.cancelled .bn { text-decoration: line-through; }
.day-empty { color: var(--faint); font-size: 12px; text-align: center; padding: 20px 0; }

/* ---------- 表格 ---------- */
.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12.5px; color: var(--sub); font-weight: 500; background: #FBFAF7; position: sticky; top: 0; }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
td .who { display: flex; align-items: center; gap: 10px; }
td .ops { display: flex; gap: 6px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; }
.toolbar .grow { flex: 1; }
.count-tip { font-size: 12.5px; color: var(--faint); margin-left: auto; }

/* ---------- 卡片墙（课程/老师） ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.ccard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.ccard .top { padding: 20px; color: #fff; background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 70%, #000)); position: relative; }
.ccard .top .en { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; opacity: .8; }
.ccard .top .nm { font-size: 20px; font-weight: 700; margin-top: 2px; }
.ccard .body { padding: 16px 20px; flex: 1; }
.ccard .facts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ccard .desc { color: var(--sub); font-size: 13px; }
.ccard .foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #F2EFE9; color: var(--sub); font-size: 12px; margin: 0 6px 6px 0; }
.idots { display: inline-flex; gap: 3px; vertical-align: middle; }
.idots i { width: 7px; height: 7px; border-radius: 50%; background: #E2DED7; }
.idots i.on { background: var(--accent); }
.tcard { display: flex; gap: 16px; padding: 20px; }
.tcard .nm { font-size: 17px; font-weight: 700; }

/* ---------- 抽屉 ---------- */
.mask { position: fixed; inset: 0; background: rgba(30, 36, 32, .32); backdrop-filter: blur(2px); z-index: 40; animation: fade .2s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--bg); z-index: 50; transform: translateX(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0, 0, 0, .12); }
.drawer.open { transform: none; }
.dw-head { padding: 22px 24px 18px; background: var(--card); border-bottom: 1px solid var(--line); position: relative; }
.dw-head .close { position: absolute; right: 16px; top: 16px; }
.dw-title { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.dw-meta { color: var(--sub); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.dw-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.dw-body { flex: 1; overflow-y: auto; padding: 18px 24px 30px; }
.dw-sec { margin-bottom: 22px; }
.dw-sec h4 { margin: 0 0 10px; font-size: 13px; color: var(--sub); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.roster-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border-radius: 12px; margin-bottom: 8px; }
.roster-row.off { opacity: .5; }
.roster-row .info { flex: 1; min-width: 0; }
.roster-row .info b { font-weight: 600; }
.roster-row .info small { display: block; color: var(--faint); font-size: 12px; }
.roster-row .ops { display: flex; gap: 6px; }
.add-line { display: flex; gap: 8px; }
.add-line input { flex: 1; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 8px 12px; background: var(--card); border-radius: 12px; padding: 14px 16px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; }
.log { font-size: 13px; color: var(--sub); padding: 6px 0; border-bottom: 1px dashed var(--line); }
.log time { color: var(--faint); margin-right: 10px; font-variant-numeric: tabular-nums; }

/* 会员卡（详情里） */
.vcard { border-radius: 16px; padding: 18px 20px; color: #F4EFE6; background: linear-gradient(135deg, #2F3B32, #4A6450); position: relative; overflow: hidden; }
.vcard::after { content: ''; position: absolute; right: -50px; top: -60px; width: 160px; height: 160px; border-radius: 50%; border: 24px solid rgba(243, 197, 138, .08); }
.vcard .big { font-size: 34px; font-weight: 700; color: #F3C58A; font-variant-numeric: tabular-nums; }
.vcard.none { background: #ECE7DE; color: var(--sub); }
.vcard.bad { background: linear-gradient(135deg, #7A6B68, #A08A86); }

/* ---------- 弹窗 ---------- */
.modal-mask { display: grid; place-items: center; padding: 16px; z-index: 60; }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--card); border-radius: 20px; box-shadow: 0 30px 80px rgba(0, 0, 0, .2); animation: pop .22s cubic-bezier(.2, .8, .2, 1); }
.modal.sm { max-width: 400px; }
.md-head { padding: 22px 24px 4px; font-size: 18px; font-weight: 700; }
.md-body { padding: 16px 24px; }
.md-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 8px 24px 22px; }
.md-err { color: var(--red); font-size: 13px; min-height: 18px; padding: 0 24px; }

/* ---------- 提示 ---------- */
.toasts { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 10px 18px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); animation: drop .25s; font-weight: 500; }
.toast.err { background: var(--red); }

.empty-box { text-align: center; padding: 60px 0; color: var(--faint); }
.loading { padding: 60px 0; text-align: center; color: var(--faint); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } }

/* ---------- 窄屏 ---------- */
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .side { width: 100%; height: auto; position: sticky; top: 0; z-index: 30; flex-direction: row; align-items: center; padding: 10px 12px; gap: 8px; overflow-x: auto; }
  .brand { padding: 0 6px 0 0; }
  .brand > div:last-child, .logout { display: none; }
  .side nav { flex-direction: row; flex: none; }
  .side nav a { white-space: nowrap; padding: 8px 10px; }
  .side nav .ic { display: none; }
  .main { padding: 18px 16px 40px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .today-row .meter { display: none; }
  .today-row .t { width: 64px; }
}
.login-card .names { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.login-card .names.hidden { display: none; }
.login-card .nm { padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line, #e5e2dc); background: #fff; font-size: 14px; cursor: pointer; }
.login-card .nm.on { background: var(--ink, #2b2f2c); border-color: var(--ink, #2b2f2c); color: #fff; font-weight: 600; }
.login-card .names + input { margin-top: 16px; }
.whoami { font-size: 12.5px; color: var(--faint, #999); padding: 0 20px 8px; }
.ex-list { display: flex; flex-direction: column; gap: 10px; }
.ex { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid var(--line, #e5e2dc); border-radius: 14px; }
.ex b { display: block; font-size: 14.5px; }
.ex small { display: block; color: var(--faint, #999); font-size: 12.5px; margin-top: 3px; line-height: 1.5; }

/* ICP 备案号：登录页底部 + 侧栏底部 */
.icp { color: var(--faint); font-size: 12px; text-decoration: none; }
.icp:hover { text-decoration: underline; }
.login { position: relative; }
.login > .icp { position: absolute; left: 0; right: 0; bottom: 16px; text-align: center; }
.side > .icp { display: block; text-align: center; margin-top: 8px; }
