/* ============================================================
   食光 Pantry Life · 布局层
   PC：左侧固定导航 + 右侧内容   Mobile：品牌顶栏 + 底部悬浮 5 tab
   同一份 DOM，≤900px 才切换信息架构（home.css 里进一步重排）
   ============================================================ */

.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}
.workspace { min-width: 0; display: flex; flex-direction: column; }

/* ---------------- PC 固定侧栏 ---------------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: var(--z-side);
  display: flex;
  flex-direction: column;
  padding: 26px 16px 18px;
  background: var(--paper);
  border-right: 1px solid var(--line);
  box-shadow: 4px 0 24px rgba(107, 77, 54, .035);
}
.sidebar::before {
  content: "";
  position: absolute; inset: 0;
  background-image: var(--grain);
  background-size: 180px 180px;
  opacity: .04;
  pointer-events: none;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; border-bottom: 1px solid var(--line-soft); }
.brand__art { width: 54px; height: 54px; border-radius: 18px 20px 16px 19px / 19px 16px 20px 18px; object-fit: cover; background: var(--sage-pale); }
.brand__name { font-family: var(--serif); font-size: 21px; font-weight: 700; line-height: 1.2; }
.brand__en { font-size: 10px; letter-spacing: 2.1px; color: var(--ink-3); text-transform: uppercase; }

.nav-group { padding: 22px 10px 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 44px;
  padding: 9px 14px;
  border-radius: var(--r-chip);
  color: var(--ink-2);
  font-size: 13px;
  text-align: left;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-item + .nav-item { margin-top: 3px; }
.nav-item:hover { background: var(--sage-wash); color: var(--olive-deep); transform: translateX(2px); }
.nav-item.is-active { background: var(--olive); color: var(--on-olive); font-weight: 600; box-shadow: 0 6px 16px rgba(85, 96, 57, .18); }
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item .nav-item__en { margin-left: auto; font-size: 9px; letter-spacing: 1px; opacity: .55; }

.side-foot { margin-top: auto; padding-top: var(--sp-3); }
.side-note {
  position: relative;
  padding: 16px 16px 15px;
  background: var(--sage-wash);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card-sm);
  overflow: hidden;
}
.side-note .leaf--a { width: 34px; height: 16px; right: 10px; top: 8px; }
.side-note__title { font-family: var(--serif); font-size: 14px; margin-bottom: 4px; }
.side-note__text { font-size: 10px; color: var(--ink-2); line-height: 1.6; }
.side-phase { margin: 12px 10px 0; font-size: 9px; letter-spacing: 1.4px; color: var(--ink-3); text-transform: uppercase; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 70px;
  padding: 12px 40px;
  background: rgba(244, 238, 225, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar__crumb { font-size: 11px; color: var(--ink-3); letter-spacing: .6px; }
.topbar__crumb b { color: var(--ink); font-weight: 600; }
.topbar__right { display: flex; align-items: center; gap: 14px; }
.topbar__date { font-size: 11px; color: var(--ink-2); }
.avatar {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-round);
  background: var(--sage-pale);
  color: var(--olive-deep);
  font-family: var(--serif);
  font-size: 16px;
  border: 1px solid var(--line);
}
.topbar__brand { display: none; align-items: center; gap: 10px; }
.menu-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--paper);
  border: 1px solid var(--line-soft);
}
.menu-btn svg { width: 19px; height: 19px; }
.topbar__brand .brand__art { width: 36px; height: 36px; border-radius: 12px; }
.topbar__brand .brand__name { font-size: 17px; }
.topbar__brand .brand__en { display: none; }

/* ---------------- 当前档案标识（R5-06） ----------------
   常驻顶栏，首页 / 库存 / 详情 / 表单 / 识别页共用同一处，保证一致。
   只做展示，不是切换入口（R5-08 未解决前不开放切换 UI）。 */
.topbar__profile { display: inline-flex; min-width: 0; }
.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 200px;
  height: 30px;
  padding: 0 10px 0 9px;
  border-radius: var(--r-pill);
  background: var(--sage-wash);
  border: 1px solid var(--line);
  color: var(--olive-deep);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  transition: background .18s ease, border-color .18s ease;
}
.profile-chip:hover { background: var(--sage-pale); border-color: var(--sage-light); }
.profile-chip svg { width: 14px; height: 14px; flex: none; }
.profile-chip__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.profile-chip__tag {
  flex: none;
  font-size: 9px;
  letter-spacing: .6px;
  color: var(--ink-3);
  padding-left: 6px;
  border-left: 1px solid var(--line);
}

