/* ============ 关系图谱 · 样式 ============ */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e6e9ee;
  --line-strong: #d6dae1;
  --text: #14171f;
  --text-2: #4b5563;
  --muted: #8b93a1;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --danger: #e0453c;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .07), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-lg: 0 18px 44px rgba(16, 24, 40, .14), 0 2px 8px rgba(16, 24, 40, .06);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

#app { display: flex; height: 100vh; width: 100vw; }

/* ---------------- 侧边栏 ---------------- */
.sidebar {
  width: 272px;
  flex: 0 0 272px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 0 0;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 18px 16px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(140deg, #5b53f0, #7d5bf5);
  color: #fff; font-size: 17px; font-weight: 600;
  display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(91, 83, 240, .28);
  flex: 0 0 36px;
}
.brand-text h1 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.brand-text p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }

.search-box {
  position: relative;
  margin: 0 16px 16px;
  display: flex; align-items: center;
}
.search-box input {
  width: 100%;
  height: 34px;
  padding: 0 30px 0 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fafbfc;
  font-size: 12.5px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.search-box input:focus {
  border-color: #c3c7f5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .08);
}
.search-icon {
  position: absolute; left: 10px; width: 14px; height: 14px;
  color: var(--muted); pointer-events: none;
}
.clear-x {
  position: absolute; right: 6px;
  width: 20px; height: 20px; border: 0; border-radius: 50%;
  background: #eceef2; color: var(--text-2);
  font-size: 13px; line-height: 1;
  display: grid; place-items: center;
}
.clear-x:hover { background: #e0e3e9; }

.section-title {
  display: flex; align-items: center; gap: 6px;
  padding: 0 18px 7px;
  font-size: 11px; font-weight: 600; letter-spacing: .6px;
  color: var(--muted); text-transform: uppercase;
}
.section-title .count {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0;
  background: #f0f2f5; color: var(--text-2);
  padding: 1px 6px; border-radius: 20px;
}

.people-list {
  overflow-y: auto;
  padding: 0 10px 10px;
  flex: 1 1 auto;
  min-height: 80px;
}
.people-list::-webkit-scrollbar { width: 8px; }
.people-list::-webkit-scrollbar-thumb { background: #e3e6eb; border-radius: 8px; }

.person-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 8px;
  cursor: pointer; user-select: none;
  transition: background .12s;
}
.person-item:hover { background: #f6f7f9; }
.person-item.active { background: var(--accent-soft); }
.person-item .p-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; flex: 0 0 24px;
}
.person-item .p-name {
  font-size: 12.5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1 1 auto;
}
.person-item .p-deg {
  font-size: 10.5px; color: var(--muted);
  background: #f2f4f7; border-radius: 20px; padding: 1px 6px;
}

.legend { padding: 0 16px 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.legend-item {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--text-2);
  background: #fafbfc; border: 1px solid var(--line);
  padding: 3px 8px 3px 6px; border-radius: 20px;
  cursor: pointer; transition: all .13s;
}
.legend-item:hover { border-color: var(--line-strong); background: #fff; }
.legend-item.off { opacity: .35; }
.legend-item .swatch { width: 14px; height: 0; border-top-width: 2px; border-top-style: solid; border-radius: 2px; }
.legend-item .lbl { line-height: 1; }
.legend-item .lg-count { font-size: 10px; color: var(--muted); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--muted);
}
.link-btn {
  border: 0; background: none; color: var(--accent);
  font-size: 11.5px; padding: 2px 0;
}
.link-btn:hover { text-decoration: underline; }

/* ---------------- 画布 ---------------- */
main { position: relative; flex: 1 1 auto; overflow: hidden; }

#canvas {
  width: 100%; height: 100%; display: block;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, #dbdfe6 1px, transparent 0);
  background-size: 22px 22px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#canvas.panning { cursor: grabbing; }
body.link-mode #canvas { cursor: crosshair; }

/* 边 */
.edge { transition: opacity .18s ease; }
.edge .edge-hit { stroke: transparent; stroke-width: 16; fill: none; cursor: pointer; }
.edge .edge-path { fill: none; stroke-linecap: round; transition: stroke-width .12s; }
.edge .edge-label-bg { fill: #fff; stroke-width: 1; }
.edge .edge-label-text {
  font-size: 10.5px; font-weight: 500; text-anchor: middle;
  dominant-baseline: middle; pointer-events: none; user-select: none;
}
.edge:hover .edge-path { stroke-width: 3.4; }
.edge.dim { opacity: .1; }
.edge.dim .edge-label-bg { opacity: 0; }
.edge.dim .edge-label-text { opacity: 0; }
.edge.active .edge-path { stroke-width: 3; }
.edge.active .edge-label-text { font-weight: 600; }
.edge.link-preview { pointer-events: none; }
.edge.link-preview .edge-path { stroke-dasharray: 5 5; opacity: .9; }

/* 节点 */
.node { cursor: grab; transition: opacity .18s ease; }
.node.dragging { cursor: grabbing; }
.node .halo { fill: none; stroke: transparent; stroke-width: 2; transition: stroke .15s; }
.node .disc { transition: stroke .15s, stroke-width .15s, filter .15s; }
.node .initial {
  font-size: 15px; font-weight: 600; text-anchor: middle;
  dominant-baseline: central; pointer-events: none; user-select: none;
}
.node .nlabel {
  font-size: 11.5px; font-weight: 500; text-anchor: middle;
  fill: var(--text-2); pointer-events: none; user-select: none;
}
.node .nlabel-bg { fill: var(--bg); opacity: .82; pointer-events: none; }
.node .handle {
  fill: #fff; stroke: var(--accent); stroke-width: 1.6;
  opacity: 0; cursor: crosshair; transition: opacity .15s, r .12s;
}
.node .handle-plus {
  font-size: 9px; font-weight: 700; fill: var(--accent);
  text-anchor: middle; dominant-baseline: central;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.node:hover .handle, .node:hover .handle-plus { opacity: 1; }
.node .handle:hover { r: 8; }
.node:hover .disc { filter: drop-shadow(0 3px 8px rgba(16, 24, 40, .13)); }
.node.dim { opacity: .12; }
.node.dim .nlabel-bg { opacity: .5; }
.node.sel .disc { stroke-width: 3 !important; }
.node.sel .halo { stroke: var(--accent); stroke-opacity: .22; stroke-width: 8; }
.node.focus .halo { stroke: #c7cbf0; stroke-opacity: 1; stroke-width: 2; }
.node.search-hit .halo { stroke: #f59e0b; stroke-opacity: .9; stroke-width: 3; }
.node.linking-target .disc { stroke-width: 3 !important; }

/* ---------------- 工具栏 ---------------- */
.toolbar {
  position: absolute; top: 14px; left: 14px;
  display: flex; align-items: center; gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 5px;
  box-shadow: var(--shadow-md);
}
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 11px;
  border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--text-2);
  font-size: 12.5px; font-weight: 500;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: #f4f5f8; color: var(--text); }
.btn.primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, .25);
}
.btn.primary:hover { background: #443bd8; color: #fff; }
.btn.primary .plus { font-size: 14px; margin-top: -1px; }
.btn.active { background: var(--accent-soft); color: var(--accent); border-color: #d9dcfb; }
.btn.icon { width: 30px; padding: 0; justify-content: center; font-size: 14px; }
.btn .bi { width: 13px; height: 13px; }
.toolbar-sep { width: 1px; height: 18px; background: var(--line); margin: 0 2px; }

/* ---------------- 状态栏 ---------------- */
.statusbar {
  position: absolute; left: 16px; bottom: 14px;
  max-width: calc(100% - 380px);
  font-size: 11.5px; color: var(--muted);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 12px;
  pointer-events: none;
}
.statusbar b { color: var(--text-2); font-weight: 600; }

/* ---------------- 详情面板 ---------------- */
.detail {
  position: absolute; top: 14px; right: 14px;
  width: 322px;
  max-height: calc(100% - 28px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: slideIn .18s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }

.d-head { padding: 14px 14px 12px; display: flex; gap: 11px; align-items: flex-start; border-bottom: 1px solid var(--line); }
.d-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 17px; font-weight: 600; flex: 0 0 42px;
}
.d-head-main { flex: 1 1 auto; min-width: 0; }
.d-name { font-size: 14.5px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.d-alias { font-size: 11px; color: var(--muted); font-weight: 400; }
.d-note { font-size: 11.5px; color: var(--text-2); margin-top: 3px; line-height: 1.45; word-break: break-word; }
.d-close {
  border: 0; background: none; color: var(--muted);
  font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: 5px;
}
.d-close:hover { background: #f2f4f7; color: var(--text); }

.d-body { overflow-y: auto; padding: 10px 12px 4px; flex: 1 1 auto; }
.d-body::-webkit-scrollbar { width: 8px; }
.d-body::-webkit-scrollbar-thumb { background: #e3e6eb; border-radius: 8px; }

.rel-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 8px; border-radius: 8px;
  transition: background .12s; cursor: pointer;
}
.rel-row:hover { background: #f7f8fa; }
.rel-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; flex: 0 0 8px; }
.rel-main { flex: 1 1 auto; min-width: 0; }
.rel-top { display: flex; align-items: center; gap: 5px; font-size: 12.5px; }
.rel-type { font-weight: 600; }
.rel-arrow { color: var(--muted); font-size: 11px; }
.rel-peer { color: var(--text); font-weight: 500; }
.rel-note { font-size: 11px; color: var(--muted); margin-top: 1px; line-height: 1.4; word-break: break-word; }
.rel-amount { color: #b45309; font-weight: 600; }
.rel-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.rel-row:hover .rel-actions { opacity: 1; }
.mini-btn {
  width: 22px; height: 22px; border: 0; border-radius: 5px;
  background: transparent; color: var(--muted); font-size: 11px;
  display: grid; place-items: center;
}
.mini-btn:hover { background: #eceef2; color: var(--text); }
.mini-btn.danger:hover { background: #fdecea; color: var(--danger); }

.d-empty { font-size: 12px; color: var(--muted); text-align: center; padding: 18px 0 22px; }

.d-foot { padding: 10px 12px 12px; border-top: 1px solid var(--line); display: flex; gap: 7px; }
.d-foot .btn { flex: 1 1 auto; justify-content: center; height: 32px; border: 1px solid var(--line); }
.d-foot .btn.primary { border-color: transparent; }
.d-foot .btn.danger { flex: 0 0 auto; padding: 0 10px; color: var(--danger); }
.d-foot .btn.danger:hover { background: #fdecea; border-color: #f8d7d5; }

/* ---------------- 空状态 ---------------- */
.empty { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.empty-inner { text-align: center; pointer-events: auto; }
.empty-art { display: grid; place-items: center; margin-bottom: 14px; }
.empty h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.empty p { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.empty-actions { display: flex; gap: 8px; justify-content: center; }
.empty-actions .btn { border: 1px solid var(--line); background: #fff; height: 32px; }
.empty-actions .btn.primary { background: var(--accent); border-color: transparent; }

/* ---------------- 弹窗 ---------------- */
.modal-root {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(17, 24, 39, .32);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  animation: fadeIn .14s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 400px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 60px);
  background: #fff; border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: pop .18s cubic-bezier(.2, .8, .3, 1.1);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head {
  padding: 16px 18px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.modal-head .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 2px 18px 6px; overflow-y: auto; }
.modal-foot {
  padding: 12px 18px 16px; display: flex; gap: 8px; justify-content: flex-end;
}
.modal-foot .btn { height: 33px; padding: 0 16px; border: 1px solid var(--line); }
.modal-foot .btn.primary { border-color: transparent; }

.field { margin-bottom: 13px; }
.field > label {
  display: block; font-size: 11.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px; letter-spacing: .2px;
}
.field input[type=text], .field input[type=number], .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; color: var(--text);
  background: #fafbfc; outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea { resize: vertical; min-height: 54px; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: #c3c7f5; background: #fff; box-shadow: 0 0 0 3px rgba(79, 70, 229, .08);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1 1 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); background: #fff;
  border-radius: 20px; padding: 4px 11px 4px 8px;
  font-size: 12px; color: var(--text-2); transition: all .13s;
}
.chip:hover { border-color: var(--line-strong); background: #fafbfc; }
.chip .swatch { width: 13px; height: 0; border-top-width: 2.5px; border-top-style: solid; border-radius: 2px; }
.chip.on { border-color: currentColor; background: #fff; font-weight: 600; box-shadow: 0 0 0 3px rgba(79, 70, 229, .07); }
.chip.add { color: var(--muted); border-style: dashed; padding-left: 11px; }

.tabs { display: flex; gap: 4px; background: #f2f4f7; border-radius: 9px; padding: 3px; margin-bottom: 13px; }
.tab {
  flex: 1 1 0; border: 0; background: transparent; border-radius: 7px;
  height: 27px; font-size: 12px; color: var(--text-2); font-weight: 500;
  transition: all .13s;
}
.tab.on { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.switch input { accent-color: var(--accent); width: 14px; height: 14px; }

.color-row { display: flex; gap: 6px; align-items: center; }
.color-row input[type=color] {
  width: 34px; height: 30px; padding: 2px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; cursor: pointer;
}

.help-list { font-size: 12.5px; color: var(--text-2); line-height: 1.85; padding-left: 0; list-style: none; margin: 0; }
.help-list li { display: flex; gap: 8px; align-items: baseline; }
.help-list .k {
  flex: 0 0 auto; font-size: 10.5px; font-weight: 600;
  background: #f2f4f7; border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 6px; color: var(--text-2); min-width: 44px; text-align: center;
}
.help-sep { height: 1px; background: var(--line); margin: 12px 0; }

/* ---------------- 提示条 ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(10px);
  background: #1f2430; color: #fff;
  font-size: 12.5px; padding: 9px 16px; border-radius: 9px;
  box-shadow: var(--shadow-lg); z-index: 80;
  opacity: 0; transition: opacity .18s, transform .18s;
  max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 登录 / 注册 ============ */
.auth-screen {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 460px at 50% -6%, #ecefff 0%, rgba(244,245,247,0) 62%),
    var(--bg);
}
.auth-card {
  width: 404px; max-width: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 20px 54px rgba(16, 24, 40, .11), 0 2px 8px rgba(16, 24, 40, .04);
  padding: 26px 26px 22px;
}
.auth-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-head .logo { width: 42px; height: 42px; border-radius: 12px; font-size: 19px; flex: 0 0 42px; }
.auth-head h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: .2px; }
.auth-head p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.auth-tabs { margin-bottom: 16px; }
.auth-card .field { margin-bottom: 12px; }
.auth-card input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 13px; background: #fafbfc; outline: none; transition: border-color .15s, box-shadow .15s, background .15s; }
.auth-card input:focus { border-color: #c3c7f5; background: #fff; box-shadow: 0 0 0 3px rgba(79, 70, 229, .09); }
.btn.block { width: 100%; justify-content: center; height: 37px; font-size: 13px; margin-top: 4px; }
.auth-tip { font-size: 11px; color: var(--muted); margin-top: 13px; line-height: 1.65; text-align: center; }
.auth-tip b { color: var(--text-2); font-weight: 600; }
.auth-msg { font-size: 12px; padding: 8px 11px; border-radius: 8px; margin-bottom: 12px; line-height: 1.55; }
.auth-msg.err { background: #fdecea; color: #b42318; border: 1px solid #f8d7d5; }
.auth-msg.ok { background: #ecfdf3; color: #067647; border: 1px solid #d1fadf; }

/* ============ 用户信息条 ============ */
.user-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 2px 2px 2px 9px; margin-left: 3px;
  border-left: 1px solid var(--line);
}
.u-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(140deg, #5b53f0, #7d5bf5); color: #fff;
  font-size: 10.5px; font-weight: 600; display: grid; place-items: center;
  flex: 0 0 22px;
}
.u-meta { display: flex; flex-direction: column; line-height: 1.15; margin-right: 3px; }
.u-name { font-size: 11.5px; font-weight: 600; color: var(--text); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-role { font-size: 9.5px; color: var(--muted); }
.chip-btn {
  position: relative; width: 26px; height: 26px; border: 0;
  background: transparent; border-radius: 6px; color: var(--text-2);
  display: grid; place-items: center; transition: background .12s, color .12s;
}
.chip-btn:hover { background: #f4f5f8; color: var(--text); }
.chip-btn svg { width: 15px; height: 15px; }
.badge {
  position: absolute; top: 0; right: -1px; min-width: 14px; height: 14px;
  border-radius: 8px; background: #e0453c; color: #fff;
  font-size: 9px; font-weight: 700; display: grid; place-items: center;
  padding: 0 3px; border: 1.5px solid #fff;
}

/* ============ 详情面板补充 ============ */
.d-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; font-size: 10.5px; color: var(--muted); }
.d-region { background: #eef2ff; color: #4338ca; border-radius: 20px; padding: 1px 7px; font-weight: 500; }
.d-count { background: #f2f4f7; border-radius: 20px; padding: 1px 7px; }
.rel-when { font-size: 10.5px; color: #8b93a1; margin-top: 2px; }
.notice-lock { font-size: 10.5px; color: var(--muted); margin-left: auto; align-self: center; }

/* ============ 用户管理 ============ */
.modal-section-title {
  font-size: 11px; font-weight: 600; letter-spacing: .5px; color: var(--muted);
  text-transform: uppercase; margin: 14px 0 4px;
}
.modal-section-title:first-child { margin-top: 6px; }
.user-row { display: flex; align-items: center; gap: 9px; padding: 8px 2px; border-bottom: 1px solid #f1f3f6; }
.user-row:last-child { border-bottom: 0; }
.ur-main { flex: 1 1 auto; min-width: 0; }
.ur-name { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.ur-sub { font-size: 10.5px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ur-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 11.5px; border: 1px solid var(--line); background: #fff; }
.btn.sm.ok { border-color: #bbe5c8; color: #067647; background: #f6fef9; }
.btn.sm.danger { color: #b42318; border-color: #f8d7d5; background: #fff; }
.btn.sm:hover { filter: brightness(.98); }
.status-chip { font-size: 9.5px; padding: 1px 6px; border-radius: 20px; font-weight: 600; }
.status-pending { background: #fff7e6; color: #b45309; }
.status-active { background: #ecfdf3; color: #067647; }
.status-disabled { background: #f2f4f7; color: #6b7280; }
.status-rejected { background: #fdecea; color: #b42318; }
.role-chip { font-size: 9.5px; padding: 1px 6px; border-radius: 20px; background: #eef2ff; color: #4338ca; font-weight: 600; }

/* ============ 侧栏折叠（桌面：整体收起，画布同步变宽） ============ */
.sidebar {
  min-width: 0;
  transition: flex-basis .2s ease, width .2s ease, padding .2s ease, border-width .2s ease;
}
body.sb-closed .sidebar {
  flex-basis: 0;
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-right-width: 0;
  overflow: hidden;
}

.sb-close {
  display: none;
  margin-left: auto;
  width: 30px; height: 30px;
  border: 0; border-radius: 8px;
  background: #f4f5f8; color: var(--text-2);
  font-size: 16px; line-height: 1;
  place-items: center;
}
.sb-close:hover { background: #eceef2; color: var(--text); }

.sb-mask { display: none; }

/* ============ 移动端自适应 ============ */
@media (max-width: 860px) {
  #app { height: 100dvh; }

  /* 侧栏变抽屉 */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(84vw, 300px);
    flex: 0 0 auto;
    margin-left: 0 !important;
    flex-basis: auto !important;
    min-width: 0;
    overflow: hidden;
    transform: translateX(-103%);
    transition: transform .22s ease;
    z-index: 30;
    box-shadow: 0 0 44px rgba(16, 24, 40, .2);
    padding-top: 14px;
  }
  body.sb-open .sidebar { transform: translateX(0); }
  body.sb-open .sb-mask {
    display: block;
    position: fixed; inset: 0; z-index: 25;
    background: rgba(16, 24, 40, .36);
  }
  .sb-close { display: grid; }
  .sidebar .people-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .brand { padding-bottom: 12px; }

  /* 工具栏：可横向滑动，不换行 */
  .toolbar {
    left: 8px; right: 8px; top: 8px;
    padding: 4px; gap: 4px;
    overflow-x: auto; overflow-y: hidden;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar-sep { display: none; }
  .btn { height: 32px; padding: 0 10px; font-size: 12px; }
  .btn.icon { width: 32px; }
  .user-chip { border-left: 0; padding-left: 2px; margin-left: 2px; }
  .u-meta { display: none; }

  /* 详情面板：底部抽屉 */
  .detail {
    left: 0; right: 0; top: auto; bottom: 0;
    width: auto; max-height: 66vh;
    border-radius: 16px 16px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    animation: sheetUp .2s ease;
  }
  @keyframes sheetUp { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
  .detail::before {
    content: '';
    display: block;
    width: 38px; height: 4px; border-radius: 3px;
    background: #dfe3ea;
    margin: 7px auto 1px;
    flex: 0 0 auto;
  }

  /* 状态栏在手机上让位，避免与底部抽屉打架 */
  .statusbar { display: none; }

  /* 弹窗更贴合屏幕 */
  .modal-root { padding: 10px; place-items: center; }
  .modal { width: 100%; max-height: 88vh; }
  .modal-body { padding-left: 14px; padding-right: 14px; }
  .modal-foot { padding: 10px 14px 14px; }

  /* 触摸目标略放大 */
  .person-item { padding-top: 9px; padding-bottom: 9px; }
  .mini-btn { width: 26px; height: 26px; }
}

/* 超窄屏进一步压缩 */
@media (max-width: 400px) {
  .btn { padding: 0 8px; font-size: 11.5px; }
  .toolbar .btn.primary .plus { margin-right: 1px; }
  .d-name { font-size: 14px; }
}
