* { box-sizing: border-box; }
.hidden { display: none !important; }
:root {
  --ant-primary: #1677ff;
  --ant-primary-hover: #4096ff;
  --ant-primary-active: #0958d9;
  --ant-primary-bg: #e6f4ff;
  --ant-primary-border: #91caff;
  --ant-success: #52c41a;
  --ant-success-bg: #f6ffed;
  --ant-success-border: #b7eb8f;
  --ant-warning: #faad14;
  --ant-warning-bg: #fffbe6;
  --ant-warning-border: #ffe58f;
  --ant-error: #ff4d4f;
  --ant-error-bg: #fff2f0;
  --ant-error-border: #ffccc7;
  --ant-text: rgba(0,0,0,0.88);
  --ant-text-secondary: rgba(0,0,0,0.65);
  --ant-text-tertiary: rgba(0,0,0,0.45);
  --ant-text-quaternary: rgba(0,0,0,0.25);
  --ant-border: #d9d9d9;
  --ant-border-secondary: #f0f0f0;
  --ant-bg-container: #ffffff;
  --ant-bg-layout: #f5f5f5;
  --ant-fill-quaternary: #fafafa;
  --ant-fill-tertiary: #f5f5f5;
  --ant-radius: 6px;
  --ant-radius-sm: 4px;
  --ant-radius-lg: 8px;
  --ant-shadow: 0 1px 2px 0 rgba(0,0,0,0.03), 0 1px 6px -1px rgba(0,0,0,0.02), 0 2px 4px 0 rgba(0,0,0,0.02);
  --ant-shadow-hover: 0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12), 0 5px 12px 4px rgba(0,0,0,0.09);
}
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif; background: var(--ant-bg-layout); color: var(--ant-text); font-size: 14px; line-height: 1.5715; }
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #001529; color: rgba(255,255,255,0.85); padding: 20px; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; }
.sidebar h2 { margin-top: 0; font-size: 20px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0; }
.sidebar-nav > a,
.sidebar-nav > details {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-nav > a:last-child { border-bottom: none; }
.sidebar a { color: rgba(255,255,255,0.65); text-decoration: none; padding: 10px 12px; border-radius: 6px; display: block; font-size: 14px; transition: all .2s; }
.sidebar a.active { background: var(--ant-primary); color: #fff; }
.sidebar a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-group { margin: 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.sidebar-group-summary {
  list-style: none;
  cursor: pointer;
  color: rgba(255,255,255,0.65);
  padding: 10px 12px;
  border-radius: 6px;
  user-select: none;
  font-size: 14px;
  position: relative;
  padding-left: 28px;
}
.sidebar-group-summary::-webkit-details-marker { display: none; }
.sidebar-group-summary::marker { content: ""; }
.sidebar-group-summary::before {
  content: "\25B6";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  opacity: 0.75;
  transition: transform 0.15s ease;
}
.sidebar-group[open] > .sidebar-group-summary::before {
  transform: translateY(-50%) rotate(90deg);
}
.sidebar-group-summary:hover,
.sidebar-group[open] > .sidebar-group-summary {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.sidebar-group:has(.sidebar-subnav a.active) > .sidebar-group-summary {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.sidebar-subnav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 6px 0;
  margin: 0 0 0 10px;
  border-left: 2px solid #4b5563;
}
.sidebar-subnav a {
  padding: 8px 10px 8px 14px;
  font-size: 13px;
  border-radius: 0 6px 6px 0;
}
.sidebar-subnav a.active {
  background: var(--ant-primary);
  color: #fff;
}
.sidebar-subnav a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.content { margin-left: 240px; padding: 24px; width: calc(100% - 240px); }
.page-header { margin-bottom: 20px; }
.page-header h1 { margin: 0; font-size: 20px; font-weight: 600; color: var(--ant-text); }
.page-header p { margin: 4px 0 0; color: var(--ant-text-tertiary); font-size: 13px; }

/* ── 卡片 ── */
.card { background: var(--ant-bg-container); border: 1px solid var(--ant-border-secondary); border-radius: var(--ant-radius-lg); padding: 20px; margin-bottom: 16px; box-shadow: var(--ant-shadow); transition: box-shadow .2s; }
.card:hover { box-shadow: var(--ant-shadow-hover); }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-title-row h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--ant-text); }

/* ── 统计卡片 ── */
.grid-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid-cards .card h3 { margin: 0 0 8px; font-size: 13px; color: var(--ant-text-tertiary); font-weight: 500; }
.grid-cards .card p { margin: 0; font-size: 26px; font-weight: 700; color: var(--ant-text); }

/* ── 筛选/工具栏 ── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { min-width: 140px; }
.list-total { text-align: right; font-size: 13px; color: var(--ant-text-secondary); margin-bottom: 8px; }
.list-total-edge { margin-left: auto; font-size: 13px; color: var(--ant-text-secondary); flex-shrink: 0; }
.muted-hint { margin: 0 0 12px; font-size: 13px; color: var(--ant-text-secondary); line-height: 1.6; }

/* ── 表格 ── */
.materials-table-card { overflow-x: auto; }
input, select, textarea { border: 1px solid var(--ant-border); border-radius: var(--ant-radius); padding: 8px 12px; min-width: 120px; font-size: 14px; font-family: inherit; transition: all .2s; background: var(--ant-bg-container); color: var(--ant-text); }
input:focus, select:focus, textarea:focus { border-color: var(--ant-primary); outline: none; box-shadow: 0 0 0 2px rgba(22,119,255,0.1); }
input:hover, select:hover, textarea:hover { border-color: var(--ant-primary-hover); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: var(--ant-fill-quaternary); font-size: 13px; font-weight: 600; color: var(--ant-text-tertiary); text-align: left; }
th, td { border: 1px solid var(--ant-border-secondary); padding: 12px 16px; vertical-align: top; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--ant-fill-tertiary); }

/* ── 产品卡片网格 ── */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.material-card {
  background: #fff;
  border: 1px solid var(--ant-border-secondary);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
}
.material-card:hover {
  border-color: var(--ant-primary);
  box-shadow: 0 4px 16px rgba(22,119,255,0.1);
  transform: translateY(-2px);
}
.mc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mc-type-badge {
  font-size: 14px;
  font-weight: 500;
  color: var(--ant-text-secondary);
}
.mc-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--ant-text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mc-spec-line {
  font-size: 13px;
  color: var(--ant-text-secondary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mc-cat-line {
  font-size: 12px;
  color: var(--ant-text-tertiary);
}
.mc-meta-row {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--ant-text-tertiary);
  flex-wrap: wrap;
}
.mc-code {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  background: var(--ant-fill-tertiary);
  padding: 2px 8px;
  border-radius: 4px;
}
.mc-supplier {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}
.mc-stats {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--ant-border-secondary);
}
.mc-stock {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
}
.mc-stock-icon { font-size: 14px; }
.mc-stock-num { font-variant-numeric: tabular-nums; }
.mc-stock-label { font-size: 12px; font-weight: 500; }
.stock-green { background: #f0fdf4; color: #166534; }
.stock-yellow { background: #fefce8; color: #854d0e; }
.stock-red { background: #fef2f2; color: #991b1b; }
.stock-grey { background: #f3f4f6; color: #6b7280; }
.mc-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--ant-primary);
}
.mc-price small {
  font-size: 12px;
  font-weight: 400;
  color: var(--ant-text-tertiary);
  margin-left: 2px;
}
.mc-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--ant-border-secondary);
}
.mc-actions .btn {
  flex: 1;
  font-size: 13px;
}
.mc-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 16px;
  color: var(--ant-text-tertiary);
  font-size: 15px;
}

