/* 基础：重置、排版、焦点、顶栏、账号菜单、侧栏、全局搜索、页签、页面框架与断点（docs/reference/10 §3.6：≥1400 宽桌面 / ≤1200 侧栏图标栏 / ≤1050 窄桌面 / ≤760 手机）。 */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font: var(--fs-body)/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { margin: 0; font-size: var(--fs-h1); font-weight: 600; letter-spacing: -.01em; }
h2 { margin: 0; font-size: var(--fs-h2); font-weight: 600; }
h3 { margin: 0; font-size: var(--fs-h3); font-weight: 600; }
code { font-family: var(--mono); font-size: var(--fs-sub); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* 顶栏：左 wordmark + 「管理后台」小字，右 全局搜索 + 账号触发区（79 §3.3、§4：无面包屑、无环境胶囊） */
.topbar { height: var(--topbar-h); padding: 0 var(--sp-5); background: var(--surface); box-shadow: 0 1px 0 var(--border); display: flex; align-items: center; gap: var(--sp-3); position: sticky; top: 0; z-index: var(--z-topbar); }
.logo { width: 26px; height: 26px; flex: none; background: url(/brand/logo.svg) center / contain no-repeat; }
.brand { padding-left: var(--sp-3); border-left: 1px solid var(--border); color: var(--muted); font-weight: 500; font-size: var(--fs-sub); line-height: 1.2; white-space: nowrap; }
.spacer { flex: 1; }
/* 头像（docs/reference/10 §3.3.3）：尺寸 sm 24 / md 32（默认）/ lg 48 / xl 64；默认是首字，有图片时 img 盖在首字上，加载失败（.broken）退回首字。 */
.avatar { position: relative; width: 32px; height: 32px; flex: none; border-radius: 50%; background: linear-gradient(140deg, var(--brand-2), var(--brand)); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-sub); font-weight: 600; line-height: 1; }
.avatar.sm { width: 24px; height: 24px; font-size: var(--fs-xs); }
.avatar.md { width: 32px; height: 32px; font-size: var(--fs-sub); }
.avatar.lg { width: 48px; height: 48px; font-size: var(--fs-h2); }
.avatar.xl { width: 64px; height: 64px; font-size: var(--fs-h1); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.broken img { display: none; }
/* 在线圆点：右下角绿点，外圈用表面色描边与头像分开 */
.avatar.online::after { content: ''; position: absolute; right: 0; bottom: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--surface); }
.avatar.lg.online::after, .avatar.xl.online::after { width: 12px; height: 12px; }
/* 表格与列表里的头像：用淡底色区分，不抢视线 */
.avatar.t0 { background: var(--brand-bg); color: var(--brand); }
.avatar.t1 { background: var(--blue-bg); color: var(--blue); }
.avatar.t2 { background: var(--green-bg); color: var(--green); }
.avatar.t3 { background: var(--orange-bg); color: var(--orange); }
.avatar.t4 { background: var(--surface-2); color: var(--ink-2); }

/* 账号菜单（docs/reference/10 §3.3.3）：顶栏右侧触发区 + 固定定位的浮层，位置由 app.js 计算 */
.account { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; padding: var(--sp-1) var(--sp-3) var(--sp-1) var(--sp-1); border: none; border-radius: var(--r-ctl); background: none; color: var(--ink); cursor: pointer; text-align: left; }
.account:hover, .account[aria-expanded=true] { background: var(--hover); }
.account > svg { width: 14px; height: 14px; flex: none; color: var(--faint); transition: transform var(--dur); }
.account[aria-expanded=true] > svg { transform: rotate(180deg); }
.account .who { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.25; }
.account .who b { font-weight: 600; font-size: var(--fs-sub); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .who small { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.account-pop { position: fixed; z-index: var(--z-dp); width: 320px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); overflow: auto; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-pop); font-size: var(--fs-sub); }
.account-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); min-width: 0; }
.account-head > div { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-1); }
.account-head b { font-size: var(--fs-h3); font-weight: 600; overflow-wrap: anywhere; }
.account-head small { color: var(--muted); font-size: var(--fs-sub); overflow-wrap: anywhere; }
.account-rows { display: flex; flex-direction: column; gap: var(--sp-2); margin: 0; padding: 0 var(--sp-4) var(--sp-4); }
.account-rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); min-width: 0; }
.account-rows dt, .account-rows > div > :first-child { margin: 0; color: var(--muted); flex: none; }
.account-rows dd, .account-rows > div > :last-child { margin: 0; min-width: 0; text-align: right; overflow-wrap: anywhere; color: var(--ink-2); }
.account-pop hr, .account-sep { height: 0; margin: 0; border: none; border-top: 1px solid var(--border-soft); }
.account-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); }
.account-theme { flex: 1 0 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); color: var(--muted); }
.account-actions > .btn { flex: 1 0 100%; }
.account-foot { padding: var(--sp-2) var(--sp-4); color: var(--muted); font-size: var(--fs-xs); border-top: 1px solid var(--border-soft); }

