:root {
  --ground: #f6f5fa; --paper: #ffffff; --ink: #1d1b26; --muted: #6b6880; --faint: #9a97ac;
  --line: #e6e3ef; --line2: #f0eef5; --soft: #f8f7fb;
  --accent: #6b5b95; --accent-ink: #4b3c7a; --accent-soft: #ede8f5; --accent-2: #9b8ec4;
  --vocab: #c2602a; --vocab-soft: #fcebdd; --vocab-ink: #8a3f12;
  --mock-soft: #e4eef9; --mock-ink: #23497e;
  --plan-soft: #dff1ee; --plan-ink: #1d5e59;
  --warn-soft: #fdf3ea; --warn-ink: #8a3f12;
  --bad: #9b2c1f; --bad-line: #e7c9c4; --good: #1d5e59;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif; }
a { color: #5a4a86; } a:hover { color: #3e3163; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: -0.01em; }
.lab { font-size: 12px; color: var(--muted); font-weight: 500; }
.err { color: var(--bad); }
.okmsg { color: var(--good); }

/* login */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.loginCard { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; width: 100%; max-width: 360px; text-align: center; }
.loginCard h1 { font-size: 18px; margin: 0 0 4px; }
.loginCard input { width: 100%; height: 42px; margin: 18px 0 12px; }

/* shell */
header.top { background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topin { max-width: 1360px; margin: 0 auto; padding: 12px 24px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand .dot { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.brand em { font-style: normal; color: var(--accent); }
.brand small { font-weight: 500; color: var(--muted); font-size: 13px; }
nav.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
nav.tabs a { padding: 7px 13px; border-radius: 10px; text-decoration: none; color: #4a4760; font-weight: 500; }
nav.tabs a.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
nav.tabs a.legacy { color: var(--muted); font-size: 13px; }
.topmeta { display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--muted); }
main { max-width: 1360px; margin: 0 auto; padding: 24px 24px 64px; display: flex; flex-direction: column; gap: 18px; }
.pagehead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.pagehead h1 { margin: 0; font-size: 24px; }
.pagehead p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

/* cards */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.cols { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; }
.kpi .v { font-size: 30px; margin-top: 4px; }
.mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.mini > div { background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.mini .v { font-size: 22px; }

/* table */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 11px 10px; border-bottom: 1px solid var(--line2); vertical-align: top; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #faf9fd; }
table.t th.sort { cursor: pointer; } table.t th.sort:hover { color: var(--ink); }

/* chips & buttons */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; margin: 0 4px 4px 0; background: #f1eff5; color: #4a4760; }
.c-vocab { background: var(--vocab-soft); color: var(--vocab-ink); }
.c-course { background: var(--accent-soft); color: var(--accent-ink); }
.c-mock, .c-ypl { background: var(--mock-soft); color: var(--mock-ink); }
.c-plan { background: var(--plan-soft); color: var(--plan-ink); }
.c-warn { background: var(--warn-soft); color: var(--warn-ink); }
.c-dead { background: #f1eff5; color: var(--faint); text-decoration: line-through; }
.c-good { background: var(--plan-soft); color: var(--plan-ink); }
.btn { height: 36px; padding: 0 14px; border-radius: 9px; border: 0; background: var(--accent); color: #fff; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: #fff; border: 1px solid #e0dcea; color: var(--accent-ink); font-weight: 500; }
.btn.danger { background: #fff; border: 1px solid var(--bad-line); color: var(--bad); font-weight: 500; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 6px 13px; border-radius: 999px; background: #fff; border: 1px solid #e0dcea; font-size: 13px; cursor: pointer; color: var(--ink); font: inherit; font-size: 13px; }
.pill.on { background: var(--accent-ink); color: #fff; border-color: var(--accent-ink); }

/* forms */
input, select, textarea { height: 38px; border: 1px solid #e0dcea; border-radius: 10px; padding: 0 10px; font: inherit; font-size: 13px; background: #fff; color: var(--ink); }
textarea { height: auto; padding: 8px 10px; min-height: 64px; resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); outline-offset: 0; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label.f { flex: 1 1 150px; }
.filters label.f.wide { flex: 2 1 260px; }
.check { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.check input { height: auto; }

/* bars */
.bars { display: grid; gap: 12px; align-items: end; border-bottom: 1px solid var(--line); height: 170px; padding: 0 6px; }
.bars .col { display: flex; gap: 4px; align-items: flex-end; justify-content: center; height: 100%; }
.bars .b { width: 24px; border-radius: 4px 4px 0 0; min-height: 2px; }
.barlabels { display: grid; gap: 12px; padding: 6px 6px 0; font-size: 12px; color: var(--muted); text-align: center; }
.hbar { height: 8px; background: var(--line2); border-radius: 4px; margin-top: 5px; }
.hbar > div { height: 8px; border-radius: 4px; background: var(--accent); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--sw); vertical-align: -1px; }

/* student detail */
.split { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.split > .l { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.split > .r { flex: 2 1 620px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
dl.kv { display: grid; grid-template-columns: 92px 1fr; gap: 7px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; word-break: break-all; }
.prow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line2); }
.prow:last-child { border-bottom: 0; }
.prow .acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.paybox { background: #fbfafe; border: 1px dashed #d9d3ea; border-radius: 12px; padding: 14px; margin-top: 8px; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.paybox label.f { flex: 1 1 120px; }
.tl { display: flex; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--line2); }
.tl .d { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.todo { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; background: var(--soft); border-radius: 12px; font-size: 13px; }
.todo.warn { background: var(--warn-soft); }
.spinner { width: 24px; height: 24px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 50; max-width: 90vw; }
.note { font-size: 12px; color: var(--muted); }

/* legacy (old dashboard look kept close) */
.legacy-detail { background: #fafbff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 8px; font-size: 12px; }
.legacy-detail pre { white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.tag { display: inline-block; background: #eee; border-radius: 6px; padding: 1px 7px; font-size: 11px; color: var(--muted); margin-right: 6px; }
tr.reg-urgent td { background: #fff3d6; }
.reg-badge { display: inline-block; background: #e35d6a; color: #fff; border-radius: 6px; padding: 1px 7px; font-size: 11px; font-weight: 700; margin-left: 6px; }

@media (max-width: 640px) {
  .topin, main { padding-left: 16px; padding-right: 16px; }
  .cols { grid-template-columns: 1fr; }
}
table.t th.r, table.t td.r { text-align: right; }
