/* 可近管理系统 · 阶段1导航 + 阶段2角色首页（仅新增样式，不改旧视图） */
/* 钉钉浅色系变量在 ui-system.css；此处只用变量，深浅色自动跟随 [data-theme] */

/* ===== 角色导航开启时：隐藏旧侧栏与空间切换，显示新导航 ===== */
#roleNav{display:none}
body[data-role-home="on"] #legacyNav{display:none}
body[data-role-home="on"] #roleNav{display:flex}
body[data-role-home="on"] #spaceSwitcher,
body[data-role-home="on"] #topSpaceStatus{display:none}
.nav-group-label{font-size:11px;color:var(--muted);padding:14px 10px 4px;letter-spacing:.06em}
#roleNav{flex-direction:column;gap:2px;overflow-y:auto;min-height:0}

/* ===== 页签条（页面 / 页签 结构） ===== */
#page-tabs{display:none;gap:4px;padding:0 clamp(16px,3vw,40px);border-bottom:1px solid var(--line);background:var(--panel);overflow-x:auto;scrollbar-width:thin}
body[data-role-home="on"] #page-tabs{display:flex}
.page-tab{border:0;background:none;padding:10px 14px;font-size:13px;color:var(--muted);cursor:pointer;border-bottom:2px solid transparent;white-space:nowrap;min-height:42px}
.page-tab:hover{color:var(--text)}
.page-tab.active{color:var(--brand-text,var(--brand));border-bottom-color:var(--brand);font-weight:650}
.page-tab:focus-visible{outline:2px solid var(--brand);outline-offset:-2px}

/* ===== 顶栏工具：搜索 / 铃铛 / 视角 ===== */
.top-tools{display:none;align-items:center;gap:8px}
body[data-role-home="on"] .top-tools{display:flex}
.top-search input{min-height:34px;width:min(220px,32vw);border:1px solid var(--line);border-radius:6px;background:var(--panel2);padding:4px 10px;font-size:13px;color:var(--text)}
.top-search input:focus{border-color:var(--brand);box-shadow:0 0 0 3px color-mix(in srgb,var(--brand) 16%,transparent)}
.icon-btn{position:relative;min-width:36px;min-height:36px;display:inline-flex;align-items:center;justify-content:center;border-radius:6px}
.icon-btn .nav-badge{position:absolute;top:2px;right:2px;min-width:16px;height:16px;padding:0 4px;font-size:10px;line-height:16px;border-radius:8px}
.perspective{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--muted);white-space:nowrap}
.perspective select{min-height:34px;border:1px solid var(--line);border-radius:6px;background:var(--panel2);color:var(--text);font-size:13px;padding:4px 8px}

/* ===== 角色首页 ===== */
.home-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:12px}
.home-widget{grid-column:span 6;background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:16px;min-width:0}
.home-widget.wide{grid-column:span 12}
.home-widget>header{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:10px}
.home-widget>header h3{font-size:15px;font-weight:650;margin:0}
.home-widget .widget-src{font-size:11px;color:var(--muted);white-space:nowrap}
.widget-rows{display:flex;flex-direction:column;gap:6px}
.widget-row{display:flex;align-items:center;gap:10px;padding:8px 10px;border:1px solid var(--line);border-radius:6px;background:var(--panel2);font-size:13px;min-width:0}
.widget-row .row-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.widget-row .row-meta{font-size:12px;color:var(--muted);white-space:nowrap}
.widget-row .row-go{flex:none}
.stat-strip{display:flex;gap:16px;flex-wrap:wrap}
.stat-cell{min-width:88px}
.stat-cell .num{font-size:22px;font-weight:650;line-height:1.3}
.stat-cell .lbl{font-size:12px;color:var(--muted)}
.widget-error{border:1px dashed color-mix(in srgb,var(--danger) 45%,var(--line));background:var(--danger-soft);color:var(--danger);border-radius:6px;padding:12px;font-size:13px;display:flex;align-items:center;justify-content:space-between;gap:8px}
.widget-empty{border:1px dashed var(--line);background:var(--panel2);color:var(--muted);border-radius:6px;padding:14px;font-size:13px;display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
.widget-empty .next-step{flex:none}
.tag{display:inline-flex;align-items:center;gap:4px;font-size:11px;font-weight:650;padding:2px 8px;border-radius:4px;white-space:nowrap}
.tag.ok{background:var(--ok-soft,#e8ffea);color:var(--ok-text,#007a22)}
.tag.warn{background:var(--warn-soft);color:var(--warn-text,#b25000)}
.tag.danger{background:var(--danger-soft);color:var(--danger-text,#cb2634)}
.tag.neutral{background:var(--panel2);color:var(--muted);border:1px solid var(--line)}

/* ===== 待办聚合 ===== */
.todo-groups{display:flex;flex-direction:column;gap:14px}
.todo-group{background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:14px 16px}
.todo-group>header{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
.todo-group>header h3{font-size:14px;font-weight:650;margin:0}
.todo-group .count{font-size:12px;color:var(--muted)}

/* ===== 首页头部 ===== */
.home-hero{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:16px;flex-wrap:wrap}
.home-hero h1{font-size:20px;line-height:1.4;margin:4px 0}
.home-hero .muted{font-size:13px}
.home-hero .eyebrow{margin:0}
.stale-banner{border:1px solid var(--warn-soft);background:var(--warn-soft);color:var(--warn-text,#b25000);border-radius:8px;padding:10px 14px;font-size:13px;margin-bottom:14px}

/* ===== 三档宽度 ===== */
@media (max-width:1100px){
  .home-widget{grid-column:span 12}
}
@media (max-width:680px){
  .home-grid{gap:10px}
  .home-widget{padding:14px}
  .page-tab{padding:10px 12px;min-height:44px}
  .top-search{display:none}
  /* 顶栏：标题独占剩余空间单行省略，不再被挤成逐字竖排或消失 */
  .topbar{gap:8px}
  .crumb{flex:1 1 auto;min-width:0;font-size:15px}
  .top-right{flex:none;gap:8px}
  .top-tools{gap:6px}
  /* 隐藏「视角」文字 label（次要信息），保留下拉；可访问名由 select 的 aria-label 提供 */
  .perspective{font-size:0;gap:0}
  .perspective select{font-size:13px;max-width:88px;padding:4px 6px}
  .stat-strip{gap:12px}
  .stat-cell .num{font-size:20px}
}

/* ===== M-F1 角色首页与菜单编辑器（系统设置 · 可关闭草稿） ===== */
.menu-editor-roles{display:grid;grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:12px;margin-top:4px}
.menu-editor-role{border:1px solid var(--border,#e5e6eb);border-radius:10px;padding:10px 12px;margin:0;min-width:0}
.menu-editor-role legend{font-weight:600;font-size:13px;padding:0 6px}
.menu-editor-items{display:flex;flex-direction:column;gap:2px}
.menu-editor-item{display:flex;align-items:center;gap:8px;padding:5px 6px;border-radius:6px;cursor:grab;font-size:13px;min-width:0}
.menu-editor-item:hover{background:var(--hover,rgba(22,119,255,.06))}
.menu-editor-item input[type="checkbox"]{flex:none}
.menu-editor-order{flex:none;width:22px;text-align:center;color:var(--muted,#86909c);font-variant-numeric:tabular-nums}
.menu-editor-title{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@media (max-width:768px){.menu-editor-roles{grid-template-columns:1fr}}
