/* REQ-003-UI-01 · 统一业务壳样式（暖金 R5 双 chrome）
 *
 * 设计基线：用户已确认的暖金 R5 桌面/手机原型（design-baseline.json）。
 * tokens 与原型一致：主金 #C7A253、金色深字 #705317、浅金 #F0E6CD、
 * 深绿 #24493E、浅底 #F6F7F5、白面板。全部样式本地化，无运行时外网依赖。
 *
 * 两种 chrome（由 shell.js 按 location 决定，见 shell.js chromeOf）：
 * - sidebar：工作区自有页面（ux02/ux03/建档/…）。桌面=白色左侧栏+顶栏；
 *   手机=顶部品牌条 + 底部「今天/地块/供应链/全部」。
 * - topbar：主站宿主的兼容页（/workspace/tools/*）。沿用一条水平栏
 *   （暖金配色），主站自身布局不被侧栏推挤。
 *
 * 独立性：类名一律 ux- 前缀，避免与主站 .tabs/.tab、工作区 .tabs 冲突。
 */

:root {
  --rg-gold: #C7A253;
  --rg-gold-ink: #705317;
  --rg-gold-soft: #F0E6CD;
  --rg-green: #24493E;
  --rg-green-soft: #EDF3EF;
  --rg-bg: #F6F7F5;
  --rg-paper: #fff;
  --rg-ink: #252D27;
  --rg-muted: #69736A;
  --rg-secondary: #556158;
  --rg-line: #E1E5DF;
  --rg-raised: #F0F2EF;
  --rg-danger: #9E4839;
  --rg-danger-soft: #FAF0EC;
  /* UI-03 r3-S001：hover/warn/强调文本色纳入 token 域（消灭 ux03 残留硬编码） */
  --rg-gold-deep: #b8924a;
  --rg-raised-hover: #e8ebe6;
  --rg-warn-soft: #FDF3D7;
  --rg-on-accent: #fff;
  --ux-sidebar-w: 216px;
  --ux-topbar-h: 56px;
}

/* ---------- chrome: sidebar（工作区页面） ---------- */

.ux-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--ux-sidebar-w);
  z-index: 95;
  display: flex;
  flex-direction: column;
  background: var(--rg-paper);
  border-right: 1px solid var(--rg-line);
  overflow-y: auto;
  font: 14px/1.45 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--rg-ink);
}
.ux-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 16px 4px;
  text-decoration: none;
  color: var(--rg-ink);
}
.ux-sidebar__brand img { height: 26px; width: auto; flex: 0 0 auto; }
.ux-sidebar__brand-name {
  display: block;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .2px;
}
.ux-sidebar__brand-sub {
  font-size: 8.5px;
  color: var(--rg-muted);
  letter-spacing: .4px;
  text-transform: uppercase;
}
.ux-sidebar__caption {
  padding: 10px 18px 0;
  font-size: 11px;
  color: var(--rg-muted);
}
.ux-sidebar__group {
  padding: 10px 0 2px;
}
.ux-sidebar__group-label {
  padding: 0 18px 4px;
  font-size: 11px;
  color: var(--rg-muted);
}
.ux-sidebar__item {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 1px 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--rg-ink);
  text-decoration: none;
  white-space: nowrap;
}
.ux-sidebar__item svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--rg-secondary); }
.ux-sidebar__item:hover { background: var(--rg-raised); }
.ux-sidebar__item.is-active {
  background: var(--rg-gold-soft);
  color: var(--rg-gold-ink);
  font-weight: 600;
}
.ux-sidebar__item.is-active svg { color: var(--rg-gold-ink); }
.ux-sidebar__item.is-denied {
  color: var(--rg-muted);
  cursor: not-allowed;
}
.ux-sidebar__item.is-denied svg { color: var(--rg-line); }
.ux-sidebar__more {
  margin: 8px 10px 4px;
}
.ux-sidebar__foot {
  margin-top: auto;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--rg-line);
}
.ux-sidebar__slogan {
  font-size: 11px;
  color: var(--rg-muted);
  line-height: 1.6;
  margin: 0 0 10px;
}
.ux-sidebar__user {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--rg-ink);
  border-radius: 8px;
  padding: 4px;
}
.ux-sidebar__user:hover { background: var(--rg-raised); }
.ux-sidebar__avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--rg-gold-soft);
  color: var(--rg-gold-ink);
  font-size: 13px;
  font-weight: 700;
}
.ux-sidebar__username { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.ux-sidebar__userrole { font-size: 11px; color: var(--rg-muted); }

/* 侧栏推挤：页面自带 main 容器（ux02/ux03/建档页通用）。 */
body.ux-sidebar-installed main {
  margin-left: var(--ux-sidebar-w);
  margin-right: auto;
  padding-top: calc(var(--ux-topbar-h) + 12px);
}

/* ---------- 顶栏（面包屑 + 日期 + 用户；sidebar chrome 专用） ---------- */

.ux-topbar {
  position: fixed;
  top: 0;
  left: var(--ux-sidebar-w);
  right: 0;
  height: var(--ux-topbar-h);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: var(--rg-paper);
  border-bottom: 1px solid var(--rg-line);
  font: 13.5px/1.4 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--rg-secondary);
}
.ux-topbar__crumbs { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ux-topbar__date { flex: 0 0 auto; color: var(--rg-muted); }
.ux-topbar__user {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--rg-ink);
  text-decoration: none;
  padding: 5px 8px;
  border-radius: 8px;
}
.ux-topbar__user:hover { background: var(--rg-raised); }
.ux-topbar__brand-mini {
  display: none;
  align-items: center;
  gap: 8px;
  color: var(--rg-ink);
  font-weight: 700;
  text-decoration: none;
}
.ux-topbar__brand-mini img { height: 24px; width: auto; }

