:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e2e5ea;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --ok: #1a8f4e;
  --warn: #b7791f;
  --bad: #c53030;
  --user: #e8f0fe;
  --assistant: #f1f3f5;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --panel: #1c2027; --line: #2b313a; --text: #e6e8eb; --muted: #9aa3ad;
    --accent: #5b8cff; --user: #24304a; --assistant: #242a33;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.danger { background: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-size: 18px; font-weight: 600; }
.brand .sub { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.connect { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.connect input { min-width: 220px; }
.status { color: var(--muted); font-size: 13px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }
.tabs { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--line); background: var(--panel); }
.tabs button { background: transparent; color: var(--muted); border-radius: 6px 6px 0 0; padding: 8px 14px; }
.tabs button.active { color: var(--text); background: var(--bg); border: 1px solid var(--line); border-bottom-color: var(--bg); margin-bottom: -1px; }
main { padding: 16px; }
.tab { display: none; }
.tab.active { display: block; }
#tab-sessions.active { display: grid; grid-template-columns: 320px 1fr; gap: 16px; min-height: calc(100vh - 140px); }
@media (max-width: 800px) { #tab-sessions.active { grid-template-columns: 1fr; } }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.list-pane { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.items { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; }
.items li { padding: 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.items li:hover { background: var(--bg); }
.items li.active { border-color: var(--accent); }
.items .meta { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.chat-pane { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-height: 60vh; }
.chat-head { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.transcript { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--user); }
.msg.assistant { align-self: flex-start; background: var(--assistant); }
.msg.event { align-self: stretch; max-width: none; font-family: var(--mono); font-size: 12px; color: var(--muted); background: transparent; padding: 2px 4px; }
.msg.error { align-self: stretch; max-width: none; color: var(--bad); }
.send { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.send textarea { flex: 1; resize: vertical; }
.pending { padding: 12px 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--warn) 12%, var(--panel)); }
.pending .card { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; padding: 8px 0; }
.pending .card + .card { border-top: 1px dashed var(--line); }
.pending code { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; }
.hidden { display: none !important; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table td.mono, .mono { font-family: var(--mono); font-size: 12px; }
.table td.data { max-width: 520px; white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: 12px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); }
.tag.ok { color: var(--ok); }
.tag.warn { color: var(--warn); }
.tag.bad { color: var(--bad); }
.report { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 12px; white-space: pre-wrap; font-family: var(--mono); font-size: 12px; }
.toast { position: fixed; z-index: 1100; right: 16px; bottom: 16px; background: var(--bad); color: #fff; padding: 10px 14px; border-radius: 8px; max-width: min(480px, calc(100vw - 32px)); }
.toast.info { background: var(--accent); }

/* 身份状态与窄屏表格：横向滚动留在表格容器内。 */
.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.login-error { color: var(--bad); padding: 8px 16px; }
#users-notice { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--warn); }
.table-scroll { max-width: 100%; overflow-x: auto; }
.tab { max-width: 100%; overflow-x: auto; }
#tab-sessions { overflow: visible; }
.chat-pane, .list-pane { min-width: 0; }
.chat-head { overflow-wrap: anywhere; }
#users-table td { min-width: 90px; }
#users-table td:first-child { overflow-wrap: anywhere; max-width: 260px; }
#users-table button { margin: 2px; white-space: nowrap; }
@media (max-width: 600px) {
  .connect { width: 100%; }
  .connect input { min-width: 0; width: 100%; }
  .tabs { flex-wrap: wrap; }
  .row input, .send textarea { min-width: 0; max-width: 100%; }
  .send { flex-wrap: wrap; }
  .chat-head { flex-wrap: wrap; }
  .msg { max-width: 100%; }
}

/* 员工默认通过对话使用，部署信息收在管理员入口。 */
.login-actions { margin: 0; }
.admin-connection { margin-left: auto; font-size: 13px; }
.admin-connection summary { color: var(--muted); cursor: pointer; }
.admin-connection[open] .connect { padding-top: 10px; }
#new-session { align-items: stretch; }
#new-package { min-width: 0; flex: 1; }
#new-session label { width: 100%; font-weight: 600; }
@media (max-width: 600px) { .connect input { min-width: 0; width: 100%; } }

.welcome { padding: 24px; border-bottom: 1px solid var(--line); }
.welcome h1 { font-size: 23px; line-height: 1.5; margin: 0 0 12px; }
.welcome li { margin: 8px 0; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; align-items: center; }
.suggestions span, .entry-footer { color: var(--muted); font-size: 12px; }
.entry-footer { padding: 12px 20px; text-align: right; }
.entry-footer a { color: var(--muted); }

/* 提醒属于个人工作，不要求选择业务或填写渠道密钥。 */
.notification-panel { position: fixed; z-index: 1100; top: 72px; right: 16px; width: min(400px, calc(100vw - 24px)); max-height: min(560px, calc(100dvh - 96px)); margin: 0; padding: 16px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: 0 12px 40px #0003; outline: none; }
.notification-panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex: none; }
.notification-panel-heading strong { font-size: 17px; }
#close-notifications { border: 0; border-radius: 50%; width: 36px; height: 36px; padding: 0; color: var(--muted); font-size: 24px; }
#close-notifications:hover { background: var(--assistant); }
#notification-status { color: var(--muted); font-size: 12px; margin: 4px 0 8px; flex: none; }
#notification-list { min-height: 0; max-height: none; margin: 0; overflow-y: auto; overscroll-behavior: contain; }
#notification-list .reminder-item:last-child { border-bottom: 0; }
#notification-list .meta { color: var(--muted); font-size: 12px; }
.notification-panel button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#reminders-panel > .row { justify-content: space-between; }
.reminder-items { list-style: none; padding: 0; max-height: 24rem; overflow: auto; }
.reminder-item { padding: .7rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.reminder-item button { margin: .4rem .4rem 0 0; }
.reminder-preview { margin: .6rem 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: .7rem; overflow-wrap: anywhere; }
.reminder-preview button { margin: .5rem .5rem 0 0; }
.reminder-preview label { display: block; }
.reminder-form { display: flex; flex-wrap: wrap; gap: .5rem; }
.reminder-form strong, .reminder-form p { flex-basis: 100%; }
.reminder-form input { min-width: 0; max-width: 100%; }

/* 功能是独立辅助入口，不占据对话侧栏。 */
.functions-intro h1 { margin: 0; font-size: 23px; }
.function-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 16px; }
.function-card { padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.function-card h2 { margin: 0; font-size: 18px; }
.function-card p { color: var(--muted); }
#reminder-module-host .reminder-preview { margin: 16px 0 0; background: var(--panel); }
.reminder-form label { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 100%; }
.reminder-form label.channel-choice { display: block; flex-basis: 100%; }

/* 新通知持续悬浮，不抢输入焦点，不依赖外部消息平台或系统通知授权。 */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.notification-alerts { position: fixed; z-index: 1000; top: 20px; right: 20px; width: min(380px, calc(100vw - 32px)); max-height: calc(100dvh - 100px); overflow-y: auto; padding: 4px; border-radius: 12px; }
#notification-alert-list { display: grid; gap: 12px; }
.notification-alert { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 16px; box-shadow: 0 6px 24px #0003; animation: notification-enter .18s ease-out; }
.notification-alert-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--accent); }
.notification-alert-close { background: transparent; color: var(--muted); font-size: 22px; line-height: 1; padding: 6px 8px; }
.notification-alert-content { font-size: 16px; font-weight: 500; margin: 10px 0; overflow-wrap: anywhere; white-space: pre-wrap; max-height: 7.5em; overflow-y: auto; }
.notification-alert .meta { font-size: 12px; color: var(--muted); }
.notification-alert-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.notification-alert-more { width: 100%; margin-top: 10px; padding: 10px; }
@keyframes notification-enter { from { transform: translateX(16px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .notification-alert { animation: none; } }
@media (max-width: 600px) { .notification-alerts { top: 12px; right: 12px; width: calc(100vw - 24px); max-height: min(60dvh, 480px); } }