/* 全局搜索（⌘K / Ctrl+K）：输入框 + 结果浮层 */
.gsearch { position: relative; width: 280px; flex: none; }
.gsearch input[type=search] { width: 100%; height: var(--ctl-h); padding: 0 52px 0 32px; background: var(--ground); border-color: var(--border); }
.gsearch input[type=search]::placeholder { color: var(--faint); }
.gsearch input[type=search]::-webkit-search-cancel-button { display: none; }
.gsearch .gs-icon { position: absolute; left: var(--sp-3); top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--faint); pointer-events: none; }
.gsearch kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: var(--fs-xs) var(--mono); color: var(--faint); border: 1px solid var(--border); border-radius: var(--r-tag); padding: 0 var(--sp-1); background: var(--surface); pointer-events: none; }
.gs-pop { position: absolute; top: calc(100% + var(--sp-2)); right: 0; width: 400px; max-width: calc(100vw - 32px); background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-pop); padding: var(--sp-1); z-index: var(--z-dp); display: flex; flex-direction: column; }
.gs-item { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2); border-radius: var(--r-ctl); color: var(--ink); cursor: pointer; min-width: 0; }
.gs-item:hover, .gs-item.act { background: var(--hover); color: var(--ink); }
.gs-item .gs-text { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.gs-item .gs-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-item .gs-text small { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-note { padding: var(--sp-2) var(--sp-3); color: var(--muted); font-size: var(--fs-sub); }
.gs-foot { padding: var(--sp-2) var(--sp-3) var(--sp-1); color: var(--faint); font-size: var(--fs-xs); border-top: 1px solid var(--border-soft); margin-top: var(--sp-1); }

/* 侧栏：5 个组，选中项是浮起的胶囊 */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
nav.side { width: var(--side-w); flex: none; padding: var(--sp-4) var(--sp-3); background: var(--side); box-shadow: 1px 0 0 var(--border); display: flex; flex-direction: column; gap: var(--sp-1); position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow: auto; }
nav.side .side-label { padding: 0 var(--sp-3) var(--sp-1); color: var(--faint); font-size: var(--fs-xs); letter-spacing: .06em; }
nav.side a { padding: var(--sp-2) var(--sp-3); border-radius: var(--r-ctl); color: var(--ink-2); display: flex; align-items: center; gap: var(--sp-3); position: relative; }
nav.side a > span:not(.count) { flex: 1; min-width: 0; }
nav.side a svg { width: 16px; height: 16px; flex: none; color: var(--faint); }
nav.side a:hover { background: var(--hover); color: var(--ink); }
nav.side a.active { background: var(--pill); color: var(--ink); font-weight: 600; box-shadow: var(--sh-1); }
nav.side a.active svg { color: var(--brand); }
/* 待处理数的红色小徽标（侧栏组链接与页签各一个） */
nav.side .count, .tabs .count { background: var(--red); color: var(--on-accent); border-radius: var(--r-pill); min-width: 20px; padding: 0 var(--sp-2); text-align: center; font-size: var(--fs-xs); font-weight: 600; line-height: 20px; }
.tabs .count { display: inline-block; margin-left: var(--sp-1); }
[data-pending-badge][hidden] { display: none; }

/* 侧栏底部的版本脚注：服务端版本 + 环境徽标（开发模式）。图标栏下隐藏，版本在账号菜单里也有一份 */
nav.side .side-foot { margin-top: auto; padding: var(--sp-3) var(--sp-3) 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); color: var(--muted); font-size: var(--fs-xs); }

/* 主区 */
main { flex: 1 1 auto; min-width: 0; padding: var(--sp-6) var(--sp-8); display: flex; flex-direction: column; gap: var(--sp-4); }
.page { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-3) var(--sp-4); }
.page-head .title { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3); }
.page-head .sub { color: var(--muted); font-size: var(--fs-sub); margin-top: var(--sp-1); max-width: 800px; }
.actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

/* 页签（组内页面切换与页内筛选共用，只有一种字号）：下划线 2px，宽度不够时横向滚动不换行 */
.tabs { display: flex; gap: var(--sp-6); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { padding: var(--sp-2) 2px var(--sp-3); border: none; border-bottom: 2px solid transparent; background: none; color: var(--muted); cursor: pointer; margin-bottom: -1px; white-space: nowrap; font-size: var(--fs-body); }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs a.on, .tabs button.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand); }

/* 1050–1200：侧栏收为 64px 图标栏（文字隐藏，a 的 title 给提示；待处理数变右上角小圆标） */
@media (max-width: 1200px) {
  nav.side { width: 64px; padding: var(--sp-4) var(--sp-2); align-items: center; }
  nav.side .side-label, nav.side .side-foot { display: none; }
  nav.side a { width: 44px; height: 44px; padding: 0; justify-content: center; }
  nav.side a > span:not(.count) { display: none; }
  nav.side a svg { width: 20px; height: 20px; }
  nav.side .count { position: absolute; top: 2px; right: 2px; min-width: 16px; padding: 0 var(--sp-1); line-height: 16px; }
}
/* 窄桌面 / 平板 */
@media (max-width: 1050px) {
  .gsearch { width: 200px; }
}
/* 手机：侧栏改为顶部横排（图标 + 文字），版本进账号菜单 */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  nav.side { width: auto; height: auto; position: static; flex-direction: row; align-items: stretch; overflow-x: auto; padding: var(--sp-2) var(--sp-3); box-shadow: 0 1px 0 var(--border); }
  nav.side a { width: auto; height: auto; padding: var(--sp-2) var(--sp-3); justify-content: flex-start; white-space: nowrap; }
  nav.side a > span:not(.count) { display: inline; flex: none; }
  nav.side a svg { width: 16px; height: 16px; }
  nav.side .count { position: static; min-width: 20px; padding: 0 var(--sp-2); line-height: 20px; }
  .topbar { padding: 0 var(--sp-4); gap: var(--sp-3); }
  .topbar .brand, .account .who, .account > svg { display: none; }
  .account { padding: var(--sp-1); }
  .gsearch { width: auto; flex: 1; min-width: 0; }
  .gsearch kbd { display: none; }
  main { padding: var(--sp-4); }
}
