/* ============================================================
   核桃云交易系统 · PC 后台壳样式（v6.2）
   顶栏 + 侧栏 + 通用组件
   配色取自 tokens.css，不另起色板（业主要求继承 ui-spec.css）
   ============================================================ */

/* ---------- 顶栏（U-05 顺序固定：企业名 → 页面名 → 消息 → 用户名）---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  height: 54px; padding: 0 18px;
  background: var(--green-900, #0c3b2e);
  color: #e8f5ee;
  border-bottom: 1px solid rgba(255, 255, 255, .10);
}
.tb-org {
  font-size: 14px; font-weight: 600;
  color: #b5f2d2;
  padding-right: 16px;
  border-right: 1px solid rgba(255, 255, 255, .16);
  max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-page { font-size: 14px; color: #cfe7dc; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.tb-btn {
  position: relative; background: transparent; border: 1px solid rgba(255, 255, 255, .18);
  color: #d8ece3; border-radius: 999px; padding: 5px 13px; font-size: 12.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.tb-btn:hover { background: rgba(255, 255, 255, .10); }
.tb-ico { font-size: 13px; }
.tb-badge {
  position: absolute; top: -6px; right: -6px;
  background: var(--accent, #f0a020); color: #3a2600;
  font-size: 11px; font-weight: 700; border-radius: 999px;
  min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 5px;
}
.tb-user {
  font-size: 13px; color: #e8f5ee; cursor: pointer;
  padding: 5px 10px; border-radius: 6px;
}
.tb-user:hover { background: rgba(255, 255, 255, .10); }
.tb-menu {
  position: fixed; z-index: 60; min-width: 132px;
  background: #fff; border: 1px solid var(--border-l); border-radius: var(--r-md, 10px);
  box-shadow: var(--shadow-2); padding: 5px;
}
.tb-menu a {
  display: block; padding: 8px 11px; font-size: 13px; color: var(--ink, #16261f);
  text-decoration: none; border-radius: 6px;
}
.tb-menu a:hover { background: var(--green-100, #dff3e8); }

/* ---------- 主体布局 ---------- */
.body { display: flex; min-height: calc(100vh - 54px); }