/* ---------------- 档案已切换：本页失效面板（R5-04） ---------------- */
.profile-stale {
  max-width: 720px;
  margin: 8px auto 0;
  padding: 28px 30px 26px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
}
.profile-stale__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--clay-pale);
  color: var(--clay);
  font-size: 11px;
  letter-spacing: .5px;
}
.profile-stale__badge svg { width: 15px; height: 15px; }
.profile-stale h1 {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.35;
  margin: 14px 0 10px;
  color: var(--ink);
}
.profile-stale p { margin: 0 0 10px; font-size: 13px; line-height: 1.85; color: var(--ink-2); }
.profile-stale p b { color: var(--ink); font-weight: 600; }
.profile-stale__hint {
  padding: 10px 13px;
  border-radius: var(--r-chip);
  background: var(--sage-wash);
  color: var(--olive-deep) !important;
}
.profile-stale__acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.profile-stale__foot { margin: 14px 0 0 !important; font-size: 11px; color: var(--ink-3) !important; }

/* ---------------- 内容区 ---------------- */
.view {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-5) 40px 40px;
}
.site-foot {
  padding: 0 40px 24px;
  text-align: center;
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: .4px;
}

/* 受限预览环境提示（sandbox iframe 无 allow-same-origin 时出现） */
.env-note {
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%; max-width: var(--content-max);
  margin: 0 auto; padding: 14px 40px 0;
  font-size: 11px; line-height: 1.7; color: var(--warm);
}
.env-note > div { flex: 1; min-width: 0; }
.env-note b { color: var(--clay); font-weight: 600; }
.env-note__dot {
  flex: none; width: 7px; height: 7px; margin-top: 6px;
  border-radius: 50%; background: var(--warm);
  box-shadow: 0 0 0 3px var(--cream-deep);
}

/* ---------------- Mobile 底部导航 ---------------- */
.tabbar { display: none; }
.scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(58, 58, 48, .32);
  backdrop-filter: blur(2px);
  z-index: var(--z-drawer);
}

/* ---------------- 通用显隐工具 ---------------- */
.only-mb { display: none !important; }

/* ============================================================
   ≤1200px：PC 紧凑档（侧栏变窄，内容 padding 收敛）
   ============================================================ */
@media (max-width: 1200px) {
  .topbar { padding: 12px 26px; }
  .view { padding: var(--sp-4) 26px 36px; }
  .site-foot { padding: 0 26px 20px; }
  .env-note { padding: 12px 26px 0; }
  .brand__name { font-size: 19px; }
  /* 窄侧栏不换行、隐藏英文副标，保证导航项单行 */
  .nav-item { white-space: nowrap; }
  .nav-item__en { display: none; }
}

/* ============================================================
   ≤900px：Mobile 信息架构（侧栏 → 抽屉，顶栏 → 品牌行，底部 tabbar）
   ============================================================ */
@media (max-width: 900px) {
  .only-pc { display: none !important; }
  .only-mb { display: block !important; }

  .shell { display: block; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 272px;
    height: 100vh;
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform .26s cubic-bezier(.22, .68, .32, 1), visibility .26s;
    z-index: calc(var(--z-drawer) + 1);
    box-shadow: var(--shadow-lift);
  }
  .sidebar.open { transform: none; visibility: visible; }
  .scrim.is-open { display: block; }

  .topbar {
    min-height: 62px;
    padding: 10px 16px;
    background: rgba(244, 238, 225, .94);
  }
  .topbar__brand { display: flex; }
  .topbar__crumb { display: none; }
  .topbar__right .topbar__date { display: none; }

  .view { padding: 18px 16px 118px; }
  .site-foot { display: none; }
  .env-note { padding: 10px 16px 0; font-size: 10px; }

  /* 窄屏顶栏：档案标识收窄，只保留档案名，避免与品牌行抢位 */
  .topbar__right { gap: 8px; }
  .profile-chip { max-width: 132px; height: 28px; font-size: 10px; padding: 0 8px; }
  .profile-chip__tag { display: none; }

  .profile-stale { padding: 20px 18px; border-radius: var(--r-card-sm); }
  .profile-stale h1 { font-size: 20px; }
  .profile-stale__acts { flex-direction: column; }
  .profile-stale__acts .btn { width: 100%; }

  .tabbar {
    position: fixed;
    left: 14px; right: 14px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: var(--z-tabbar);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    padding: 7px;
    background: rgba(251, 247, 236, .96);
    backdrop-filter: blur(14px);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-float);
  }
  .tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 50px;
    border-radius: var(--r-pill);
    color: var(--ink-3);
    font-size: 10px;
    transition: background .18s ease, color .18s ease;
  }
  .tab svg { width: 20px; height: 20px; }
  .tab.is-active { background: var(--olive); color: var(--on-olive); font-weight: 600; }
}

/* ≤480px：更紧凑，保证不横向溢出 */
@media (max-width: 480px) {
  .view { padding-left: 14px; padding-right: 14px; }
  .topbar { padding-left: 14px; padding-right: 14px; }
  .tabbar { left: 10px; right: 10px; }
  .tab { font-size: 9px; }
}
