/* ============ 致知录课管理系统 · 样式（浅色主题） ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f2f4f8; --card: #ffffff; --line: #e3e7ee; --line2: #d4dae4;
  --txt: #1f2733; --sub: #6b7686; --brand: #2f54eb; --brand-d: #1d39c4;
  --brand-bg: #eef1fe; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 12px;
}
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--txt); font-size: 14px; -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
[hidden], .hidden { display: none !important; }

/* ---------- 登录页 ---------- */
#loginView { position: fixed; inset: 0; z-index: 20; height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f6f7fb 55%, #e9f3ff 100%); }
.login-card { background: #fff; width: 400px; border-radius: 18px; padding: 38px 38px 30px;
  box-shadow: 0 18px 50px rgba(31, 45, 100, .12); text-align: center; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 14px; display:block;
  object-fit: contain; background: #fff; box-shadow: 0 2px 8px rgba(31,45,100,.08); }
.login-card h1 { font-size: 21px; letter-spacing: 1px; }
.login-sub { color: var(--sub); margin: 8px 0 22px; font-size: 12.5px; }
.login-card .field { text-align: left; margin-bottom: 14px; }
.login-card label { display: block; font-size: 12.5px; color: var(--sub); margin-bottom: 5px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--line2); border-radius: 8px; outline: none; }
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,84,235,.12); }
.login-hint { margin-top: 16px; font-size: 12px; color: #9aa3b2; }
.err { color: var(--bad); font-size: 12.5px; min-height: 18px; margin: 2px 0 6px; text-align: left; }
.btn { border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; transition: .15s; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.ghost { background: #fff; border: 1px solid var(--line2); color: var(--txt); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn.danger-ghost { background: #fff; border: 1px solid #f3c2c2; color: var(--bad); }
.btn.danger-ghost:hover { background: #fdeeee; }
.btn.block { width: 100%; padding: 11px; font-size: 15px; letter-spacing: 4px; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.mini { border: 1px solid var(--line2); background:#fff; color: var(--sub); border-radius: 6px;
  padding: 3px 8px; font-size: 12px; }
.mini:hover { color: var(--brand); border-color: var(--brand); }
.mini.danger:hover { color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 主布局 ---------- */
#mainView { display: flex; height: 100vh; }
#sidebar { width: 258px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display:block; object-fit: contain;
  background:#fff; flex-shrink:0; }
.brand-txt b { display:block; font-size: 15px; }
.brand-txt i { font-style: normal; color: var(--sub); font-size: 11px; }
.userbox { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-bg); color: var(--brand);
  display:flex; align-items:center; justify-content:center; font-weight: 700; flex-shrink:0; }
.user-txt { flex: 1; min-width: 0; }
.user-txt b { display:block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-txt span { font-size: 11px; color: var(--sub); }
#treeNav { flex: 1; overflow: auto; padding: 10px 8px; }
.tree-node { margin: 1px 0; }
.tree-row { display: flex; align-items: center; gap: 5px; padding: 6px 8px; border-radius: 8px;
  cursor: pointer; user-select: none; }
.tree-row:hover { background: #f5f7fb; }
.tree-row.sel { background: var(--brand-bg); color: var(--brand); font-weight: 600; }
.tree-row .caret { width: 14px; text-align: center; color: #9aa3b2; font-size: 11px; flex-shrink:0; transition: .12s; }
.tree-row .caret.open { transform: rotate(90deg); }
.tree-row .ico { flex-shrink: 0; font-size: 13px; }
.tree-row .nm { flex:1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-row .cnt { font-size: 11px; color: #9aa3b2; background: #f1f3f7; border-radius: 8px; padding: 0 6px; }
.tree-children { margin-left: 16px; border-left: 1px dashed var(--line2); padding-left: 6px; }
.ico-root{color:#2f54eb}.ico-school{color:#9333ea}.ico-grade{color:#0e9f6e}.ico-room{color:#d97706}

/* ---------- 内容区 ---------- */
#content { flex:1; display: flex; flex-direction: column; overflow: hidden; }
#topbar { display:flex; align-items:center; justify-content: space-between; gap: 10px; padding: 14px 22px 0; }
#crumb { font-size: 15px; font-weight: 600; }
#crumb .crumb-sub { font-weight: 400; color: var(--sub); font-size: 12.5px; margin-left: 8px; }
#nodeActions { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; padding: 10px 22px 0; border-bottom: 1px solid var(--line); margin-top: 6px; }
.tab { background: none; border: none; padding: 9px 18px; font-size: 14px; color: var(--sub);
  border-bottom: 2px solid transparent; }
.tab:hover { color: var(--txt); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tabpage { display: none; padding: 18px 22px 30px; overflow: auto; flex: 1; }
.tabpage.active { display: block; }

/* ---------- 卡片 / 统计 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h3 { font-size: 14px; margin-bottom: 12px; display:flex; align-items:center; justify-content: space-between; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat-card .lbl { color: var(--sub); font-size: 12.5px; }
.stat-card .num { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-card .num small { font-size: 13px; color: var(--sub); font-weight: 400; }
.stat-card.blue .num { color: var(--brand); } .stat-card.green .num { color: var(--ok); }
.stat-card.orange .num { color: var(--warn); } .stat-card.red .num { color: var(--bad); }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
@media (max-width: 1100px){ .grid2{grid-template-columns:1fr} .cards{grid-template-columns:repeat(2,1fr)} }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--sub); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line2);
  background: #fafbfd; white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: #fafbfe; }
.mono { font-variant-numeric: tabular-nums; font-family: Consolas, monospace; }
.tag { display:inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; }
.tag.on { background: #e7f6ec; color: #15803d; }
.tag.off { background: #fdecec; color: #b91c1c; }
.tag.main { background: var(--brand-bg); color: var(--brand); }
.tag.sub { background: #f1f5f9; color: #475569; }
.empty { text-align: center; color: #9aa3b2; padding: 34px 0; }
.node-info { display:flex; align-items:center; gap:12px; }
.node-info .big { width: 46px; height: 46px; border-radius: 12px; display:flex; align-items:center;
  justify-content:center; font-size: 20px; background: var(--brand-bg); color: var(--brand); font-weight:700; }
.pill-row { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.pill { background:#f5f7fb; border:1px solid var(--line); border-radius:8px; padding:8px 12px; font-size:12px; color:var(--sub); }
.pill b { display:block; font-size:15px; color: var(--txt); }

/* 树状层级列表（结构） */
.struct-row { display:flex; align-items:center; gap:8px; padding:9px 12px; border:1px solid var(--line);
  border-radius:10px; margin-bottom:8px; background:#fff; }
.struct-row .info { flex:1; min-width:0; }
.struct-row .info b { font-size:14px; }
.struct-row .info span { font-size:12px; color:var(--sub); margin-left:8px; }

/* ---------- 弹窗 ---------- */
#modalRoot { position: fixed; inset: 0; z-index: 50; display: none; }
.mask { position: absolute; inset: 0; background: rgba(20,26,40,.45); display:flex; align-items:center; justify-content:center; pointer-events: auto; }
.modal { width: 520px; max-width: calc(100vw - 40px); max-height: 86vh; overflow: auto; background:#fff;
  border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.modal.wide { width: 860px; }
.modal-head { display:flex; align-items:center; justify-content: space-between; padding: 16px 20px;
  border-bottom: 1px solid var(--line); font-size: 16px; font-weight: 600; position: sticky; top:0; background:#fff; }
.modal-head .x { border:none; background:none; font-size:20px; color:var(--sub); cursor:pointer; line-height:1; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display:flex; justify-content:flex-end; gap:10px;
  position: sticky; bottom:0; background:#fff; }
.f-row { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field2 { margin-bottom: 12px; }
.field2 label { display:block; font-size:12.5px; color:var(--sub); margin-bottom:5px; }
.field2 input, .field2 select, .field2 textarea { width:100%; padding: 8px 10px; border:1px solid var(--line2); border-radius:8px; outline:none; }
.field2 input:focus, .field2 select:focus, .field2 textarea:focus { border-color: var(--brand); box-shadow:0 0 0 3px rgba(47,84,235,.12); }
.field2 textarea { resize: vertical; min-height: 120px; }
.field2 .hint { font-size: 11px; color: #9aa3b2; margin-top: 4px; }
.opt-title { font-size: 12px; color: var(--sub); margin: 14px 0 8px; padding-top: 12px; border-top: 1px dashed var(--line2); }
.form-check { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--sub); }

/* ---------- Toast ---------- */
#toastRoot { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 99;
  display:flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 10px 18px; border-radius: 10px; font-size: 13.5px; color:#fff; box-shadow: 0 8px 24px rgba(0,0,0,.15);
  animation: pop .2s ease; max-width: 70vw; }
.toast.ok { background: var(--ok); } .toast.err { background: var(--bad); } .toast.info { background: #334155; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

.pager { display:flex; align-items:center; gap:10px; justify-content:flex-end; margin-top: 12px; font-size: 13px; color: var(--sub); }
.pager button { padding: 4px 10px; }
canvas#trendCanvas { width: 100%; height: 220px; }
.filters { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:12px; }
.filters input { padding:6px 10px; border:1px solid var(--line2); border-radius:8px; outline:none; }