/* ── 通用数据卡片（库存/订单等）与产品卡片统一风格 ── */
.data-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;  /* 与 materials-grid 一致 */
}
.data-card {
  background: #fff;
  border: 1px solid var(--ant-border-secondary);
  border-radius: 12px;
  padding: 20px;          /* 与 material-card 一致 */
  display: flex;
  flex-direction: column;
  gap: 10px;              /* 与 material-card 一致 */
  transition: all 0.2s ease;
}
.data-card:hover {
  border-color: var(--ant-primary);
  box-shadow: 0 4px 16px rgba(22,119,255,0.1);   /* 与 material-card 一致 */
  transform: translateY(-2px);                      /* 与 material-card 一致 */
}
/* 顶部行 — 匹配 mc-top */
.dc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
/* 标题 — 匹配 mc-name */
.dc-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ant-text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 副行 — 匹配 mc-spec-line */
.dc-sub {
  font-size: 13px;
  color: var(--ant-text-secondary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 元数据行 — 匹配 mc-meta-row */
.dc-meta {
  font-size: 12px;
  color: var(--ant-text-tertiary);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.dc-meta code {
  font-family: 'SF Mono','Menlo','Consolas',monospace;
  background: var(--ant-fill-tertiary);
  padding: 2px 8px;
  border-radius: 4px;
}
/* 信息区 — 匹配 mc-stats 的边框+间距 */
.dc-info {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--ant-border-secondary);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.dc-info-item {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
}
.dc-number {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ant-text);
  font-size: 18px;
}
.dc-label-sm {
  font-size: 12px;
  font-weight: 400;
  color: var(--ant-text-tertiary);
}
/* 操作按��行 — 匹配 mc-actions */
.dc-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--ant-border-secondary);
}
.dc-actions .btn {
  flex: 1;
  font-size: 13px;
}
.dc-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 16px;
  color: var(--ant-text-tertiary);
  font-size: 15px;
}