/* ---------- chrome: topbar（主站宿主 /workspace/tools/* 兼容承接） ---------- */

.ux-shell {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 0 10px;
  padding: 8px 10px;
  background: var(--rg-paper);
  border: 1px solid var(--rg-line);
  border-radius: 12px;
  color: var(--rg-ink);
  font: 15px/1.4 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.ux-shell::-webkit-scrollbar { display: none; }
.ux-shell__brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  color: var(--rg-ink);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 8px;
}
.ux-shell__brand img { width: 26px; height: 26px; }
.ux-shell__brand:hover { background: var(--rg-raised); }
.ux-shell__links { display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0; }
.ux-shell__item {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 6px 11px;
  border-radius: 8px;
  color: var(--rg-ink);
  text-decoration: none;
  border: 1px solid transparent;
}
.ux-shell__item:hover { background: var(--rg-raised); }
.ux-shell__item.is-active {
  background: var(--rg-gold-soft);
  color: var(--rg-gold-ink);
  font-weight: 600;
}
.ux-shell__item.is-denied {
  color: var(--rg-muted);
  cursor: not-allowed;
  text-decoration: line-through dotted rgba(105, 115, 106, .5);
}
.ux-shell__me {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--rg-secondary);
}
.ux-shell__who { white-space: nowrap; }
.ux-shell__aux {
  color: var(--rg-ink);
  text-decoration: none;
  border-bottom: 1px dashed var(--rg-muted);
  white-space: nowrap;
}
.ux-shell__aux:hover { border-bottom-style: solid; color: var(--rg-gold-ink); }
.ux-shell__flag {
  flex: 0 0 auto;
  background: var(--rg-gold-soft);
  color: var(--rg-gold-ink);
  border: 1px solid var(--rg-gold);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}
.ux-shell.is-readonly { box-shadow: inset 0 0 0 2px var(--rg-gold); }

/* ---------- 面包屑（#uxCrumbs 优先，页面自备 #crumbs 兜底） ---------- */

.ux-shell__sep { margin: 0 6px; color: var(--rg-muted); }
#uxCrumbs a, #crumbs a { color: var(--rg-secondary); text-decoration: none; }
#uxCrumbs a:hover, #crumbs a:hover { color: var(--rg-gold-ink); text-decoration: underline; }
#uxCrumbs b, #crumbs b { color: var(--rg-ink); font-weight: 600; }
#crumbs { font-size: .95rem; margin: 0 0 10px; }

/* ---------- 手机底部导航：今天 / 地块 / 供应链 / 全部 ---------- */

.ux-mobile-nav { display: none; }
.ux-mobile-nav a, .ux-mobile-nav button, .ux-mobile-nav span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 50px;
  padding: 2px 0 0;
  color: var(--rg-secondary);
  text-decoration: none;
  background: none;
  border: 0;
  font: 11px/1.2 inherit;
  cursor: pointer;
}
.ux-mobile-nav .ux-mobile-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 30px;
  border-radius: 10px;
}
.ux-mobile-nav .ux-mobile-ico svg { width: 18px; height: 18px; }
.ux-mobile-nav [aria-current="page"] { color: var(--rg-gold-ink); font-weight: 700; }
.ux-mobile-nav [aria-current="page"] .ux-mobile-ico { background: var(--rg-gold-soft); }
.ux-mobile-nav [aria-disabled="true"] { color: var(--rg-muted); }

/* ---------- 「全部」入口面板（真实全量：栏目 + 专项工具 + 其他） ---------- */

