:root {
  --bg: #0d1117;
  --bg-soft: #141a22;
  --card: #161d26;
  --card-hi: #1c2530;
  --line: #232c38;
  --text: #e6edf3;
  --text-dim: #93a1b1;
  --text-mute: #6b7a8c;
  --accent: #3fb6a8;
  --accent-dim: #2b7f76;
  --blue: #4a90d9;
  --amber: #d9a13f;
  --red: #e05c5c;
  --green: #46b17b;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(63, 182, 168, .14), transparent 70%),
    radial-gradient(700px 380px at 95% 0%, rgba(74, 144, 217, .10), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }
.muted { color: var(--text-mute); font-size: 12px; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 26px;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .2px; }
.brand .sub { margin: 2px 0 0; font-size: 12px; color: var(--text-mute); }

.dot-logo {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), #2f6f9c);
  box-shadow: 0 4px 14px rgba(63, 182, 168, .30);
  position: relative;
}
.dot-logo::after {
  content: "";
  position: absolute; inset: 9px;
  border-radius: 3px;
  background: #0d1117;
  opacity: .82;
}

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }

input, textarea {
  width: 100%;
  background: #0f151c;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(63, 182, 168, .12);
}
textarea { resize: vertical; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-hi);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { background: #23303d; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, #3fb6a8, #2f9488);
  border-color: #2f9488; color: #06201d; font-weight: 600;
}
.btn.primary:hover { background: linear-gradient(180deg, #4ac4b5, #34a094); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, .05); }
.btn.block { width: 100%; justify-content: center; }
.btn.tiny { padding: 4px 9px; font-size: 12px; border-radius: 7px; }

.hint { font-size: 11.5px; color: var(--text-mute); margin: 12px 0 0; line-height: 1.5; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  /* 粘性顶栏必须高于正文，否则列表滚动时会压在顶栏上方 */
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 17, 23, .96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.brand.small { margin: 0; }
.brand.small h1 { font-size: 15px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.spin {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(63, 182, 168, .28);
  border-top-color: var(--accent);
  display: none;
  animation: rotate .8s linear infinite;
}
.spin.on { display: inline-block; }
@keyframes rotate { to { transform: rotate(360deg); } }

.banner {
  position: relative; z-index: 1;
  margin: 14px 24px 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  background: rgba(217, 161, 63, .10);
  border: 1px solid rgba(217, 161, 63, .35);
  color: #e8c07a;
}
.banner.error {
  background: rgba(224, 92, 92, .10);
  border-color: rgba(224, 92, 92, .35);
  color: #f0a3a3;
}

main { position: relative; z-index: 0; padding: 18px 24px 48px; max-width: 1180px; margin: 0 auto; }

/* ---------------- 统计卡 ---------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font-size: 26px; font-weight: 650; line-height: 1.15; letter-spacing: .4px; }
.stat-label { font-size: 12px; color: var(--text-mute); }
.stat.warn .stat-num { color: var(--amber); }
.stat.danger .stat-num { color: var(--red); }

/* ---------------- 工具条 ---------------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.tabs { display: flex; gap: 6px; background: var(--card); padding: 4px; border-radius: 10px; border: 1px solid var(--line); }
.tab {
  border: 0; background: transparent; color: var(--text-dim);
  padding: 6px 13px; border-radius: 7px; font-size: 12.5px; cursor: pointer;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { background: #23303d; color: var(--text); }
.toolbar-right { display: flex; gap: 8px; align-items: center; }
.search { width: 200px; padding: 7px 11px; }

/* ---------------- 任务列表 ---------------- */
.table {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 172px 142px 72px 52px;
  gap: 12px;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.row:last-child { border-bottom: 0; }
.row { cursor: pointer; }
.row:hover { background: rgba(255, 255, 255, .035); }
.row::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--green); opacity: .8;
}
.row.u3::before { background: var(--red); }
.row.u24::before { background: #e0894f; }
.row.u72::before { background: var(--amber); }
.row.over::before { background: var(--red); }

.tag {
  font-size: 11.5px; padding: 3px 0; text-align: center; border-radius: 6px;
  background: rgba(74, 144, 217, .13); color: #8fc0ec; border: 1px solid rgba(74, 144, 217, .28);
}
.tag.exam { background: rgba(217, 161, 63, .13); color: #e6c083; border-color: rgba(217, 161, 63, .30); }

.row-main { min-width: 0; }
.row-title { font-size: 13.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-course { font-size: 12px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cell-time { font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.chip {
  display: inline-block; font-size: 12px; padding: 4px 9px; border-radius: 999px;
  background: rgba(70, 177, 123, .12); color: #7fd3a4; border: 1px solid rgba(70, 177, 123, .25);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chip.u72 { background: rgba(217, 161, 63, .12); color: #e6c083; border-color: rgba(217, 161, 63, .28); }
.chip.u24 { background: rgba(224, 137, 79, .13); color: #f0b083; border-color: rgba(224, 137, 79, .30); }
.chip.u3 { background: rgba(224, 92, 92, .14); color: #f0a3a3; border-color: rgba(224, 92, 92, .32); }
.chip.over { background: rgba(224, 92, 92, .18); color: #ffb3b3; border-color: rgba(224, 92, 92, .40); }

.status { font-size: 12px; color: var(--text-mute); text-align: right; }

.empty { padding: 34px 18px; text-align: center; color: var(--text-mute); font-size: 13px; }
.empty.small { padding: 20px 12px; font-size: 12.5px; }

/* ---------------- 面板 ---------------- */
.panels { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 16px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text-dim); letter-spacing: .3px; }
.panel-body { padding: 8px 16px 14px; max-height: 320px; overflow: auto; }

.ev { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed rgba(255, 255, 255, .05); font-size: 12.5px; }
.ev:last-child { border-bottom: 0; }
.ev-time { color: var(--text-mute); font-variant-numeric: tabular-nums; flex: 0 0 96px; font-size: 12px; }
.ev-kind { flex: 0 0 62px; font-size: 11.5px; }
.ev-kind.new { color: var(--blue); }
.ev-kind.due { color: var(--amber); }
.ev-kind.overdue { color: var(--red); }
.ev-text { min-width: 0; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.logs {
  margin: 0; padding: 12px 16px; max-height: 320px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.65; color: #9fb0c2; background: #0f151c; white-space: pre-wrap;
}

/* ---------------- 抽屉 ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .5);
  z-index: 40; backdrop-filter: blur(2px);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw;
  background: var(--bg-soft); border-left: 1px solid var(--line);
  z-index: 50; transform: translateX(102%); transition: transform .22s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 15px; }
.drawer-body { padding: 16px 18px 24px; overflow: auto; flex: 1; }
fieldset { border: 0; border-top: 1px solid var(--line); padding: 14px 0 4px; margin: 0 0 6px; }
fieldset:first-of-type { border-top: 0; padding-top: 0; }
legend { font-size: 12px; color: var(--accent); letter-spacing: .4px; padding: 0 0 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); margin: 4px 0 10px; }
.check input { width: auto; }
.drawer-foot {
  position: sticky; bottom: -24px; background: var(--bg-soft);
  padding: 14px 0 4px; display: flex; align-items: center; gap: 12px;
  border-top: 1px solid var(--line);
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #1e2833; border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 80; max-width: 84vw;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(224, 92, 92, .5); color: #f3b4b4; }
.toast.ok { border-color: rgba(70, 177, 123, .5); color: #9adcb6; }

@media (max-width: 880px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .row { grid-template-columns: 52px 1fr 96px; grid-auto-rows: auto; }
  .cell-time { display: none; }
  .status { display: none; }
  .search { width: 130px; }
  .topbar { padding: 12px 14px; }
  main { padding: 14px 14px 40px; }
}

/* ---------------- 连接诊断 ---------------- */
.diag {
  margin: 14px 0 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.diag-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.diag-head h2 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text-dim); }
.diag-body { padding: 6px 16px 12px; }
.dstep {
  display: grid; grid-template-columns: 22px 148px 1fr 54px;
  gap: 10px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px dashed rgba(255, 255, 255, .05);
  font-size: 12.5px;
}
.dstep:last-child { border-bottom: 0; }
.dstep .mark { font-weight: 700; }
.dstep.ok .mark { color: var(--green); }
.dstep.bad .mark { color: var(--red); }
.dstep .name { color: var(--text); }
.dstep .detail { color: var(--text-dim); word-break: break-all; }
.dstep .cost { color: var(--text-mute); text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- 行内操作按钮 ---------------- */
.row-act {
  justify-self: end;
  font-size: 11.5px; padding: 3px 8px; border-radius: 6px;
  background: transparent; border: 1px solid var(--line);
  color: var(--text-mute); cursor: pointer; font-family: inherit;
  white-space: nowrap;
}
.row-act:hover { color: var(--text); border-color: var(--text-mute); }
.row-act.restore { color: var(--accent); border-color: var(--accent-dim); }

/* ---------------- 作业详情抽屉 ---------------- */
.detail-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 94vw;
  background: var(--bg-soft); border-left: 1px solid var(--line);
  z-index: 50; transform: translateX(102%); transition: transform .22s ease;
  display: flex; flex-direction: column;
}
.detail-drawer.open { transform: translateX(0); }
.d-actions {
  display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line);
  background: var(--bg-soft); flex-wrap: wrap;
}
.d-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 14px; font-size: 12.5px; color: var(--text-dim); }
.d-meta b { color: var(--text); font-weight: 550; }
.d-sec { margin: 0 0 18px; }
.d-sec h3 {
  margin: 0 0 8px; font-size: 12px; color: var(--accent);
  letter-spacing: .4px; font-weight: 600;
}
.q {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; background: #121922;
}
.q-head { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-mute); margin-bottom: 6px; }
.q-stem { font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.q-opts { margin: 8px 0 0; padding-left: 4px; }
.q-opt { font-size: 12.5px; color: var(--text-dim); line-height: 1.7; }
.d-empty { font-size: 12.5px; color: var(--text-mute); padding: 10px 0; }
.d-attach { display: block; font-size: 12.5px; color: #8fc0ec; margin: 4px 0; text-decoration: none; word-break: break-all; }
.d-attach:hover { text-decoration: underline; }

@media (max-width: 880px) {
  .row { grid-template-columns: 52px minmax(0, 1fr) 96px 44px; }
  .row .cell-time, .row .status { display: none; }
  .detail-drawer { width: 100%; }
}
