/* ============================================================
 * 布局层：应用骨架 / 侧边栏 / 顶栏 / 步骤条 / 响应式断点
 *
 * 断点约定（全站统一，新增样式请沿用）：
 *   ≥1280  宽屏，侧栏常驻
 *   1024   中屏，侧栏收窄
 *   <1024  侧栏改为抽屉（浮层）
 *   <768   平板/大屏手机：网格单列、表格横向滚动
 *   <640   手机：modal 变底部抽屉、toast 移到底部
 * ============================================================ */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;      /* 移动端浏览器地址栏收缩时仍撑满 */
  overflow: hidden;
}

/* ============ 侧边栏 ============ */
.sidebar {
  width: var(--sb);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: width .22s ease, transform .22s ease;
}

.brand {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 16px 16px 14px;
  min-width: 0;
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--pri);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.brand-txt { min-width: 0; }
.brand-txt b { display: block; font-size: 14.5px; font-weight: 600; letter-spacing: -.2px; }
.brand-txt small { font-size: 11px; color: var(--t4); }

.nav { flex: 1; padding: 6px 10px; overflow: auto; }
.nav-i {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  border-radius: var(--r);
  font-size: 13.5px;
  color: var(--t2);
  margin-bottom: 2px;
  transition: .15s;
  font-weight: 500;
  white-space: nowrap;
}
.nav-i svg { flex: none; }

/* 全局侧栏折叠态：仅桌面端生效 */
.app.sb-collapsed .sidebar { width: var(--sb-narrow); }
.app.sb-collapsed .brand-txt,
.app.sb-collapsed .nav-i span,
.app.sb-collapsed .side-foot .u-info,
.app.sb-collapsed .side-foot .quota-box { display: none; }
.app.sb-collapsed .brand { justify-content: center; padding-left: 12px; padding-right: 12px; }
.app.sb-collapsed .nav { padding: 6px; }
.app.sb-collapsed .nav-i { justify-content: center; padding: 11px; }
.app.sb-collapsed .user-box { justify-content: center; }
.app.sb-collapsed .user-box .avatar { margin: 0; }
.app.sb-collapsed .side-foot { padding: 12px 6px; }

#btnCollapse .c1 { display: inline; }
#btnCollapse .c2 { display: none; }
.app.sb-collapsed #btnCollapse .c1 { display: none; }
.app.sb-collapsed #btnCollapse .c2 { display: inline; }
.nav-i:hover { background: var(--surface-3); color: var(--t1); }
.nav-i.on { background: var(--pri-w); color: var(--pri); font-weight: 600; }
.nav-i.on svg { color: var(--pri); }

.side-foot {
  padding: 12px;
  border-top: 1px solid var(--line-soft);
  flex: none;
}

/* ============ 抽屉遮罩（仅 <1024 时生效） ============ */
.sb-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(29, 33, 41, .42);
  z-index: 290;
  animation: fin .16s;
}

/* ============ 主区域 ============ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;      /* 关键：否则表格会把主区撑破 */
}

.topbar {
  flex: none;
  min-height: var(--tb-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-left h2 { font-size: 16px; font-weight: 600; letter-spacing: -.2px; white-space: nowrap; }
.crumb {
  font-size: 12px;
  color: var(--t4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.tb-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.view {
  flex: 1;
  overflow: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

/* ============ 汉堡按钮：宽屏隐藏 ============ */
.only-narrow { display: none; }
.only-wide { display: inline-flex; }

/* ============ 步骤条 ============ */
.steps {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 5px;
  margin-bottom: 16px;
  gap: 2px;
  align-items: center;
}
.steps .st {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 13px;
  border-radius: var(--r);
  cursor: pointer;
  transition: .16s;
  min-width: 0;
}
.steps .st .n {
  width: 23px; height: 23px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--t3);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex: none;
}
.steps .st .tx { min-width: 0; }
.steps .st .tx b {
  display: block; font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.steps .st .tx small {
  display: block; font-size: 11.5px; color: var(--t4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 紧凑模式：收起描述文字，只留序号+标题，整体更窄 */
.steps.compact .st .tx small { display: none; }
.steps.compact .st { padding: 8px 10px; gap: 7px; }
.steps.compact .st .n { width: 20px; height: 20px; font-size: 11px; }
.steps.compact .st .tx b { font-size: 13px; }
.steps .st:hover { background: var(--surface-2); }
.steps .st.on { background: var(--pri-w); }
.steps .st.on .tx b { color: var(--pri); }
.steps .st.on .n { background: var(--pri); color: #fff; }
.steps .st.done .n { background: var(--ok); color: #fff; }
.steps .st-tog {
  flex: none;
  padding: 4px 8px;
  border-radius: var(--r);
  color: var(--t3);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  margin-left: 4px;
}
.steps .st-tog:hover { background: var(--surface-2); color: var(--t1); }

/* ============ 加载占位 ============ */
.pad-load { padding: 48px; text-align: center; }

/* ============ 通用网格 ============ */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ============ 步骤内的操作条 ============ */
.step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}
.skip-hint {
  margin-top: 10px; font-size: 12px; color: var(--t3); text-align: right;
}
.skip-hint .link {
  display: inline-block;
  margin-left: 5px; color: var(--pri); background: none; border: none;
  padding: 3px 6px; font-size: 12px; cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px; border-radius: var(--r);
}
.skip-hint .link:hover { color: var(--pri-h); background: var(--pri-w); }

/* ============================================================
 * 响应式
 * ============================================================ */

/* —— 中屏：侧栏收窄 —— */
@media (max-width: 1279px) {
  :root { --sb: 210px; }
}

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* —— 侧栏转抽屉 —— */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    transform: translateX(-100%);
    box-shadow: var(--sh-3);
  }
  .app.sb-open .sidebar { transform: none; }
  .app.sb-open .sb-mask { display: block; }
  .only-narrow { display: inline-flex; }
  .only-wide { display: none; }
  .view { padding: 16px; }
}

@media (max-width: 860px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
}

/* —— 平板 / 大屏手机 —— */
@media (max-width: 767px) {
  .topbar {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .tb-left { width: 100%; }
  .tb-left h2 { font-size: 15px; }
  .crumb { display: none; }
  .tb-right { width: 100%; justify-content: flex-start; }

  .view { padding: 12px; }

  /* 步骤条改为横向滚动，避免挤压成两行 */
  .steps {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .steps::-webkit-scrollbar { display: none; }
  .steps .st { flex: 1 0 auto; padding: 8px 11px; }

  .step-actions .btn { flex: 1 1 auto; }
}

/* —— 手机 —— */
@media (max-width: 639px) {
  body { font-size: 13.5px; }
  .view { padding: 10px; }
  .tb-left h2 { font-size: 14.5px; }

  /* 顶栏按钮只留图标，腾出横向空间 */
  .tb-right .btn span { display: none; }
  .tb-right .btn { padding: 6px 10px; }

  .step-actions > .btn { width: 100%; justify-content: center; }
  .step-actions .mut.small { width: 100%; }
}
