/* ============================================
   十香厨自助烤肉订货平台 - 管理端布局
   © 立鹏科技 (LiPeng Technology)
   设计：电脑端左侧导航栏 / 手机端底部导航（自动切换）
   ============================================ */

.layout { display: flex; min-height: 100vh; }

/* ---------- 左侧栏（电脑端） ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none;
  background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
}
.side-brand .mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(46, 124, 230, .18);
}
.side-brand .mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.side-brand .name { font-size: 14.5px; font-weight: 700; letter-spacing: .5px; }

.side-nav { flex: 1; overflow: auto; padding: 10px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; margin-bottom: 2px;
  border-radius: 9px; color: var(--text-sub); font-size: 13.5px;
  cursor: pointer; transition: all .15s; user-select: none; border: 1px solid transparent;
}
.nav-item:hover { background: #f3f7fc; color: var(--primary); }
.nav-item.active {
  background: var(--primary-weak); color: var(--primary);
  font-weight: 600; border-color: #d4e5fb;
}
.side-foot {
  padding: 10px 12px; border-top: 1px solid var(--border);
  font-size: 10.5px; color: var(--text-faint); line-height: 1.7;
}

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- 顶部栏 ---------- */
.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  position: sticky; top: 0; z-index: 10;
}
.topbar .tb-brand { display: none; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.topbar .tb-brand .mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(46, 124, 230, .18);
}
.topbar .tb-brand .mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.topbar .crumb { font-size: 13px; font-weight: 600; color: var(--text-sub); }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar .who { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-sub); }
.topbar .who .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-weak); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700;
}
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none; cursor: pointer;
  background: transparent; color: var(--text-sub);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #f3f7fc; color: var(--primary); }

.content { padding: 16px; flex: 1; }
.view { display: none; }
.view.active { display: block; animation: viewIn .18s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } }

