:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #6b7688;
  --line: #e6eaf2;
  --brand: #2f6bff;
  --brand-dark: #1f4fd6;
  --brand-soft: #eaf0ff;
  --ok: #14a44d;
  --err: #dc3545;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 39, 51, 0.08);
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.6; -webkit-font-smoothing: antialiased;
}
code { font-family: var(--mono); }

/* 布局 */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 60px; }
.topbar-brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 9px 14px; border-radius: 10px; cursor: pointer; font-size: 14.5px; color: var(--muted); white-space: nowrap; }
.tab:hover { background: var(--brand-soft); color: var(--brand-dark); }
.tab.active { background: var(--brand); color: #fff; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.content { max-width: 1080px; margin: 0 auto; padding: 26px 20px 40px; min-height: 60vh; }
.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 20px; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; padding: 10px 16px; font-size: 14.5px; cursor: pointer; text-decoration: none; transition: .15s; font-weight: 600; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 36px 30px; }
.brand { text-align: center; margin-bottom: 26px; }
.brand-logo { font-size: 40px; }
.brand h1 { margin: 8px 0 4px; font-size: 22px; }
.brand-sub { margin: 0; color: var(--muted); font-size: 14px; }
.mock-note { background: #fff7e6; border: 1px solid #ffe1a6; color: #8a5b00; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 18px; }

/* 表单 */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, textarea, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14.5px; font-family: inherit; background: #fff; }
input:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.mono { font-family: var(--mono); font-size: 13px; line-height: 1.5; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

/* 卡片/公告 */
.announce { background: var(--brand-soft); color: var(--brand-dark); border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; font-size: 14px; }
.link-list { display: grid; gap: 14px; }
.link-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.link-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.link-name { font-weight: 700; font-size: 16px; }
.link-remark { color: var(--muted); font-size: 13px; }
.link-type { background: #eef2ff; color: var(--brand-dark); font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.link-body { background: #0f1626; color: #b8c4dc; border-radius: 10px; padding: 12px 14px; font-family: var(--mono); font-size: 12.5px; word-break: break-all; overflow: auto; }
.link-actions { margin-top: 12px; display: flex; gap: 8px; }

/* 空/加载 */
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin: 0 0 8px; }
.empty code { background: #f0f3fa; padding: 2px 6px; border-radius: 6px; }
.loading { text-align: center; color: var(--muted); padding: 40px; }

/* 绑定手机号 */
.bind-card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 16px; box-shadow: var(--shadow); }
.bind-card h3 { margin: 0 0 6px; }
.bind-card p { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

/* 登录身份卡 */
.id-card { margin-top: 22px; background: #fbfcfe; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.id-title { font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.id-card summary.id-title { margin-bottom: 0; cursor: pointer; list-style: none; }
.id-card[open] summary.id-title { margin-bottom: 10px; }
.id-card summary.id-title::-webkit-details-marker { display: none; }
.id-card summary.id-title::before { content: "▸ "; color: var(--muted); }
.id-card[open] summary.id-title::before { content: "▾ "; }
.id-rows { display: grid; gap: 6px; font-size: 13px; }
.id-rows > div { display: flex; align-items: center; gap: 8px; }
.id-rows span { color: var(--muted); width: 84px; flex: none; }
.id-rows code { background: #eef2fa; padding: 2px 8px; border-radius: 6px; word-break: break-all; }
.id-hint { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.id-hint code { background: #eef2fa; padding: 1px 5px; border-radius: 5px; }

/* 下载 */
.dl-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 40px; text-align: center; box-shadow: var(--shadow); max-width: 560px; margin: 20px auto; }
.dl-icon { font-size: 52px; }
.dl-card h2 { margin: 10px 0 6px; }
.dl-card p { color: var(--muted); }
.dl-hint { font-size: 13px; margin-top: 18px; }

/* 管理 */
.subtabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.subtab { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 14px; color: var(--muted); }
.subtab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.form-card h3 { margin: 0 0 14px; font-size: 16px; }
.hint { color: var(--muted); font-size: 13px; }

/* 通讯录选人 */
.picker { position: relative; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; background: #fbfcff; }
.picker-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; font-size: 14px; }
.picker input#f-search { width: 100%; }
.picker-results { position: absolute; left: 14px; right: 14px; top: 74px; max-height: 240px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 20; }
.picker-item { padding: 9px 12px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; }
.picker-item:hover { background: var(--brand-soft); }
.picker-dept { color: var(--muted); font-size: 12.5px; }
.picker-empty { padding: 12px; color: var(--muted); font-size: 13px; }
.picker-picked { margin-top: 8px; font-size: 14px; color: var(--brand-dark); background: var(--brand-soft); border-radius: 8px; padding: 6px 10px; }
.picker-picked .btn-link { color: var(--err); margin-left: 8px; }
.admin-actions { display: flex; gap: 10px; align-items: center; }
.table-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.acct-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13.5px; }
.acct-table th, .acct-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.acct-table th { color: var(--muted); font-weight: 600; }
.cell-link { font-family: var(--mono); font-size: 12px; color: var(--muted); max-width: 260px; word-break: break-all; }
.cell-ops { white-space: nowrap; }
.btn-link { background: none; border: 0; color: var(--brand); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.btn-link:hover { text-decoration: underline; }

/* Markdown */
.md { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 32px; box-shadow: var(--shadow); max-width: 820px; margin: 0 auto; }
.md .md-h { margin: 20px 0 8px; } .md h2.md-h:first-child { margin-top: 0; }
.md .md-p { margin: 8px 0; } .md .md-ul { margin: 8px 0; padding-left: 22px; } .md .md-ul li { margin: 4px 0; }
.md .md-quote { border-left: 4px solid var(--brand); background: var(--brand-soft); margin: 12px 0; padding: 8px 14px; border-radius: 0 8px 8px 0; color: var(--brand-dark); }
.md .md-code { background: #0f1626; color: #b8c4dc; padding: 14px; border-radius: 10px; overflow: auto; }
.md code:not(.md-code code) { background: #f0f3fa; padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.md a { color: var(--brand); }
.preview-card .md { padding: 16px; box-shadow: none; border: 1px solid var(--line); }

/* Toast */
#toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--err); }
.fatal { max-width: 520px; margin: 80px auto; text-align: center; color: var(--err); }