/* ── 精简表格（备选视图） ── */
#materials-table-wrap table { min-width: 720px; font-size: 14px; }
#materials-table-wrap th { white-space: nowrap; font-size: 13px; }
/* ── 按钮 ── */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--ant-border); background: var(--ant-bg-container); color: var(--ant-text); padding: 8px 15px; border-radius: var(--ant-radius); cursor: pointer; text-decoration: none; display: inline-block; font-size: 14px; font-weight: 400; transition: all .2s; line-height: 1.5715; }
.btn:hover { border-color: var(--ant-primary-hover); color: var(--ant-primary-hover); }
.btn.primary { background: var(--ant-primary); border-color: var(--ant-primary); color: #fff; }
.btn.primary:hover { background: var(--ant-primary-hover); border-color: var(--ant-primary-hover); color: #fff; }
.btn.sm { padding: 4px 11px; font-size: 12px; border-radius: var(--ant-radius-sm); }
.btn.danger { color: var(--ant-error); border-color: var(--ant-error-border); background: var(--ant-error-bg); }
.btn.danger:hover { background: #ffccc7; border-color: var(--ant-error); color: var(--ant-error); }
.btn.link { border: none; background: transparent; color: var(--ant-primary); padding: 4px 8px; font-size: 14px; }
.btn.link:hover { color: var(--ant-primary-hover); }
.tag { display: inline-flex; align-items: center; padding: 0 7px; border-radius: var(--ant-radius-sm); font-size: 12px; line-height: 20px; font-weight: 400; border: 1px solid transparent; }
.tag.draft { background: var(--ant-warning-bg); color: var(--ant-warning); border-color: var(--ant-warning-border); }
.tag.released { background: var(--ant-success-bg); color: var(--ant-success); border-color: var(--ant-success-border); }
.tag.obsolete { background: var(--ant-error-bg); color: var(--ant-error); border-color: var(--ant-error-border); }
.tag.current { background: var(--ant-primary-bg); color: var(--ant-primary); border-color: var(--ant-primary-border); }
.tag.sm { padding: 0 5px; font-size: 11px; line-height: 16px; }

/* ── 消息提示 ── */
.msg { padding: 10px 14px; margin: 10px 0; min-height: 18px; border-radius: 8px; font-size: 14px; }
.msg.ok { color: #166534; background: #f0fdf4; border: 1px solid #bbf7d0; }
.msg.err { color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; }

/* ── 弹窗 ── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 1000; }
.modal.hidden { display: none; }
.modal-body { width: min(720px, 95vw); max-height: 90vh; overflow-y: auto; background: var(--ant-bg-container); border-radius: var(--ant-radius-lg); padding: 24px; box-shadow: 0 6px 16px 0 rgba(0,0,0,0.08), 0 3px 6px -4px rgba(0,0,0,0.12), 0 9px 28px 8px rgba(0,0,0,0.05); }
.modal-body h3 { margin: 0 0 20px; font-size: 18px; font-weight: 600; color: var(--ant-text); }

/* ── 表单网格 ── */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ant-text-secondary); font-weight: 500; }
.form-grid label input, .form-grid label select, .form-grid label textarea { min-width: 0; width: 100%; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .form-block { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.form-grid .form-block .form-block-title { color: var(--ant-text-secondary); font-weight: 500; }
.checkbox-group { display: flex; gap: 10px; flex-wrap: wrap; padding: 6px 0; }
.checkbox-group label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 400; flex-direction: row; }
.checkbox-group input[type="checkbox"] { min-width: 0; width: 14px; height: 14px; padding: 0; margin: 0; }
.scroll-checkbox-list {
  display: block; max-height: 220px; overflow-y: auto;
  border: 1px solid var(--ant-border-secondary); border-radius: 8px; padding: 10px; background: var(--ant-fill-quaternary);
}
.scroll-checkbox-list label {
  display: flex; align-items: center; gap: 6px; margin: 0 0 6px 0; white-space: nowrap; line-height: 1.2;
}
.scroll-checkbox-list label:last-child { margin-bottom: 0; }

/* ── 采购订单专用 ── */
.po-modal-wide { width: min(1100px, 98vw); }
.po-section { margin-bottom: 20px; }
.po-section h4 { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--ant-text); padding-bottom: 8px; border-bottom: 1px solid #f0f0f0; }
.po-lines-wrap { overflow-x: auto; max-width: 100%; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table-scroll > table { min-width: 600px; }
.po-lines-table { font-size: 13px; min-width: 920px; }
.po-lines-table input { min-width: 0; width: 100%; box-sizing: border-box; }
.po-total-line { text-align: right; margin: 10px 0 0; font-size: 15px; font-weight: 600; }
.po-invoice-list { list-style: none; padding: 0; margin: 0; }
.po-invoice-li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; padding: 10px 12px; background: var(--ant-fill-quaternary); border-radius: 8px; border: 1px solid var(--ant-border-secondary); }
.po-invoice-no { font-weight: 600; }

/* 采购订单列表 — 状态标签 */
.po-status-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.po-st-draft { background: #e5e7eb; color: var(--ant-text); }
.po-st-sent { background: #bfdbfe; color: #1e3a8a; }
.po-st-confirmed { background: #a7f3d0; color: #064e3b; }
.po-st-partial_received { background: #fde68a; color: #78350f; }
.po-st-received { background: #a5f3fc; color: #155e75; }
.po-st-closed { background: #e7e5e4; color: #57534e; }
.po-st-unknown { background: #f3f4f6; color: #4b5563; }

.po-pay-unpaid { background: #fef3c7; color: #92400e; }
.po-pay-partial { background: #dbeafe; color: #1e40af; }
.po-pay-paid { background: #d1fae5; color: #065f46; }
.po-pay-unknown { background: #f3f4f6; color: #4b5563; }

.po-due-muted {
  color: #6b7280;
  font-size: 13px;
}
.po-due-overdue {
  background: #fee2e2 !important;
  color: #991b1b;
  font-weight: 600;
}
.po-due-today {
  background: #ffedd5 !important;
  color: #9a3412;
  font-weight: 600;
}
.po-due-soon {
  background: #fef9c3 !important;
  color: #854d0e;
}
.po-due-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background: #dc2626;
  color: #fff;
  margin-right: 6px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.po-due-pill-today {
  background: #ea580c;
}

.po-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.po-status-row select {
  flex: 1;
  min-width: 200px;
}

/* 采购入库 — 当前已加载明细的订单行 */
#pr_order_tbody tr.pr-row-active {
  background: var(--ant-primary-bg);
  outline: 2px solid #93c5fd;
  outline-offset: -2px;
}

/* 采购发票列表 — 开票状态 */
.pi-inv-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  vertical-align: middle;
}
.pi-inv-none {
  background: #fef3c7;
  color: #92400e;
}
.pi-inv-yes {
  background: #d1fae5;
  color: #065f46;
}

@media (max-width: 1280px) {
  .grid-cards { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── 侧边栏用户区域 ── */
.sidebar-user {
  margin-top: auto; padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.sidebar-user-name { color: #fff; font-weight: 600; font-size: 14px; display: block; }
.sidebar-user-role { color: rgba(255,255,255,0.45); font-size: 12px; display: block; margin-top: 2px; }

/* ── 库存拖拽排序 ── */
.drag-handle { user-select: none; }
#tx-tbody tr[draggable="true"]:hover { background: var(--ant-primary-bg); cursor: grab; }
#tx-tbody tr[draggable="true"] td:first-child { white-space: nowrap; }

/* ════════════════════════════════════════════
   响应式 / 移动端适配
   断点: 768px (手机), 1024px (小平板)
   ════════════════════════════════════════════ */

/* ── 移动端顶栏（默认隐藏，手机端显示）── */
.mobile-topbar {
  display: none;
}
.hamburger {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.mobile-topbar-title {
  font-size: 16px;
  font-weight: 600;
}
.sidebar-overlay {
  display: none;
}

/* ── 平板适配 (≤1024px) ── */
@media (max-width: 1024px) {
  .grid-cards { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-row { grid-template-columns: 1fr !important; }
  .dashboard-row > * { width: 100% !important; }
  .modal-body { width: min(640px, 95vw); }
  .materials-grid { grid-template-columns: repeat(2, 1fr); }
  .data-cards { grid-template-columns: repeat(2, 1fr); }
}

/* ── 手机适配 (≤768px) ── */
@media (max-width: 768px) {
  /* 移动端顶栏 */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #001529;
    color: #fff;
    padding: 10px 14px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    height: 48px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }

  /* 侧边栏变为抽屉 */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1002;
    padding-top: 48px;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
  }
  .sidebar h2 { font-size: 18px; }
  .sidebar-nav { padding-bottom: 20px; }
  .sidebar-nav > a,
  .sidebar-nav > details,
  .sidebar-group { padding: 0; }
  .sidebar a { padding: 14px 12px; font-size: 15px; }
  .sidebar-subnav a { padding: 12px 10px 12px 14px; font-size: 14px; }
  .sidebar-group-summary { padding: 14px 12px 14px 28px; font-size: 15px; }

  /* 遮罩层 */
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .sidebar-overlay.overlay-active {
    opacity: 1;
    pointer-events: auto;
  }

  /* 内容区全宽 */
  .content {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 12px !important;
    padding-top: 60px !important;
  }

  /* 页面标题 */
  .page-header { margin-bottom: 12px; }
  .page-header h1 { font-size: 18px; }

  /* 产品卡片手机端单列 */
  .materials-grid { grid-template-columns: 1fr; gap: 12px; }
  .data-cards { grid-template-columns: 1fr; gap: 10px; }
  .material-card { padding: 16px; gap: 8px; min-height: auto; }
  .mc-name { font-size: 16px; }
  .mc-price { font-size: 16px; }
  .page-header p { font-size: 12px; display: none; }

  /* 卡片 */
  .card { padding: 10px; margin-bottom: 10px; border-radius: 10px; }
  .card-title-row { gap: 8px; }
  .card-title-row h3 { font-size: 15px; }

  /* 统计卡片 → 2列网格 */
  .grid-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .grid-cards .card { padding: 10px; }
  .grid-cards .card h3 { font-size: 12px; }
  .grid-cards .card p { font-size: 20px; }
  .grid-cards .card .stat-sub { font-size: 11px; }

  /* 表单 → 单列 */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .form-grid .full { grid-column: 1; }
  .form-grid label { font-size: 14px; gap: 6px; }
  .form-grid input, .form-grid select, .form-grid textarea {
    padding: 10px 12px; font-size: 15px;
  }

  /* 筛选栏 → 堆叠 */
  .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filters > * {
    width: 100%;
    min-width: 0;
  }
  .filters .btn,
  .filters input,
  .filters select {
    width: 100%;
  }
  .list-total-edge {
    margin-left: 0;
    text-align: left;
    font-size: 12px;
  }
  .list-total { font-size: 12px; }

  /* 输入框 */
  input, select, textarea {
    min-width: 0;
    font-size: 15px; /* 防止 iOS 缩放 */
    padding: 10px 12px;
  }

  /* 表格 → 精美卡片式布局 */
  .card:not(.table-scroll) > table,
  .card:not(.table-scroll) table.dash-table,
  .po-lines-wrap:not(.modal .po-lines-wrap) .po-lines-table {
    display: block !important;
    border: none !important;
    background: transparent !important;
  }
  .card:not(.table-scroll) > table thead,
  .card:not(.table-scroll) table.dash-table thead,
  .po-lines-wrap:not(.modal .po-lines-wrap) .po-lines-table thead { display: none !important; }
  .card:not(.table-scroll) > table tbody,
  .card:not(.table-scroll) table.dash-table tbody,
  .po-lines-wrap:not(.modal .po-lines-wrap) .po-lines-table tbody { display: block !important; }
  .card:not(.table-scroll) > table tr,
  .card:not(.table-scroll) table.dash-table tr,
  .po-lines-wrap:not(.modal .po-lines-wrap) .po-lines-table tr {
    display: block !important;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 12px;
    padding: 16px;
    border: none !important;
  }
  .card:not(.table-scroll) > table tbody tr:hover,
  .po-lines-wrap tbody tr:hover { background: #fff !important; }
  /* 第一列：卡片标题 */
  .card:not(.table-scroll) > table tr td:first-child,
  .card:not(.table-scroll) table.dash-table tr td:first-child,
  .po-lines-wrap:not(.modal .po-lines-wrap) .po-lines-table tr td:first-child {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 10px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid #f1f5f9 !important;
    font-size: 16px;
    font-weight: 700;
    color: var(--ant-text);
    gap: 8px;
  }
  .card:not(.table-scroll) > table tr td:first-child::before,
  .card:not(.table-scroll) table.dash-table tr td:first-child::before,
  .po-lines-wrap:not(.modal .po-lines-wrap) .po-lines-table tr td:first-child::before {
    content: none !important;
  }
  /* 中间列：紧凑标签-值 */
  .card:not(.table-scroll) > table td:not(:first-child):not(:last-child),
  .card:not(.table-scroll) table.dash-table td:not(:first-child):not(:last-child),
  .po-lines-wrap:not(.modal .po-lines-wrap) .po-lines-table td:not(:first-child):not(:last-child) {
    display: flex !important;
    justify-content: space-between;
    align-items: flex-start;
    padding: 5px 0;
    border: none !important;
    font-size: 13px;
    gap: 10px;
  }
  .card:not(.table-scroll) > table td:not(:first-child):not(:last-child)::before,
  .card:not(.table-scroll) table.dash-table td:not(:first-child):not(:last-child)::before,
  .po-lines-wrap:not(.modal .po-lines-wrap) .po-lines-table td:not(:first-child):not(:last-child)::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--ant-text-tertiary);
    min-width: 55px;
    flex-shrink: 0;
    text-align: left;
  }
  /* 操作列：底部按钮行 */
  .card:not(.table-scroll) > table tr td:last-child,
  .card:not(.table-scroll) table.dash-table tr td:last-child,
  .po-lines-wrap:not(.modal .po-lines-wrap) .po-lines-table tr td:last-child {
    display: flex !important;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9 !important;
  }
  .card:not(.table-scroll) > table tr td:last-child::before,
  .card:not(.table-scroll) table.dash-table tr td:last-child::before,
  .po-lines-wrap:not(.modal .po-lines-wrap) .po-lines-table tr td:last-child::before {
    content: none !important;
  }
  .card:not(.table-scroll) > table tr td:last-child .btn,
  .po-lines-wrap tr td:last-child .btn {
    padding: 8px 14px;
    font-size: 14px;
    border-radius: 8px;
    flex: 1;
    text-align: center;
  }
  /* 空单元格隐藏 */
  .card:not(.table-scroll) > table td:empty,
  .po-lines-wrap td:empty { display: none !important; }

  /* 物料产品卡（已经用卡片网格，不变） */
  /* tables inside modals keep scroll */
  .modal .po-lines-wrap { overflow-x: auto; }
  .modal .po-lines-table { min-width: 700px; display: table !important; }
  .modal .po-lines-table thead { display: table-header-group !important; }
  .modal .po-lines-table tr { display: table-row !important; padding: 0; box-shadow: none; margin: 0; border-radius: 0; }
  .modal .po-lines-table td { display: table-cell !important; padding: 6px; border: 1px solid #e5e7eb !important; }
  .modal .po-lines-table td::before { content: none !important; }

  /* 弹窗 → 全屏底部抽屉 */
  .modal {
    padding: 0;
    align-items: flex-end;
  }
  .modal-body {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    padding: 20px;
    margin: 0;
    animation: slideUp 0.25s ease;
  }
  .po-modal-wide { width: 100% !important; }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* 按钮行 */
  .btn-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .btn-row .btn {
    flex: 1 1 calc(50% - 4px);
    text-align: center;
    padding: 10px 12px;
    font-size: 14px;
  }

  /* 仪表盘行堆叠 */
  .dashboard-row {
    grid-template-columns: 1fr !important;
  }

  /* 状态行堆叠 */
  .po-status-row {
    flex-direction: column;
    align-items: stretch;
  }
  .po-status-row select {
    min-width: 0;
    width: 100%;
  }

  /* 侧边栏用户区域 */
  .sidebar-user {
    padding: 14px 12px;
  }

  /* 操作按钮在表格内 */
  #materials-table .material-actions {
    grid-template-columns: 1fr;
  }

  /* checkbox 列表适配 */
  .scroll-checkbox-list { max-height: 160px; }
  .checkbox-group {
    flex-direction: column;
    align-items: flex-start;
  }

  /* 按钮触摸目标 */
  .btn { padding: 10px 14px; font-size: 14px; min-height: 40px; }
  .btn.sm { padding: 8px 10px; font-size: 12px; min-height: 32px; }

  /* 提示文字 */
  .muted-hint { font-size: 12px; line-height: 1.5; }

  /* 表格内链接和按钮 */
  .dash-table a, table a { font-size: 13px; }

  /* 采购订单/销售订单列表保持滚动 */
  .card:not(.table-scroll) > table[style*="display: block"],
  .card:not(.table-scroll) > table[style*="display:block"] {
    white-space: nowrap;
  }
  /* 项目详情页两栏变单栏 */
  .detail-two-col { grid-template-columns: 1fr !important; }
  .detail-info-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ── 小手机 (≤480px) 进一步优化 ── */
@media (max-width: 480px) {
  .mobile-topbar-title { font-size: 14px; }
  .page-header h1 { font-size: 16px; }
  .card { padding: 8px; }
  .grid-cards { grid-template-columns: 1fr; gap: 8px; }
  .grid-cards .card p { font-size: 18px; }
  .btn-row .btn { flex: 1 1 100%; }
  .modal-body { padding: 12px; }
  .detail-info-grid { grid-template-columns: 1fr !important; }
}