/* ---------- 底部导航（毛玻璃，手机端显示；电脑端隐藏） ---------- */
.bottombar {
  display: none;
  position: sticky; bottom: 0; z-index: 10;
  align-items: center; justify-content: center;
  gap: 4px; padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-top: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.bottombar::-webkit-scrollbar { display: none; }
.bbnav {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 5px 12px; min-width: 62px;
  border-radius: 10px; color: var(--text-sub); font-size: 11px;
  cursor: pointer; user-select: none; white-space: nowrap;
  border: 1px solid transparent; transition: all .15s;
  position: relative;
}
.bbnav:hover { color: var(--primary); background: #f3f7fc; }
.bbnav.active { color: var(--primary); background: var(--primary-weak); border-color: #d4e5fb; font-weight: 600; }
.bbnav .badge {
  position: absolute; top: 3px; right: 8px;
  background: var(--danger); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.nav-item .badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.page-head h2 { font-size: 17px; }
.page-head .desc { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; }

/* ---------- 看板 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 15px; box-shadow: var(--shadow);
  display: flex; align-items: flex-start; gap: 11px;
}
.stat-card .sic {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.sic-blue { background: var(--primary-weak); color: var(--primary); }
.sic-orange { background: var(--warning-weak); color: #d07c0a; }
.sic-green { background: var(--success-weak); color: var(--success); }
.sic-red { background: var(--danger-weak); color: var(--danger); }
.sic-purple { background: var(--purple-weak); color: var(--purple); }
.stat-card .val { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-card .lab { font-size: 12px; color: var(--text-sub); margin-top: 3px; }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

/* 纯 CSS 柱状图 */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding: 10px 6px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bar-col .bar {
  width: 60%; max-width: 34px; border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, #5ea0f5, #2e7ce6);
  min-height: 3px; position: relative; transition: height .4s ease;
}
.bar-col .bar.today { background: linear-gradient(180deg, #f7c05f, #e8960f); }
.bar-col .bar .bv {
  position: absolute; top: -19px; left: 50%; transform: translateX(-50%);
  font-size: 10.5px; color: var(--text-sub); white-space: nowrap;
}
.bar-col .bd { font-size: 10.5px; color: var(--text-faint); }

/* 条形排行 */
.rank-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.rank-row .rname { width: 118px; font-size: 12.5px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .rbar-wrap { flex: 1; background: #eef3f9; height: 9px; border-radius: 5px; overflow: hidden; }
.rank-row .rbar { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #5ea0f5, #2e7ce6); }
.rank-row .rval { width: 74px; text-align: right; font-size: 12px; color: var(--text-sub); font-variant-numeric: tabular-nums; flex: none; }

/* ---------- 弹窗内表格/明细 ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: 13px; margin-bottom: 12px; }
.detail-grid .dl { color: var(--text-faint); }
.timeline { margin-top: 12px; border-left: 2px solid var(--border); padding-left: 14px; }
.tl-item { position: relative; padding-bottom: 12px; font-size: 12.5px; color: var(--text-sub); }
.tl-item::before {
  content: ''; position: absolute; left: -19.5px; top: 3px;
  width: 9px; height: 9px; border-radius: 50%; background: #c9d7e8;
}
.tl-item.on::before { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
.tl-item .t { color: var(--text-faint); font-size: 11.5px; }

/* 入库多行编辑 */
.stockin-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.stockin-row .input.name { flex: 1.6; }
.stockin-row .input.qty { flex: .7; }

/* 分类 chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 5px 13px; border-radius: 18px; font-size: 12.5px;
  border: 1px solid var(--border); background: #fff; color: var(--text-sub);
  cursor: pointer; user-select: none; transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 低库存高亮 */
tr.low td { background: #fffaf5; }
tr.low:hover td { background: #fdf4ea !important; }

/* ---------- 订单编辑（总部改单，卡片式） ---------- */
.eo-card {
  border: 1px solid #e4e8f5; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px; background: #fff;
  box-shadow: var(--shadow);
}
.eo-card .eo-head { display: flex; align-items: center; gap: 8px; }
.eo-card .eo-head .eo-prod { flex: 1; }
.eo-row2 { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.eo-row2 .eo-sup { flex: 1; }
.eo-row3 { display: flex; gap: 10px; margin-top: 9px; }
.eo-row3 .f { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.eo-card .lbl { font-size: 11.5px; color: var(--text-faint); }
.eo-card .eo-qty, .eo-card .eo-price { width: 100%; }
.eo-total { border: 1px solid #d4e5fb; }

/* ---------- 订单分店列 chip ---------- */
.b-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 16px; font-size: 12px; font-weight: 500;
  background: var(--primary-weak); color: var(--primary); white-space: nowrap;
}

/* ---------- 资质文件 ---------- */
.pf-upload {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; margin-bottom: 10px;
  background: #f7fafe; border: 1px dashed #b9d4f5; border-radius: 10px;
}
.pf-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid #eef3f8; }
.pf-row:last-child { border-bottom: none; }
.pf-thumb {
  width: 46px; height: 46px; border-radius: 8px; border: 1px solid var(--border);
  object-fit: cover; background: #f7fafe; flex: none;
}
.pf-thumb.pf-pdf { display: flex; align-items: center; justify-content: center; color: var(--danger); }
.pf-info { flex: 1; min-width: 0; }
.pf-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

/* 销售单预览图 */
.sd-preview { text-align: center; background: #f4f7fc; border-radius: 10px; padding: 12px; }
.sd-preview img { max-width: 100%; max-height: 62vh; border-radius: 8px; box-shadow: var(--shadow); }

/* 销售单设计：取色器 */
.color-pick { width: 100%; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }

/* ---------- 单位管理 ---------- */
.unit-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 2px; border-bottom: 1px solid #eef3f8; }
.unit-row:last-child { border-bottom: none; }
.unit-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 11px; border-radius: 16px; font-size: 12.5px; font-weight: 600;
  background: var(--primary-weak); color: var(--primary);
}

/* ---------- 数据库初始化 ---------- */
.reset-warn {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--danger-weak); color: var(--danger); font-size: 12.5px; line-height: 1.6;
}
.reset-opt {
  display: flex; gap: 9px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; cursor: pointer; line-height: 1.55;
}
.reset-opt:has(input:checked) { border-color: var(--primary); background: #f7fafe; }
.reset-opt input { margin-top: 3px; accent-color: var(--primary); }

/* ============================================
   手机 / 平板适配（管理端在手机浏览器可用）
   ============================================ */
@media (max-width: 768px) {
  /* 手机端：隐藏左侧栏，启用底部导航 + 顶部品牌 */
  .sidebar { display: none; }
  .bottombar {
    display: flex; justify-content: flex-start;
    padding: 5px 8px calc(5px + env(safe-area-inset-bottom));
  }
  .bbnav { min-width: 56px; padding: 5px 10px; }
  .topbar .tb-brand { display: flex; }

  .topbar { padding: 0 10px; gap: 8px; position: static; }
  .topbar .crumb { font-size: 12.5px; }
  .topbar .right { gap: 6px; }
  .content { padding: 10px; padding-bottom: 6px; }

  .page-head { flex-wrap: wrap; gap: 8px; }
  .page-head h2 { font-size: 15.5px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 11px 12px; }
  .stat-card .val { font-size: 18px; }
  .dash-grid { grid-template-columns: 1fr; }

  .filter-bar { gap: 6px; }
  .filter-bar .chips { width: 100%; }
  .filter-bar .input { flex: 1 1 130px; width: auto; }
  .filter-bar .select { flex: 1 1 110px; width: auto; }

  /* 弹窗全宽 */
  .modal, .modal-lg { width: calc(100vw - 24px); max-height: calc(100vh - 30px); }
  .modal-body { padding: 12px 14px; }
  .modal-foot { padding: 0 14px 14px; flex-wrap: wrap; }

  /* 表单纵向堆叠 */
  .form-row { flex-direction: column; gap: 0; }
  .form-row .form-item { margin-bottom: 13px; }
  .detail-grid { grid-template-columns: 1fr; }

  /* 改单卡片式：小屏纵向紧凑 */
  .eo-card { padding: 9px 10px; }
  .eo-row3 { gap: 8px; }
  .eo-card .eo-head .eo-prod { flex: 1 1 100%; }

  .card-head { padding: 10px 11px; font-size: 13.5px; flex-wrap: wrap; }
  .tb th, .tb td { padding: 7px 8px; }
  .pager { flex-wrap: wrap; }
  .timeline { padding-left: 12px; }
  .pf-upload { flex-wrap: wrap; }
  .stockin-row { flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .tb { font-size: 12px; }
  .modal-foot .btn { flex: 1; }
}
