:root {
  --bg: #f4f3ee;
  --panel: #ffffff;
  --ink: #1b2330;
  --body: #3a4453;
  --muted: #6b7482;
  --line: #e6e3da;
  --line-strong: #cfcbbf;
  --accent: #17594a;
  --accent-dark: #114638;
  --accent-soft: #e2f0ea;
  --danger: #b0352a;
  --danger-soft: #fbe8e5;
  --warn: #946000;
  --warn-soft: #fbf0d9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 35, 48, .05), 0 4px 16px rgba(27, 35, 48, .04);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font: 15px/1.65 "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", -apple-system, sans-serif;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--ink); line-height: 1.3; margin: 0; letter-spacing: 0; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
p { margin: 0; }
.en { color: var(--muted); font-weight: 400; font-size: .82em; }

/* 顶部导航 */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 6px 20px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 16px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.nav a:hover { text-decoration: none; background: var(--bg); color: var(--ink); }
.nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav a.active .en { color: inherit; }
.who { color: var(--muted); font-size: 13px; display: flex; gap: 12px; align-items: center; }

main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; align-items: center; }
h1 + .meta { margin-top: 8px; }
.back { display: inline-block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.stack { display: grid; gap: 18px; min-width: 0; }
.spaced { margin-top: 14px; }

/* 面板与按钮 */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; min-width: 0; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-note { margin: -6px 0 14px; }
.count { color: var(--muted); font-weight: 400; font-size: 13px; }

button {
  font: inherit; font-size: 14px; cursor: pointer;
  padding: 7px 14px; min-height: 36px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink);
  transition: background .12s, border-color .12s;
}
.button { display: inline-block; font-size: 14px; line-height: 20px; padding: 7px 14px; min-height: 36px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); }
.button:hover { background: #faf9f5; text-decoration: none; }
button:hover { background: #faf9f5; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-dark); }
button.danger { color: var(--danger); border-color: #ecc9c4; }
button.wide { width: 100%; min-height: 42px; }
button.link { border: 0; background: none; padding: 2px 4px; min-height: 0; color: var(--muted); font-size: 13px; }
button.link:hover { color: var(--ink); text-decoration: underline; }
button.link.danger { color: var(--danger); }
button:disabled { opacity: .55; cursor: default; }

/* 标签 */
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; line-height: 1.7; background: #efede6; color: var(--muted); white-space: nowrap; }
.tag.good { background: var(--accent-soft); color: var(--accent); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--danger-soft); color: var(--danger); }
.tag + .tag { margin-left: 4px; }

/* 进度条 */
.progress { height: 7px; background: #ebe8df; border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.progress-line { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.progress-line .progress { flex: 1; min-width: 60px; }

/* 首页 */
.alerts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 28px; }
.alert-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.alert-list li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.alert-list a { min-width: 0; overflow-wrap: anywhere; }
.alert-list .when { flex: none; font-size: 12px; color: var(--muted); line-height: 1.9; }
.panel.overdue { border-top: 3px solid var(--danger); }
.panel.overdue h2 { color: var(--danger); }
.panel.upcoming { border-top: 3px solid #d9a441; }
.panel.upcoming h2 { color: var(--warn); }
.round { margin-bottom: 28px; }
.round-head { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; margin-bottom: 10px; padding: 0 4px; }
.college-list { display: grid; gap: 10px; }
.college-row {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 20px; color: inherit; box-shadow: var(--shadow);
  transition: border-color .12s, transform .12s;
}
.college-row:hover { text-decoration: none; border-color: var(--line-strong); transform: translateY(-1px); }
.college-name { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }

/* 大学详情：Todo / Finished 两栏 */
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.todo { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 7px; background: var(--panel); }
.todo + .todo { margin-top: 10px; }
.todo.finished { background: #faf9f5; }
.todo-title { display: flex; gap: 9px; align-items: flex-start; }
.todo-title input { margin-top: 4px; }
.todo-title strong { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; min-width: 0; }
.todo.finished strong { color: var(--muted); }
.todo-tools { display: flex; gap: 4px 8px; flex-wrap: wrap; align-items: center; }
.todo-tools select { padding: 2px 6px; min-height: 30px; width: auto; font-size: 13px; }

/* 文件 */
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.files li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.files a { overflow-wrap: anywhere; min-width: 0; }
.file-name { cursor: pointer; }
.file-download { font-size: 12px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--muted); background: var(--panel); white-space: nowrap; line-height: 20px; }
.file-download:hover { color: var(--ink); text-decoration: none; }

/* 拖放上传 */
.dropping { position: relative; outline: 2px dashed var(--accent); outline-offset: -2px; }
.dropping::after {
  content: attr(data-drop-hint); position: absolute; inset: 0; z-index: 3;
  display: grid; place-items: center; text-align: center; padding: 8px;
  background: rgba(226, 240, 234, .9); color: var(--accent); font-weight: 600;
  border-radius: inherit; pointer-events: none;
}

/* 预览窗口 */
dialog.viewer { width: min(1000px, calc(100vw - 32px)); height: calc(100vh - 32px); max-height: none; padding: 0; overflow: hidden; }
dialog.viewer[open] { display: flex; flex-direction: column; }
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.viewer-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.viewer-title strong { color: var(--ink); overflow-wrap: anywhere; min-width: 0; }
.viewer-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.viewer-zoom { min-width: 46px; text-align: center; font-size: 13px; color: var(--muted); }
.viewer-body { position: relative; flex: 1; min-height: 0; overflow: auto; background: #eeece5; }
.viewer-message { padding: 48px 20px; text-align: center; color: var(--muted); }
.viewer-tools[hidden] { display: none; }
.pdf-pages { padding: 16px; width: max-content; min-width: 100%; display: grid; gap: 12px; justify-items: center; }
.pdf-page { background: #fff; box-shadow: 0 1px 4px rgba(27, 35, 48, .18); }
.pdf-page canvas { display: block; width: 100%; height: 100%; }
.viewer-image { display: block; margin: 16px auto; }
.viewer-text { margin: 16px auto; padding: 24px 28px; max-width: 860px; min-height: calc(100% - 32px); background: var(--panel); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.7 Consolas, "Microsoft YaHei", monospace; }
.viewer-doc { margin: 16px auto; padding: 36px 44px; max-width: 860px; min-height: calc(100% - 32px); background: var(--panel); color: var(--ink); font-size: 100%; line-height: 1.75; }
.viewer-doc h2 { font-size: 1.6em; margin: .8em 0 .4em; }
.viewer-doc h3 { font-size: 1.3em; margin: .8em 0 .4em; }
.viewer-doc h4 { font-size: 1.1em; margin: .8em 0 .4em; }
.doc-p { margin: 0 0 .6em; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1em; }
.doc-list { padding-left: 1.4em; }
.doc-list::before { content: "•"; display: inline-block; width: 1.2em; margin-left: -1.2em; }
.doc-table { font-size: 1em; margin-bottom: 1em; }
.doc-table td { border: 1px solid var(--line-strong); padding: .4em .6em; }
.b { font-weight: 700; }
.i { font-style: italic; }
.u { text-decoration: underline; }

/* 工单 */
.ticket-row {
  display: flex; justify-content: space-between; gap: 14px; align-items: center;
  padding: 14px 20px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); color: inherit; margin-bottom: 10px; box-shadow: var(--shadow);
}
.ticket-row:hover { text-decoration: none; border-color: var(--line-strong); }
.ticket-row strong { color: var(--ink); overflow-wrap: anywhere; }
.panel .ticket-row { box-shadow: none; border-radius: 10px; padding: 12px 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select { width: auto; background: var(--panel); font-size: 14px; }
.comment { border-top: 1px solid var(--line); padding: 12px 0; display: grid; gap: 4px; }
.comment:first-of-type { border-top: 0; padding-top: 0; }
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 20px; margin: 0; }
.details dt { font-size: 12px; color: var(--muted); }
.details dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }

/* 私信 */
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
.badge[hidden] { display: none; }
.dm { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; height: calc(100vh - 200px); min-height: 440px; }
.dm-list { padding: 8px; overflow-y: auto; }
.dm-items { display: grid; gap: 2px; }
.dm-items .empty { padding: 12px; }
.dm-item { display: block; padding: 10px 12px; border-radius: 10px; color: inherit; }
.dm-item:hover { text-decoration: none; background: var(--bg); }
.dm-item.active { background: var(--accent-soft); }
.dm-item-top { display: flex; align-items: center; gap: 8px; }
.dm-item-top strong { color: var(--ink); font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.dm-item-top .badge { margin-left: auto; }
.dm-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-time { font-size: 11px; color: var(--muted); }
.dm-placeholder { display: grid; place-items: center; color: var(--muted); }
.panel.chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.chat-back { display: none; font-size: 13px; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; background: #fbfaf7; }
.chat-hint { text-align: center; margin: auto; }
.chat-row { display: flex; flex-direction: column; align-items: flex-start; max-width: 76%; }
.chat-row.mine { align-self: flex-end; align-items: flex-end; }
.chat-bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; color: var(--ink); min-width: 0; max-width: 100%; display: grid; gap: 6px; }
.chat-row.mine .chat-bubble { background: var(--accent-soft); border-color: #cfe4db; }
.chat-meta { font-size: 11px; color: var(--muted); margin-top: 2px; padding: 0 4px; }
.chat-image img { display: block; max-width: min(280px, 100%); max-height: 280px; border-radius: 8px; cursor: zoom-in; }
.chat-image .chat-file { margin-top: 6px; }
.chat-file { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.chat-file .file-name { overflow-wrap: anywhere; min-width: 0; }
.chat-composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--line); }
.chat-composer textarea { flex: 1; min-width: 0; min-height: 40px; height: 40px; max-height: 120px; resize: none; line-height: 1.4; }
.chat-composer button { flex: none; min-height: 40px; }
.chat-closed { padding: 14px 20px; border-top: 1px solid var(--line); }

/* 表单 */
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--body); }
input, select, textarea {
  font: inherit; font-size: 16px; width: 100%; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; color: var(--ink);
}
input[type="checkbox"] { width: 16px; height: 16px; padding: 0; flex: none; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
.form { display: grid; gap: 14px; }
.form-error { color: var(--danger); font-size: 13px; }
.form-error:empty { display: none; }
.form-buttons { display: flex; justify-content: flex-end; gap: 8px; }
.check-group { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px; max-height: 200px; overflow: auto; }

dialog {
  border: 0; border-radius: 16px; padding: 24px; width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); overflow: auto; color: var(--body);
  box-shadow: 0 16px 48px rgba(20, 25, 30, .25);
}
dialog::backdrop { background: rgba(20, 25, 30, .42); }
dialog h2 { margin-bottom: 14px; font-size: 18px; }
.pin-display {
  font: 700 34px/1.2 Consolas, "Courier New", monospace; letter-spacing: .14em;
  text-align: center; color: var(--accent); background: var(--accent-soft);
  border-radius: 12px; padding: 18px 8px; margin-bottom: 12px; user-select: all;
}

/* 登录 */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(900px 500px at 50% -10%, #dcebe4 0, var(--bg) 70%);
}
.login-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 32px 30px; box-shadow: 0 10px 40px rgba(27, 35, 48, .08); }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.login-mark {
  width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 14px;
  display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 24px; font-weight: 700;
}

/* 管理后台 */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; }
th, td { padding: 10px 14px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
td.nowrap { white-space: nowrap; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: transparent; border-color: transparent; color: var(--muted); }
.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tabs button.active .en { color: inherit; }
.tabs-full { background: #f1efe8; border-radius: 11px; padding: 4px; gap: 4px; }
.tabs-full button { flex: 1; min-width: 0; padding: 6px 8px; }
.tabs-full button.active { background: var(--panel); box-shadow: 0 1px 3px rgba(27, 35, 48, .1); }

/* 空状态：放在面板里时不靠 .panel 的内边距也不贴边 */
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
.empty-page { text-align: center; padding: 44px 20px; }
.empty-page p { color: var(--muted); }
.empty-page p + button, .empty-page p + a { margin-top: 14px; display: inline-block; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; }
#toast.error { background: var(--danger); }

@media (max-width: 720px) {
  .alerts, .board { grid-template-columns: 1fr; }
  .college-row { grid-template-columns: 1fr; gap: 8px; padding: 14px 16px; }
  .round-head { grid-template-columns: auto 1fr; }
  .round-head .round-deadline { grid-column: 1 / -1; }
  .topbar { position: static; }
  .topbar-inner { padding: 10px 16px; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; }
  .who .name { display: none; }
  main { padding: 18px 16px 48px; }
  .panel { padding: 16px; }
  .ticket-row { padding: 12px 16px; flex-wrap: wrap; }
  .login-card { padding: 26px 20px; }
  dialog.viewer { width: 100vw; max-width: 100vw; height: 100vh; border-radius: 0; }
  .viewer-doc, .viewer-text { margin: 0; padding: 20px 16px; min-height: 100%; }
  .dm { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .dm-placeholder { display: none; }
  .dm-open .dm-list, .dm-page-head { display: none; }
  .dm-open .chat { height: calc(100vh - 118px); min-height: 420px; }
  .nav a { padding: 6px 10px; }
  .nav .en { display: none; }
  .chat-back { display: inline; }
  .chat-head { padding: 12px 16px; }
  .chat-log { padding: 14px 12px; }
  .chat-row { max-width: 88%; }
  .chat-composer { padding: 10px; gap: 6px; }
  .chat-composer button { padding: 7px 10px; }
  button { min-height: 40px; }
  button.link { min-height: 0; padding: 4px 6px; }
}
