* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  background: #f0f2f5;
  color: #333;
}

/* ── 左侧边栏 ─────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 220px;
  background: #1a3a5c;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.sidebar-logo-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.5;
  letter-spacing: .5px;
}
.sidebar-logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0 6px;
  overflow-y: auto;
}

/* 顶级直链（工作台） */
.sidebar-item {
  display: flex;
  align-items: center;
  padding: 9px 16px 9px 32px;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: 14px;
  transition: background .15s, color .15s;
  position: relative;
}
.sidebar-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-item.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: #40a9ff;
  border-radius: 0 2px 2px 0;
}
.sidebar-item.top-level { padding-left: 20px; font-size: 15px; }

/* 分组 */
.sidebar-section { margin: 2px 0; }
.sidebar-group-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
  color: rgba(255,255,255,.5);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  user-select: none;
}

.sidebar-subitems { overflow: hidden; }

/* 底部用户区 */
.sidebar-foot {
  padding: 12px 16px 14px;
  border-top: 1px solid rgba(255,255,255,.1);
  background: rgba(0,0,0,.15);
  flex-shrink: 0;
}
.sidebar-username { color: rgba(255,255,255,.9); font-size: 13px; font-weight: 500; }
.sidebar-userrole { color: rgba(255,255,255,.45); font-size: 11px; margin-top: 2px; }
.sidebar-logout-btn {
  margin-top: 10px;
  width: 100%;
  padding: 5px 0;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.8);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background .15s;
}
.sidebar-logout-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

/* 主内容区 */
.main-content { margin-left: 220px; min-height: 100vh; }

/* 页面主体 */
.page { padding: 16px; max-width: 1400px; margin: 0 auto; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.page-title { font-size: 18px; font-weight: 600; color: #1a3a5c; }

/* 卡片 */
.card {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  padding: 16px;
  margin-bottom: 14px;
}

/* 筛选栏 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filter-bar input, .filter-bar select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  background: #fff;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: #1a3a5c; }

/* 按钮 */
.btn {
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: opacity .2s;
  white-space: nowrap;
}
.btn:hover { opacity: .85; }
.btn-primary { background: #1a3a5c; color: #fff; }
.btn-success { background: #52c41a; color: #fff; }
.btn-warning { background: #faad14; color: #fff; }
.btn-danger  { background: #ff4d4f; color: #fff; }
.btn-default { background: #fff; color: #333; border: 1px solid #d9d9d9; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f5f7fa;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e8e8e8;
  white-space: nowrap;
  color: #555;
  font-weight: 600;
}
td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* 入库弹窗两栏布局 */
#inbound-two-col { display: flex; gap: 16px; }
#inbound-two-col > div:first-child { width: 210px; flex-shrink: 0; }
@media (max-width: 640px) {
  #inbound-two-col { flex-direction: column; }
  #inbound-two-col > div:first-child { width: 100%; }
}

/* 状态 Tab 导航 */
.status-tab {
  padding: 5px 14px;
  border-radius: 16px;
  border: 1px solid #d9d9d9;
  background: #fff;
  color: #555;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.status-tab:hover { border-color: #1890ff; color: #1890ff; }
.status-tab.active { background: #1890ff; border-color: #1890ff; color: #fff; font-weight: 600; }

/* 状态徽标 */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  white-space: nowrap;
}
.badge-草稿    { background: #f0f0f0; color: #888; }
.badge-待审批  { background: #fff7e6; color: #fa8c16; }
.badge-已审批  { background: #e6f7ff; color: #1890ff; }
.badge-待采购  { background: #e6f7ff; color: #096dd9; }
.badge-pay-未付款  { background: #fff1f0; color: #ff4d4f; }
.badge-pay-部分付款 { background: #fff7e6; color: #fa8c16; }
.badge-pay-全部付款 { background: #f6ffed; color: #389e0d; }
.badge-部分下单 { background: #fff0f6; color: #c41d7f; }
.badge-已下单  { background: #f9f0ff; color: #722ed1; }
.badge-部分到货 { background: #fff1b8; color: #d46b08; }
.badge-全部到货 { background: #f6ffed; color: #389e0d; }
.badge-作废    { background: #fff1f0; color: #cf1322; }

/* 弹窗 */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 600;
}
.modal-close {
  cursor: pointer;
  font-size: 20px;
  color: #999;
  line-height: 1;
  border: none;
  background: none;
  padding: 4px;
}
.modal-close:hover { color: #333; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 13px; color: #555; font-weight: 500; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: #1a3a5c; }
.form-textarea { resize: vertical; min-height: 72px; }

/* 分页 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  color: #666;
}
.pagination button {
  height: 28px;
  padding: 0 10px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination button:hover:not(:disabled) { border-color: #1a3a5c; color: #1a3a5c; }

/* 导入异常标记 */
.import-warn {
  display: inline-block;
  background: #fff7e6;
  color: #d46b08;
  border: 1px solid #ffd591;
  border-radius: 3px;
  font-size: 11px;
  padding: 1px 5px;
  margin-left: 5px;
  cursor: pointer;
  vertical-align: middle;
  white-space: nowrap;
}
.import-warn:hover { background: #ffe7ba; }
.import-warn-banner {
  background: #fff7e6;
  border: 1px solid #ffd591;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #7c4a00;
  line-height: 1.7;
}
.import-warn-banner strong { color: #d46b08; }

/* 辅助 */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #999; }
.text-warning { color: #fa8c16; }
.text-danger  { color: #ff4d4f; }
.text-success { color: #52c41a; }
.mt8 { margin-top: 8px; }
.gap8 { display: flex; gap: 8px; }

/* 移动端适配 */
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .nav-title { font-size: 14px; margin-right: 12px; }
  .page { padding: 10px; }
  td, th { padding: 8px; }
}

@media (max-width: 768px) {
  /* 侧边栏默认隐藏，滑入式 */
  .sidebar {
    transform: translateX(-220px);
    transition: transform .25s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }

  /* 主内容全宽 */
  .main-content { margin-left: 0; }

  /* 汉堡按钮 */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 10px; left: 10px;
    z-index: 200;
    width: 38px; height: 38px;
    background: #1a3a5c;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
  }

  /* 蒙层 */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
  }
  body.sidebar-open .sidebar-overlay { display: block; }

  /* 页头留出汉堡按钮空间 */
  .page-header { padding-left: 46px; }

  /* 筛选栏自动换行 */
  .filter-bar { flex-wrap: wrap; }
  .filter-bar input, .filter-bar select { width: auto !important; flex: 1 1 120px; }

  /* 弹窗全屏 */
  .modal {
    max-width: 100% !important;
    width: 100%;
    margin: 0;
    border-radius: 0;
    max-height: 100vh;
  }
  .modal-overlay { align-items: flex-end; }
}

/* 桌面端隐藏汉堡按钮 */
.mobile-menu-btn { display: none; }

/* 打印 */
@media print {
  .sidebar { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .filter-bar, .btn, .pagination, .modal-overlay { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ── 阅读角色：隐藏所有写操作按钮 ── */
body.is-viewer .page-header .btn { display: none !important; }
body.is-viewer .viewer-action    { display: none !important; }
body.is-viewer .btn-danger       { display: none !important; }