.ux-all-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(37, 45, 39, .42);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.ux-all-panel {
  background: var(--rg-paper);
  width: 100%;
  max-width: 640px;
  max-height: 84vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
  font: 14px/1.5 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--rg-ink);
}
@media (min-width: 861px) {
  .ux-all-backdrop { align-items: center; padding: 24px; }
  .ux-all-panel { border-radius: 16px; }
}
.ux-all-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 6px;
}
.ux-all-panel__head h2 { font-size: 1.05rem; margin: 0; }
.ux-all-panel__close {
  border: 0;
  background: var(--rg-raised);
  color: var(--rg-ink);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
}
.ux-all-panel__section { margin: 10px 0 0; }
.ux-all-panel__section > h3 {
  font-size: 11.5px;
  color: var(--rg-muted);
  font-weight: 600;
  margin: 0 0 4px;
}
.ux-all-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 8px;
  border-radius: 8px;
  color: var(--rg-ink);
  text-decoration: none;
}
.ux-all-item svg { width: 16px; height: 16px; color: var(--rg-secondary); flex: 0 0 auto; }
.ux-all-item:hover { background: var(--rg-raised); }
.ux-all-item.is-denied { color: var(--rg-muted); cursor: not-allowed; }
.ux-all-item .ux-all-why {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--rg-muted);
}

/* ---------- 键盘可达与动效偏好 ---------- */

.ux-sidebar__item:focus-visible,
.ux-sidebar__user:focus-visible,
.ux-topbar__user:focus-visible,
.ux-shell__item:focus-visible,
.ux-shell__brand:focus-visible,
.ux-mobile-nav a:focus-visible,
.ux-mobile-nav button:focus-visible,
.ux-all-item:focus-visible,
.ux-all-panel__close:focus-visible {
  outline: 2px solid var(--rg-gold);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .ux-sidebar, .ux-topbar, .ux-all-backdrop, .ux-all-panel {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- 响应式（≤860px 收侧栏为手机形态） ---------- */

@media (max-width: 860px) {
  .ux-sidebar { display: none; }
  body.ux-sidebar-installed main {
    margin-left: 0;
    padding-top: calc(var(--ux-topbar-h) + 10px);
  }
  body.ux-mobile-installed { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .ux-topbar {
    left: 0;
    padding: 0 12px;
  }
  .ux-topbar__crumbs { display: none; }
  .ux-topbar__date { display: none; }
  .ux-topbar__brand-mini { display: flex; }
  .ux-topbar__user { margin-left: auto; }
  .ux-mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--rg-paper);
    border-top: 1px solid var(--rg-line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .ux-shell { flex-wrap: wrap; border-radius: 10px; padding: 8px; gap: 8px; }
  .ux-shell__links { display: none; }
  .ux-shell__aux { display: none; }
  .ux-shell__me { order: 2; margin-left: auto; font-size: 12px; gap: 8px; }
  .ux-shell__item { padding: 7px 10px; }
}
@media (max-width: 420px) {
  .ux-shell__who { display: none; }   /* 375/390 视口优先保证栏目可点 */
}

/* ---------- 既有兼容（建档页表单 / 主站宿主工具页） ---------- */

#trialWork input, #trialWork select {
  display: block; width: 100%; min-height: 42px; margin: 4px 0 10px;
  box-sizing: border-box; padding: 8px; border: 1px solid #c6d9cb;
  border-radius: 6px; font: inherit; background: white; color: inherit;
}
#trialWork .btn { min-height: 44px; margin: 4px 0; }
/* Reused business panels keep their forms inside the shared navigation. */
/* HOL-F009（R12：固定 44px 不覆盖手机换行横幅——横幅高度不固定）：
   改为 CSS 变量 --ux-banner-offset 动态测量。shell.js 启动时量取
   #wzFrozenBanner/#wzRehearsalBanner 的实际高度写入变量；无横幅=0。
   顶栏/侧栏引用变量，横幅换行多高避让多高。 */
body.wz-frozen .ux-topbar, body.wz-rehearsal .ux-topbar {
  top: var(--ux-banner-offset, 0px);
}
body.wz-frozen .ux-sidebar, body.wz-rehearsal .ux-sidebar {
  padding-top: var(--ux-banner-offset, 0px);
}
body.workspace-tool #mainNav, body.workspace-tool #groupChips,
body.workspace-tool #bottomNav, body.workspace-tool .bottom-nav,
body.workspace-tool #newTrialBtn { display: none !important; }
/* HOL-F001：主站宿主 .wrap 是 212px+1fr 双列栅格——插入的统一壳必须
   跨全部列，否则整条导航挤进左列与账号文字重叠（截图04 实测）。 */
body.workspace-tool .ux-shell { grid-column: 1 / -1; }
/* 旧导航隐藏后，宿主双列栅格会让业务内容掉进 212px 窄左列（截图41 实测）
   ——工具页宿主整体单列化，壳与内容依次全宽排布。 */
body.workspace-tool .wrap { grid-template-columns: 1fr; }
body.ux-mobile-installed #bottomNav { display: none !important; }
