:root {
  --bg: #f6f7f5;
  --panel: #ffffff;
  --ink: #1c2321;
  --muted: #6b7672;
  --line: #e2e6e3;
  --brand: #0f6b52;
  --brand-2: #12856a;
  --brand-soft: #e7f3ee;
  --warn: #b45309;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 8px 24px rgba(16, 24, 20, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
code { background: #eef1ef; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 26px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfb 100%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 40px; height: 40px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 700; font-size: 19px; letter-spacing: 1px;
}
.topbar h1 { font-size: 17px; letter-spacing: .2px; }
.sub { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.pill {
  font-size: 12px; color: var(--brand); background: var(--brand-soft);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}

/* ---------------- 按钮 ---------------- */
button.primary, button.ghost, button.link, .chip {
  border-radius: 8px; border: 1px solid transparent; transition: .15s;
}
button.primary {
  background: var(--brand); color: #fff; padding: 8px 16px; font-weight: 500;
}
button.primary:hover { background: var(--brand-2); }
button.ghost {
  background: #fff; border-color: var(--line); padding: 7px 14px; color: #33403b;
}
button.ghost:hover { border-color: #c6d2cc; background: #fafcfb; }
button.ghost.wide { width: 100%; margin-top: 6px; }
button.link { background: none; color: var(--brand); padding: 0; text-decoration: underline; font-size: 13px; }
button.icon { background: none; border: 0; font-size: 16px; color: var(--muted); padding: 6px; }
.chip {
  background: #fff; border: 1px solid var(--line); padding: 2px 9px; font-size: 12px;
  color: #4a5551; border-radius: 999px;
}
.chip:hover { border-color: #b9c9c1; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------------- 提示条 ---------------- */
.banner {
  display: flex; gap: 14px; align-items: center; justify-content: center;
  background: #fff7e8; color: #7c4a03; border-bottom: 1px solid #f3dfb6;
  padding: 8px 16px; font-size: 13px;
}
.banner.warn { background: #fef2f2; color: #b42318; border-bottom-color: #fecaca; }

/* ---------------- 标签页 ---------------- */
.tabs {
  display: flex; gap: 4px; padding: 10px 26px 0;
  border-bottom: 1px solid var(--line); background: #fff;
}
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 9px 16px; color: var(--muted); font-size: 14px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

main { padding: 20px 26px 60px; max-width: 1280px; margin: 0 auto; }
.view { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------------- 搜索框 ---------------- */
.searchbox { position: relative; display: flex; gap: 10px; }
.searchbox input[type=search] {
  flex: 1; padding: 13px 16px; font-size: 15px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); outline: none;
}
.searchbox input[type=search]:focus { border-color: var(--brand-2); }
.searchbox button.primary { padding: 0 26px; font-size: 15px; }
.suggest {
  position: absolute; top: 52px; left: 0; right: 120px; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); overflow: hidden;
}
.suggest div { padding: 9px 14px; font-size: 14px; cursor: pointer; }
.suggest div:hover { background: var(--brand-soft); }

.hintline {
  display: flex; justify-content: space-between; align-items: center;
  margin: 14px 2px 12px; font-size: 13px; color: var(--muted);
}
.sort { display: flex; align-items: center; gap: 6px; }

/* ---------------- 布局 ---------------- */
.layout { display: grid; grid-template-columns: 232px 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .filters { order: 2; }
  main { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .tabs { padding: 8px 16px 0; }
}

.filters {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 10px; position: sticky; top: 78px;
}
.filter-block { margin-bottom: 14px; }
.filter-block h3 { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .5px; margin-bottom: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; margin: 4px 0; color: #3c4744; }

/* ---------------- 结果 ---------------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: .15s;
}
.item:hover { border-color: #bcd3c9; box-shadow: var(--shadow); transform: translateY(-1px); }
.item h3 { font-size: 15.5px; line-height: 1.5; margin-bottom: 4px; }
.item .meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.item .snippet { margin-top: 7px; font-size: 13.5px; color: #45504c; }
.tag {
  font-size: 11px; padding: 1px 7px; border-radius: 4px;
  background: #f1f4f2; color: #4a5551;
}
.tag.type { background: var(--brand-soft); color: var(--brand); }
.tag.att { background: #eef2ff; color: #3f51b5; }
.tag.att-hit { background: #fff1f0; color: #b42318; border: 1px solid #ffd6d3; }
.tag.demo { background: #fff4e5; color: var(--warn); }
mark { background: #fff1a8; color: inherit; padding: 0 1px; border-radius: 2px; }

.empty { padding: 40px 0; text-align: center; color: var(--muted); }

/* 文件库 */
.file-item { display: flex; gap: 12px; align-items: flex-start; cursor: default; }
.file-item:hover { transform: none; }
.file-ext {
  flex: none; width: 46px; text-align: center; padding: 5px 0; border-radius: 7px;
  background: var(--brand-soft); color: var(--brand); font-size: 11px;
  font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
}
.file-main { min-width: 0; }
.file-main h3 { margin: 0 0 3px; }
.file-main h3 a { color: var(--ink); text-decoration: none; }
.file-main h3 a:hover { color: var(--brand); text-decoration: underline; }
.file-src { color: var(--brand); text-decoration: none; }
.file-src:hover { text-decoration: underline; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pager button {
  min-width: 34px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; font-size: 13px;
}
.pager button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: .4; cursor: default; }

/* 跳页 */
.pager .jump {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 10px; font-size: 12.5px; color: var(--muted);
}
.pager .jump-input {
  width: 66px; padding: 5px 8px; border: 1px solid var(--line);
  border-radius: 8px; text-align: center; font-size: 13px; background: #fff;
}
.pager .jump-input:focus { border-color: var(--brand-2); outline: none; }
.pager .jump-go { padding: 5px 10px; font-size: 12.5px; }

/* ---------------- 问答 ---------------- */
.chat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 420px;
}
.chat-log { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
/* 机器人消息：气泡、引用、工具按钮纵向堆叠，不要挤到右侧 */
.msg.bot { flex-direction: column; align-items: flex-start; gap: 6px; }
.msg.bot > * { max-width: 86%; }
.bubble {
  max-width: 84%; padding: 11px 15px; border-radius: 12px; font-size: 14.5px;
  background: #f4f7f5; white-space: pre-wrap; word-break: break-word;
}
.msg.user .bubble { background: var(--brand); color: #fff; }
.msg.bot .bubble { background: #f7f9f8; border: 1px solid var(--line); }
/* 引用来源：跟在回答下方，横向换行排列 */
.cites {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 2px; padding: 8px 10px;
  background: #fff; border: 1px dashed #d9e4df; border-radius: 10px;
}
.cites::before {
  content: "资料来源"; flex: none; align-self: center;
  font-size: 11px; color: var(--muted); margin-right: 2px;
}
.cite {
  flex: none; max-width: 100%;
  font-size: 12px; background: #f6faf8; border: 1px solid #d7e3dd; color: var(--brand);
  padding: 3px 10px; border-radius: 999px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cite:hover { background: var(--brand-soft); }
.cite-date { opacity: .55; margin-left: 4px; font-size: 11px; }
.cite-src { margin-left: 5px; font-size: 11px; opacity: .8; }
.msg-tools { margin-top: 6px; }
.msg-tools .ghost { font-size: 12px; padding: 2px 9px; }
.chat-input { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.chat-actions { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.chat-actions .ghost, .chat-actions .primary { padding: 6px 12px; font-size: 13px; }
.chat-input textarea {
  flex: 1; resize: none; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; outline: none;
}
.chat-input textarea:focus { border-color: var(--brand-2); }
.typing::after { content: "▌"; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0; }

/* ---------------- 管理 ---------------- */
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .admin-grid { grid-template-columns: 1fr; } }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 9px;
}
.card.wide { grid-column: 1 / -1; }
.card h2 { font-size: 15px; margin-bottom: 2px; }
.card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #3c4744; }
.card input {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #fdfefd;
}
.card input:focus { border-color: var(--brand-2); }
.card input.tiny { width: 110px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.right { justify-content: flex-end; }
.logbox {
  background: #10201a; color: #c9e6d8; border-radius: 8px; padding: 10px 12px;
  font-size: 12px; line-height: 1.6; max-height: 170px; overflow: auto;
  white-space: pre-wrap; word-break: break-all; margin: 4px 0 0;
}
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: #f8faf9; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 19px; color: var(--brand); }
.stat span { font-size: 12px; color: var(--muted); }

/* 账号列表 */
.userlist { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.userrow {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fcfdfd;
}
.userrow .name { font-weight: 600; }
.userrow .role { font-size: 11px; padding: 1px 7px; border-radius: 4px; background: var(--brand-soft); color: var(--brand); }
.userrow .role.admin { background: #eef2ff; color: #3f51b5; }
.userrow .off { color: var(--danger); }
.userrow .spacer { margin-left: auto; }
.userrow button { font-size: 12px; padding: 2px 8px; }
.userrow button.danger { color: var(--danger); border-color: #f0c7c3; }
.userrow.editing { flex-wrap: wrap; background: #f8fbfa; }
.userrow .eu-name { width: 120px; }
.userrow .eu-pwd { width: 150px; }
.userrow .eu-quota { width: 110px; }
.userrow input, .userrow select { font-size: 12.5px; padding: 3px 7px; }
input.tiny-w { width: 140px; }
select.tiny { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.row.adduser { flex-wrap: wrap; }

/* AI 连接状态 */
.ai-status {
  display: flex; align-items: center; gap: 8px;
  margin: 2px 0 10px; padding: 8px 11px; font-size: 12.5px;
  background: #f8fbfa; border: 1px solid var(--line); border-radius: 9px;
  word-break: break-all;
}
.ai-status .dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none; background: #b9c6c0;
}
.ai-status .dot.ok { background: #1a9d6a; box-shadow: 0 0 0 3px #e3f5ec; }
.ai-status .dot.warn { background: #c98a12; box-shadow: 0 0 0 3px #fdf3de; }
.ai-status .dot.bad { background: #c8392f; box-shadow: 0 0 0 3px #fdeceb; }
label textarea {
  display: block; width: 100%; box-sizing: border-box; margin-top: 5px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 13px; line-height: 1.5; resize: vertical; background: #fff;
}
label textarea:focus { border-color: var(--brand-2); outline: none; }

/* ---------------- 抽屉 ---------------- */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(18, 26, 23, .32); z-index: 40;
  backdrop-filter: blur(1px);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 96vw); z-index: 50;
  background: #fff; display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(16, 24, 20, .16);
  animation: slide .22s ease;
}
@keyframes slide { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; justify-content: space-between; gap: 14px; align-items: flex-start;
  padding: 18px 22px 12px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 17px; line-height: 1.5; }
.drawer-head .meta { font-size: 12.5px; color: var(--muted); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.drawer-body { padding: 18px 22px 40px; overflow-y: auto; }
.content { font-size: 14.5px; line-height: 1.85; }
.content p { margin: 0 0 10px; }
.attachments { margin-top: 22px; }
.attachments h3, .related h3 { font-size: 13px; color: var(--muted); margin: 16px 0 8px; }
.att {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 9px; margin-bottom: 7px; background: #fcfdfd;
}
.att a { color: var(--brand); text-decoration: none; font-size: 13.5px; word-break: break-all; }
.att a:hover { text-decoration: underline; }
.att .size { margin-left: auto; font-size: 12px; color: var(--muted); flex: none; }
.att-name { font-size: 13.5px; word-break: break-all; }
.att .ghost { text-decoration: none; font-size: 12px; padding: 3px 9px; }
.file-actions { margin-top: 7px; }
.file-actions .ghost { text-decoration: none; font-size: 12px; padding: 3px 10px; }
.related a { display: block; font-size: 13.5px; color: #2c3b36; padding: 5px 0; text-decoration: none; }
.related a:hover { color: var(--brand); }

/* ---------------- 弹窗 / Toast ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(18, 26, 23, .38); z-index: 60;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; padding: 22px; width: min(380px, 100%);
  display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow);
}
.modal h2 { font-size: 16px; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.modal input { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; outline: none; }
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #1f2b27; color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; z-index: 80; box-shadow: var(--shadow);
}

/* ---------------- 附件预览 ---------------- */
.preview-modal {
  width: min(920px, 96vw); height: min(84vh, 940px);
  display: flex; flex-direction: column; padding: 0; gap: 0; overflow: hidden;
}
.preview-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.preview-head h3 { font-size: 14.5px; font-weight: 600; word-break: break-all; }
.preview-body { flex: 1; overflow: auto; padding: 16px 18px; background: #fbfcfb; }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.preview-body img { max-width: 100%; display: block; margin: 0 auto; }
.preview-body pre {
  white-space: pre-wrap; word-break: break-word; margin: 0;
  font: 13.5px/1.85 "PingFang SC", "Microsoft YaHei", monospace; color: #2c3b36;
}
.preview-foot { padding: 10px 18px; border-top: 1px solid var(--line); }
.preview-foot .ghost { text-decoration: none; }

/* ---------------- 移动端适配 ---------------- */
@media (max-width: 720px) {
  .tabs { overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .searchbox { flex-direction: column; }
  .searchbox button.primary { width: 100%; padding: 11px; }
  .topbar { gap: 8px; }
  .topbar h1 { font-size: 15px; }
  .sub { display: none; }
  .pill { display: none; }
  .drawer { width: 100vw; }
  .preview-modal { width: 100vw; height: 100%; border-radius: 0; }
  .preview-body { padding: 12px; }
  .chat { height: calc(100vh - 200px); }
  .chat-input textarea { font-size: 15px; }
  .admin-grid { grid-template-columns: 1fr; }
  .list .item { padding: 12px; }
  .hintline { flex-wrap: wrap; gap: 6px; }
  .att { flex-wrap: wrap; }
  .att .size { margin-left: 0; }
}

/* 使用日志 */
.logtable { display: flex; flex-direction: column; margin-top: 8px; max-height: 420px; overflow-y: auto; }
.logrow { display: flex; gap: 10px; align-items: baseline; font-size: 12.5px;
  padding: 6px 8px; border-bottom: 1px solid var(--line); }
.logrow:last-child { border-bottom: none; }
.log-time { color: var(--muted); width: 92px; flex: none; }
.log-user { width: 84px; flex: none; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.log-q { flex: 1; word-break: break-all; }
.log-meta { color: var(--muted); flex: none; }

/* 同步频率设置 */
.sched-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: 6px 0; font-size: 13px; }
.sched-row input.tiny { width: 68px; }
.sched-row .check { margin: 0; }

/* ================================================================
   日程页（月历 + 今日/本周时间轴 + 编辑/设置弹窗）
   复用上面的颜色变量与卡片风格，只新增 .cal-* / .agenda-* / .ag-* / .editor-*
   ================================================================ */

/* ---------------- 工具栏 ---------------- */
.agenda-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.agenda-toolbar .cal-nav { display: flex; align-items: center; gap: 6px; }
.agenda-toolbar h2 { font-size: 18px; min-width: 112px; text-align: center; }
.agenda-toolbar .cal-nav .icon { font-size: 20px; line-height: 1; padding: 2px 9px; }
.agenda-status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted);
  background: #f8fbfa; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; white-space: nowrap;
}
.agenda-status .dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none; background: #b9c6c0;
}
.agenda-status .dot.ok { background: #1a9d6a; box-shadow: 0 0 0 3px #e3f5ec; }
.agenda-status .dot.warn { background: #c98a12; box-shadow: 0 0 0 3px #fdf3de; }
.agenda-status .dot.bad { background: #c8392f; box-shadow: 0 0 0 3px #fdeceb; }
.agenda-status .muted { font-size: 12px; }

/* ---------------- 账户视图（管理员，列表模式） ---------------- */
.agenda-accounts {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 10px; min-width: 0;
  position: sticky; top: 12px;
}
.agenda-accounts.hidden { display: none; }
.agenda-accounts-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; padding: 0 6px 9px; border-bottom: 1px dashed var(--line);
}
.agenda-accounts-head strong { font-size: 13px; color: var(--ink); letter-spacing: .02em; }
.agenda-accounts-head .muted { font-size: 11.5px; }
.agenda-account-list { display: flex; flex-direction: column; gap: 2px; margin-top: 7px; max-height: 540px; overflow: auto; }
.agenda-account-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: transparent; border-radius: 9px;
  padding: 7px 7px; cursor: pointer; text-align: left; color: inherit;
  font: inherit;
}
.agenda-account-row:hover { background: #f3f8f5; }
.agenda-account-row.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.agenda-account-avatar {
  width: 27px; height: 27px; flex: none; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; background: #7f9f90;
}
.agenda-account-row:nth-child(3n+2) .agenda-account-avatar { background: #8a9f7f; }
.agenda-account-row:nth-child(3n+3) .agenda-account-avatar { background: #9a8fb0; }
.agenda-account-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.agenda-account-name { font-size: 12.8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-account-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-account-count {
  flex: none; font-size: 11.5px; color: var(--muted);
  background: #f4f6f5; border-radius: 999px; padding: 1px 7px; min-width: 28px; text-align: center;
}
.agenda-account-row.active .agenda-account-count { background: #fff; color: var(--brand); }

/* ---------------- 月历 ---------------- */
.agenda-wrap {
  display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  gap: 16px; align-items: start;
}
.agenda-wrap.has-accounts {
  grid-template-columns: 228px minmax(0, 1.12fr) minmax(0, 1fr);
}
.cal-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); min-width: 0;
}
.cal-weekdays, .cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px;
}
.cal-weekdays span {
  text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0;
}
.cal-grid { min-height: 320px; }
.cal-grid.loading { opacity: .45; }
.cal-cell {
  min-width: 0; min-height: 62px; padding: 4px 5px; margin: 0;
  background: #fbfcfb; border: 1px solid transparent; border-radius: 8px;
  display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  font: inherit; text-align: left; color: inherit; cursor: pointer;
  transition: .12s; overflow: hidden;
}
.cal-cell:hover { border-color: #b9c9c1; background: #fff; }
.cal-cell.other { opacity: .42; background: transparent; }
.cal-cell.sel { border-color: var(--brand); background: var(--brand-soft); }
.cal-cell.today .cal-day {
  background: var(--brand); color: #fff; border-radius: 50%;
}
.cal-cell.has-ddl { box-shadow: inset 0 -2px 0 #f0c7c3; }
.cal-day {
  width: 22px; height: 22px; flex: none; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 600;
}
.cal-marks { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; min-height: 8px; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-2); display: inline-block; }
.cal-dot.ddl { background: var(--danger); }
.cal-dot.important { background: var(--warn); }
.cal-more { font-size: 10px; color: var(--muted); }
.cal-title {
  font-size: 10.5px; line-height: 1.35; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.cal-legend {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--muted);
}
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------------- 右侧当天/本周列表 ---------------- */
.agenda-side {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); min-width: 0;
}
.agenda-side-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  flex-wrap: wrap; padding-bottom: 10px; margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.agenda-side-head h2 { font-size: 15px; }
.agenda-seg { display: flex; gap: 5px; }
.agenda-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 640px; overflow-y: auto; padding-right: 2px;
}
.ag-empty { padding: 26px 4px; text-align: center; color: var(--muted); font-size: 13px; }
.ag-daygroup { margin-top: 2px; }
.ag-daygroup-title {
  font-size: 12px; color: var(--muted); font-weight: 600; margin: 6px 0 6px;
  display: flex; align-items: center; gap: 6px;
}
.ag-daygroup-title .tag { background: var(--brand-soft); color: var(--brand); }
.ag-section-title {
  font-size: 12px; color: var(--muted); margin: 10px 0 2px;
  display: flex; align-items: center; gap: 6px;
}
.ag-section-title::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.ag-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: #fcfdfd; min-width: 0; transition: .12s;
}
.ag-row:hover { border-color: #bcd3c9; background: #fff; box-shadow: var(--shadow); }
.ag-row.done { opacity: .58; }
.ag-row.overdue { border-color: #f0c7c3; background: #fffafa; }
.ag-time {
  flex: none; width: 48px; text-align: right; font-size: 12px; line-height: 1.5;
  color: var(--brand); font-weight: 600; word-break: break-all; padding-top: 2px;
}
.ag-row.overdue .ag-time { color: var(--danger); }
.ag-main { flex: 1; min-width: 0; }
.ag-title {
  font-size: 14px; font-weight: 600; line-height: 1.45; word-break: break-word;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.ag-title .tag { font-weight: 500; }
.ag-meta {
  font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap;
  gap: 4px 8px; align-items: center; margin-top: 2px; word-break: break-word;
}
.ag-meta a { color: var(--brand); text-decoration: none; }
.ag-meta a:hover { text-decoration: underline; }
.ag-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.ag-note { font-size: 12.5px; color: #45504c; margin-top: 3px; word-break: break-word; }
.ag-actions {
  flex: none; display: flex; gap: 3px; align-items: flex-start;
  opacity: 0; transition: .12s;
}
.ag-row:hover .ag-actions, .ag-row:focus-within .ag-actions { opacity: 1; }
.ag-actions button { font-size: 11.5px; padding: 2px 7px; white-space: nowrap; }
.ag-actions button.danger { color: var(--danger); border-color: #f0c7c3; }
.ag-more { margin-top: 8px; }
.ag-more summary {
  cursor: pointer; font-size: 12.5px; color: var(--muted); padding: 4px 2px;
  user-select: none;
}
.ag-overdue-banner {
  font-size: 12.5px; color: #7c4a03; background: #fff7e8;
  border: 1px solid #f3dfb6; border-radius: 8px; padding: 7px 10px;
}

/* 日程条目上的标签（复用 .tag 基础样式） */
.tag.ddl { background: #fff1f0; color: var(--danger); border: 1px solid #ffd6d3; }
.tag.memo { background: #eef2ff; color: #3f51b5; }
.tag.repeat { background: #f3eefe; color: #6b46c1; }
.tag.important { background: #fff4e5; color: var(--warn); }
.tag.allday { background: var(--brand-soft); color: var(--brand); }
.tag.remind { background: #eef6f2; color: #2f6e57; }
.tag.account { background: #f0f4ff; color: #3f51b5; }
.tag.overdue { background: var(--danger); color: #fff; }
.tag.ok { background: var(--brand-soft); color: var(--brand); }
.tag.bad { background: #fff1f0; color: var(--danger); border: 1px solid #ffd6d3; }
.tag.warn { background: #fff7e8; color: var(--warn); }

/* ---------------- 日程编辑/设置弹窗 ---------------- */
.editor-modal {
  width: min(640px, 100%); max-height: min(90vh, 940px);
  padding: 0; gap: 0; overflow: hidden;
}
.editor-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); flex: none;
}
.editor-head h3 { font-size: 15px; }
.editor-body {
  padding: 14px 18px; overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 10px;
}
.editor-body label {
  display: flex; flex-direction: column; gap: 4px; font-size: 13px; min-width: 0;
}
.editor-body label.check, .editor-body label.editor-check {
  display: flex; flex-direction: row; align-items: center; gap: 6px; margin: 0;
  flex: none;
}
.editor-body label.check input[type=checkbox], .editor-body label.editor-check input[type=checkbox] {
  flex: none;
}
.editor-body label.inline-field {
  display: flex; flex-direction: row; align-items: center; gap: 5px; flex-wrap: wrap;
}
.editor-body input, .editor-body select, .editor-body textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  outline: none; background: #fdfefd; font-size: 13.5px; width: 100%; min-width: 0;
}
.editor-body input:focus, .editor-body select:focus, .editor-body textarea:focus {
  border-color: var(--brand-2);
}
.editor-body input[type=checkbox] { width: auto; }
.editor-body textarea { resize: vertical; line-height: 1.5; }
.editor-body input.tiny { width: 110px; flex: none; }
.modal select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; outline: none; }
.editor-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.editor-row > label { flex: 1 1 130px; }
.editor-row > label.editor-check { flex: 0 0 auto; }
.editor-block { display: flex; flex-direction: column; gap: 6px; }
.editor-block h4 { font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 2px 0 0; }
.remind-grid { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.remind-grid label {
  display: inline-flex; flex-direction: row; align-items: center; gap: 6px;
  font-size: 13px; flex: none;
}
.editor-body input[type=checkbox]:disabled { cursor: not-allowed; opacity: .5; }
.remind-grid label:has(input:disabled) { opacity: .55; }
.editor-source {
  font-size: 12.5px; color: var(--muted); background: #f8fbfa;
  border: 1px dashed var(--line); border-radius: 8px; padding: 7px 10px;
}
.editor-foot {
  padding: 12px 18px; border-top: 1px solid var(--line); flex: none;
  margin: 0; background: #fcfdfd;
}
.editor-foot .spacer { margin-left: auto; }
.editor-foot .danger { color: var(--danger); border-color: #f0c7c3; }
.editor-foot .primary:disabled { opacity: .55; cursor: default; }
#schRemindExtra { font-size: 12px; }

/* 抽屉里的「加入日程」 */
.drawer-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.drawer-actions .ghost { font-size: 12.5px; padding: 4px 11px; }

/* ---------------- 管理页：令牌 / 提醒任务 ---------------- */
.userrow.wrap { flex-wrap: wrap; }
.userrow .scopes {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.token-plain {
  background: #10201a; color: #c9e6d8; border-radius: 8px; padding: 10px 12px;
  font-size: 12.5px; word-break: break-all;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.token-plain .token-text { font-family: Consolas, "SFMono-Regular", monospace; }
.token-plain .muted { color: #9fc2b2; }
.token-plain button { font-size: 12px; padding: 3px 10px; }
#outboxList .userrow, #tokenList .userrow { align-items: flex-start; }
#outboxList .log-q { min-width: 0; }

/* ---------------- 日程页移动端适配 ---------------- */
@media (max-width: 1000px) {
  .agenda-wrap, .agenda-wrap.has-accounts { grid-template-columns: 1fr; }
  .agenda-accounts { position: static; }
  .agenda-account-list { flex-direction: row; flex-wrap: wrap; max-height: none; }
  .agenda-account-row { width: auto; min-width: 190px; flex: 1 1 190px; }
  .agenda-list { max-height: none; overflow: visible; }
}
@media (max-width: 720px) {
  .agenda-toolbar h2 { font-size: 16px; min-width: 92px; }
  .agenda-toolbar .row { width: 100%; justify-content: space-between; }
  .agenda-toolbar .row .primary { flex: none; }
  .cal-card { padding: 8px; }
  .cal-weekdays, .cal-grid { gap: 3px; }
  .cal-grid { min-height: 240px; }
  .cal-cell { min-height: 44px; padding: 2px 3px; gap: 1px; }
  .cal-day { width: 19px; height: 19px; font-size: 11.5px; }
  .cal-title { display: none; }
  .cal-legend { gap: 10px; font-size: 11.5px; }
  .agenda-side { padding: 12px; }
  .ag-time { width: 40px; font-size: 11.5px; }
  .ag-actions { opacity: 1; }
  .ag-row { flex-wrap: wrap; }
  .ag-actions { width: 100%; justify-content: flex-end; margin-top: 2px; }
  .editor-modal { max-height: 100%; border-radius: 0; width: 100vw; height: 100%; }
  .editor-body { padding: 12px 14px; }
  .editor-row > label { flex: 1 1 110px; }
  .editor-foot { padding: 10px 14px; }
  .agenda-status { font-size: 11.5px; padding: 3px 9px; }
}

.group-member-picker{display:flex;flex-wrap:wrap;gap:8px;max-height:140px;overflow:auto;padding:4px 0}
.group-member-picker label{display:inline-flex;flex-direction:row;align-items:center;gap:5px;padding:4px 8px;border:1px solid var(--line);border-radius:14px;font-size:12px}
.group-member-picker input{width:auto}
.group-admin-list,.batch-list,.attach-list{display:flex;flex-direction:column;gap:6px;margin:6px 0}
.group-admin-row,.batch-row,.attach-row{display:flex;align-items:center;gap:8px;padding:7px 9px;border:1px solid var(--line);border-radius:8px;font-size:12.5px}
.group-admin-row .grow,.batch-row .grow,.attach-row .grow{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.group-admin-row .muted,.batch-row .muted,.attach-row .muted{font-size:12px}
.attach-row a{color:var(--primary);text-decoration:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.editor-block input[type=file]{font-size:12px;padding:5px 0;border:none}
.tag.source-leader{background:#fff4e5;color:#b26a00;border-color:#f2d2a8}
.tag.source-self{background:#eef7ff;color:#2b6cb0;border-color:#c7e2f7}
.tag.attach{background:#f2f0ff;color:#5b4bb7;border-color:#d9d3f7}