/* ---------- 侧栏（U-07 按模块分组；U-08 无权限项不渲染）---------- */
.rail {
  width: 226px; flex: none; background: #2f6b52; color: #e2f0e9;
  position: sticky; top: 54px; height: calc(100vh - 54px); overflow-y: auto;
}
.rail .brand {
  color: #fff; font-weight: 700; font-size: 16px; padding: 18px 18px 2px;
}
.rail .brand small {
  display: block; font-size: 11px; color: #bfe0d2; font-weight: 400; margin-top: 3px;
}
.rail .role {
  font-size: 11px; color: #cfe7dc; padding: 0 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rail a {
  display: flex; align-items: center; padding: 10px 18px; color: inherit;
  text-decoration: none; font-size: 13px; border-left: 3px solid transparent;
}
.rail a:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.rail a.on {
  background: #1a5f42; color: #b5f2d2;
  border-left-color: #7be3ad; font-weight: 600;
}
.rail .grp {
  padding: 15px 18px 5px 14px; font-size: 12px; font-weight: 700;
  color: #a8dcc4; letter-spacing: .12em; border-left: 3px solid rgba(123, 227, 173, .5);
}

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; padding: 20px 24px 56px; }
.h {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; flex-wrap: wrap; margin-bottom: 14px;
}
.h h1 { font-size: var(--fs-xl, 21px); font-weight: 500; margin: 0; color: var(--ink, #16261f); }
.h .sub { font-size: var(--fs-sm, 12.5px); color: var(--muted, #7d8b83); margin-top: 4px; }

/* ---------- 卡片 ---------- */
.card {
  background: #fff; border: 1px solid var(--border-l);
  border-radius: var(--r-lg, 16px); padding: 18px 20px;
  margin-bottom: 16px; box-shadow: var(--shadow-1);
}
.card .ct { font-size: 15px; font-weight: 600; color: var(--ink, #16261f); margin-bottom: 3px; }
.card .cs { font-size: 12px; color: var(--muted, #7d8b83); margin-bottom: 14px; line-height: 1.7; }

/* 四口径 KPI */
.kpi-row {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  margin-bottom: 14px;
}
.kpi {
  background: #fff; border: 1px solid var(--border-l);
  border-radius: var(--r-md, 10px); padding: 14px 16px;
}
.kpi .kt { font-size: 12px; color: var(--muted, #7d8b83); margin-bottom: 6px; }
.kpi .kv {
  font-size: 24px; font-weight: 600; color: var(--green-700, #116045);
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.kpi .ku { font-size: 11.5px; color: var(--muted, #7d8b83); margin-top: 3px; }
.kpi.frozen .kv { color: var(--accent-ink, #6b4a00); }
.kpi.avail  .kv { color: var(--green-500, #0f9d58); }

/* 订单状态统计格 */
.stat-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.stat {
  border-radius: var(--r-md, 10px); padding: 13px 15px;
  border: 1px solid var(--border-l); background: #fff;
  text-decoration: none; display: block;
}
.stat:hover { box-shadow: var(--shadow-1); }
.stat .sn { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.stat .sc { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .sm { font-size: 11.5px; color: var(--muted, #7d8b83); margin-top: 4px; }
.stat .sm2 { font-size: 11.5px; color: var(--muted, #7d8b83); }

/* ---------- 状态标签（V3.2 渲染规范的视觉呈现）---------- */
.st {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.st-todo     { background: #fdf4e3; color: #6b4a00; border-color: #f0d9a8; }
.st-going    { background: #e3f0fb; color: #0c447c; border-color: #b5d4f4; }
.st-abnormal { background: #fdeeee; color: #8a2020; border-color: #f2c2c2; }
.st-done     { background: #e6f5ec; color: #1a6b4a; border-color: #b9e0cb; }
.st-clearing { background: #f1ecfb; color: #3c3489; border-color: #cfc2f0; }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 10px 11px; color: var(--ink-2, #3d4f46);
  font-weight: 600; background: var(--paper-2, #efece4);
  border-bottom: 1px solid var(--border-l); white-space: nowrap;
}
/* ★ R11：表头可点排序（正序/倒序切换） */
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--green-700, #116045); }
.tbl th .arw { margin-left: 4px; font-size: 10px; opacity: .55; }
.tbl td { padding: 10px 11px; border-bottom: 1px solid var(--border-l); color: var(--ink, #16261f); }
.tbl tbody tr:hover { background: var(--green-100, #dff3e8); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green-700, #116045); color: #fff;
  border: none; border-radius: var(--r-sm, 6px);
  padding: 8px 16px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--green-900, #0c3b2e); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost {
  background: transparent; color: var(--green-700, #116045);
  border: 1px solid var(--border-l);
}
.btn.ghost:hover { background: var(--green-100, #dff3e8); }
.btn.acc { background: var(--accent, #f0a020); color: #3a2600; }
.btn.acc:hover { filter: brightness(.94); }
.btn.danger { background: var(--danger, #d84a4a); }
.btn.sm { padding: 5px 11px; font-size: 12px; }

/* ---------- 空状态与加载（U-12 / U-13）---------- */
.empty {
  text-align: center; padding: 40px 20px; color: var(--muted, #7d8b83);
}
.empty .ei { font-size: 30px; opacity: .35; margin-bottom: 10px; }
.empty .et { font-size: 14px; color: var(--ink-2, #3d4f46); margin-bottom: 6px; }
.empty .ed { font-size: 12.5px; line-height: 1.8; }
.empty .ed a { color: var(--green-700, #116045); }

.loading { text-align: center; padding: 36px; color: var(--muted, #7d8b83); font-size: 13px; }
.skel { background: linear-gradient(90deg, #eef0ed 25%, #f6f7f5 50%, #eef0ed 75%);
        background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- 提示条 ---------- */
.tip {
  background: #fdf4e3; border-left: 3px solid var(--accent, #f0a020);
  border-radius: 0 var(--r-md, 10px) var(--r-md, 10px) 0;
  padding: 11px 14px; font-size: 12.5px; color: var(--accent-ink, #6b4400);
  line-height: 1.8; margin-bottom: 14px;
}
.err {
  background: #fdeeee; border-left: 3px solid var(--danger, #d84a4a);
  border-radius: 0 var(--r-md, 10px) var(--r-md, 10px) 0;
  padding: 11px 14px; font-size: 12.5px; color: #8a2020; margin-bottom: 14px;
}
.ok-msg {
  background: #e6f5ec; border-left: 3px solid var(--green-500, #0f9d58);
  border-radius: 0 var(--r-md, 10px) var(--r-md, 10px) 0;
  padding: 11px 14px; font-size: 12.5px; color: #1a6b4a; margin-bottom: 14px;
}

/* ---------- 无权限 ---------- */
.guard-denied { text-align: center; padding: 90px 20px; }
.guard-denied .gd-title { font-size: 19px; color: var(--ink, #16261f); margin-bottom: 8px; }
.guard-denied .gd-sub { font-size: 13px; color: var(--muted, #7d8b83); margin-bottom: 20px; }
.guard-denied .gd-btn {
  display: inline-block; background: var(--green-700, #116045); color: #fff;
  padding: 9px 20px; border-radius: var(--r-sm, 6px); text-decoration: none; font-size: 13px;
}

/* ---------- 响应式（U-21-2 业主 2026-10-12 定）----------
   ≥1024  菜单固定展开（默认）
   768-1023 菜单收窄为图标条
   <768   菜单收为抽屉，点左上角图标滑出 */
.drawer-btn {
  display: none; position: fixed; top: 60px; left: 12px; z-index: 50;
  background: var(--green-700, #116045); color: #fff; border: none;
  width: 38px; height: 38px; border-radius: 8px; font-size: 17px; cursor: pointer;
  box-shadow: var(--shadow-2);
}
.rail-mask { display: none; }

@media (max-width: 1023px) {
  .rail { width: 60px; }
  .rail .brand, .rail .role, .rail a { font-size: 0; padding-left: 0; padding-right: 0; }
  .rail .brand small, .rail .grp { display: none; }
  .rail a {
    height: 42px; justify-content: center;
  }
  .rail a::before { content: "·"; font-size: 17px; }
  .rail a:hover::before { content: attr(data-t); font-size: 12px; position: absolute; left: 64px;
    background: #1a5f42; color: #fff; padding: 4px 10px; border-radius: 6px; z-index: 50; }
  .main { padding: 16px; }
  .tb-org { max-width: 150px; }
}

@media (max-width: 767px) {
  .drawer-btn { display: block; }
  .rail {
    position: fixed; top: 54px; left: 0; bottom: 0; z-index: 45;
    width: 226px; transform: translateX(-100%); transition: transform .24s var(--ease-out);
  }
  .rail.open { transform: translateX(0); }
  .rail .brand, .rail .role, .rail a { font-size: 13px; padding-left: 18px; padding-right: 18px; }
  .rail .brand small, .rail .grp { display: block; }
  .rail a::before { content: none; }
  .rail-mask { display: block; position: fixed; inset: 54px 0 0 0; background: rgba(0, 0, 0, .34); z-index: 44; }
  .main { padding: 14px; }
  /* ★ 表格改卡片式，不允许横向滚动 */
  .tbl thead { display: none; }
  .tbl tr { display: block; border: 1px solid var(--border-l); border-radius: 10px;
            margin-bottom: 9px; padding: 8px 11px; background: #fff; }
  .tbl td { display: flex; justify-content: space-between; gap: 12px;
            border: none; padding: 5px 0; }
  .tbl td::before {
    content: attr(data-th); font-size: 12px; color: var(--muted, #7d8b83); flex: none;
  }
  .tbl td.num { text-align: right; }
  .topbar { gap: 10px; padding: 0 12px; }
  .tb-org { max-width: 108px; font-size: 13px; }
  .tb-btn span:not(.tb-badge) { display: none; }
}
