* { box-sizing: border-box; font-family: system-ui, 'Segoe UI', Roboto, sans-serif; }
body { background: #f2f5f9; margin: 0; padding: 24px 16px; }
.app { max-width: 1200px; margin: 0 auto; }
h1 { font-size: 1.9rem; color: #1e2a3a; margin: 0 0 6px; }
.sub { color: #4b5e71; margin-bottom: 28px; border-left: 4px solid #2c7be5; padding-left: 14px; }

/* ============================================================
   顶部导航
   ============================================================ */
.top-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.top-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nav-link { text-decoration: none; padding: 9px 20px; border-radius: 40px; color: #1e2a3a; font-weight: 500; font-size: .92rem; background: #fff; border: 1px solid #cbd5e1; transition: .15s; }
.nav-link:hover { background: #f8fafc; }
.nav-link.active { background: #1e5eb0; color: #fff; border-color: #1e5eb0; }

.user-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 14px;
  background: #f2f7ff;
  border-radius: 40px;
  font-size: .88rem;
  color: #1e5eb0;
  font-weight: 600;
  border: 1px solid #d3e4f8;
  line-height: 1;
}
.user-info .user-name {
  display: inline-flex;
  align-items: center;
  height: 26px;
  line-height: 26px;
  white-space: nowrap;
}
.user-info .user-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: .95rem;
  text-decoration: none;
  color: inherit;
  transition: background .15s;
  line-height: 1;
  padding: 0;
}
.user-info .user-link:hover { background: #d6e7ff; }

/* ============================================================
   卡片通用
   ============================================================ */
.card { background: #fff; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,20,40,.08); padding: 24px; margin-bottom: 30px; border: 1px solid #e9eef3; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.card-header h2 { font-size: 1.3rem; margin: 0; color: #1a2c3e; }

.btn { border: none; border-radius: 40px; padding: 9px 20px; font-weight: 500; font-size: .9rem; cursor: pointer; border: 1px solid #cbd5e1; background: #fff; color: #1e2a3a; }
.btn-primary { background: #1e5eb0; border-color: #1e5eb0; color: #fff; }
.btn-primary:hover { background: #154a8a; }
.btn-outline:hover { background: #f8fafc; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }

/* ============================================================
   录入区：meta 字段 + 物品表格 + 优惠行
   ============================================================ */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(170px,1fr)); gap: 18px; margin-bottom: 24px; background: #f9fcff; padding: 18px; border-radius: 18px; border: 1px solid #dde7f0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .8rem; font-weight: 600; color: #4e6a85; }
.field input { padding: 10px 14px; border: 1px solid #cfddee; border-radius: 14px; font-size: .95rem; outline: none; }
.field input:focus { border-color: #1e5eb0; box-shadow: 0 0 0 3px rgba(30,94,176,.15); }

.items-table { width: 100%; border-collapse: collapse; border-radius: 14px; overflow: hidden; border: 1px solid #e2eaf2; }
.items-table th { background: #f0f6fe; font-weight: 600; font-size: .85rem; color: #1f3b5c; text-align: left; padding: 12px 14px; border-bottom: 1px solid #d0ddee; }
.items-table td { padding: 8px 10px; border-bottom: 1px solid #e9eff6; }
.items-table tr:last-child td { border-bottom: none; }
.items-table input { width: 100%; border: 1px solid #d9e2ef; border-radius: 12px; padding: 9px 12px; font-size: .9rem; outline: none; }
.items-table input:focus { border-color: #1e5eb0; box-shadow: 0 0 0 2px rgba(30,94,176,.1); }
.items-table input[readonly] { background: #f5f8fc; font-weight: 500; }

.remove-item-btn { background: transparent; border: 1px solid #f1c4c4; color: #b91c1c; width: 32px; height: 32px; border-radius: 10px; cursor: pointer; font-size: 1rem; }
.remove-item-btn:hover { background: #fef2f2; }

.items-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; flex-wrap: wrap; gap: 12px; }
.total-badge { background: #e9f1fe; padding: 10px 24px; border-radius: 40px; font-size: 1.15rem; font-weight: 700; color: #0a2a4a; border: 1px solid #b7d0f0; }
.total-badge span { font-weight: 400; font-size: .9rem; color: #336699; margin-right: 8px; }

.discount-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding: 18px 20px; flex-wrap: wrap; gap: 16px;
  background: linear-gradient(135deg, #fff9ed, #fffaf5);
  border: 1px dashed #f0c48a; border-radius: 18px;
}
.discount-input-wrap { display: flex; flex-direction: column; gap: 6px; flex: 1 1 300px; }
.discount-input-wrap > label { font-size: .85rem; font-weight: 600; color: #7a4a00; }
.discount-input-box { display: flex; align-items: center; background: #fff; border: 1px solid #eab676; border-radius: 14px; padding: 0 14px; max-width: 260px; }
.discount-input-box .prefix { color: #b45309; font-weight: 600; margin-right: 6px; }
.discount-input-box input { border: none; outline: none; padding: 11px 0; font-size: 1.05rem; font-weight: 600; color: #7a4a00; width: 100%; background: transparent; }
.discount-input-box input:focus { outline: none; }
.discount-hint { font-size: .75rem; color: #b98a4a; }

.final-badge {
  background: linear-gradient(135deg, #0d8a6a, #14a37f);
  color: #fff; padding: 12px 28px; border-radius: 40px;
  font-size: 1.25rem; font-weight: 700;
  box-shadow: 0 6px 16px rgba(20,163,127,.3);
  white-space: nowrap;
}
.final-badge span { font-weight: 400; font-size: .9rem; opacity: .9; margin-right: 8px; }

/* ============================================================
   查询：全选栏 + 搜索框
   ============================================================ */
.select-all-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  margin-bottom: 14px;
  background: #f9fcff;
  border: 1px dashed #dde7f0;
  border-radius: 12px;
  font-size: .88rem;
  color: #4e6a85;
}
.select-all-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.select-all-bar input[type="checkbox"] {
  transform: scale(1.15);
  cursor: pointer;
}
.select-all-bar .selected-count {
  color: #1e5eb0;
  font-weight: 600;
  margin-left: auto;
}

.search-input { width: 100%; padding: 12px 18px; border-radius: 40px; border: 1px solid #cfddee; font-size: .95rem; outline: none; margin-bottom: 18px; }
.search-input:focus { border-color: #1e5eb0; box-shadow: 0 0 0 3px rgba(30,94,176,.1); }

/* ============================================================
   采购单卡片
   ============================================================ */
.order-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid #dfe9f2;
  border-left: 3px solid #dfe9f2;
  padding: 14px 18px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 8px 12px;
  transition: background .18s, border-color .18s, box-shadow .18s, transform .18s;
  cursor: default;
}
.order-card:hover {
  background: #eaf3ff;
  border-color: #7fb0e8;
  border-left: 5px solid #1e5eb0;
  box-shadow: 0 10px 26px rgba(30,94,176,.18);
  transform: translateY(-1px);
}
.order-card:hover .order-title { color: #0a3a7a; }
.order-card:hover .order-meta span { background: #d6e7ff; color: #1a4a8a; }
.order-card:hover .order-total { background: #d6f5e8; }

.order-info {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  align-self: center;
}
.order-title { font-weight: 700; font-size: 1.05rem; color: #1d2f44; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }

/* meta 行 */
.order-meta {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed #e5eef8;
  font-size: .82rem;
  color: #4d6a8c;
  min-width: 0;
}
.order-meta span {
  background: #f2f7ff;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 700px) {
  .order-meta { flex-wrap: wrap; }
}

/* 商品明细 */
.order-items-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 18px;
  margin-top: 10px;
  font-size: .8rem;
}
.order-items-grid .item-head {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 0;
  border-bottom: 1px solid #dbe7f3;
  margin-bottom: 2px;
}
.order-items-grid .item-head .head-half {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px 62px 70px;
  gap: 6px;
  padding: 3px 8px 5px 8px;
  font-size: .72rem;
  color: #8aa0b8;
  letter-spacing: .3px;
}
.order-items-grid .item-head .head-half span { text-align: right; white-space: nowrap; }
.order-items-grid .item-head .head-half span:first-child { text-align: left; }

.order-items-grid .item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px 62px 70px;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-bottom: 1px dashed #e5eef8;
  min-width: 0;
}
.order-items-grid .item-row:last-child { border-bottom: none; }

.order-items-grid .item-row .name { min-width: 0; color: #1d2f44; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-items-grid .item-row .qty { color: #2c7be5; text-align: right; white-space: nowrap; }
.order-items-grid .item-row .price { color: #5b7a9a; text-align: right; white-space: nowrap; }
.order-items-grid .item-row .subtotal { color: #0d8a6a; font-weight: 600; text-align: right; white-space: nowrap; }

.order-items-grid .item-empty {
  grid-column: 1 / -1;
  color: #8aa0b8;
  padding: 6px 8px;
  font-size: .82rem;
}
@media (max-width: 700px) {
  .order-items-grid { grid-template-columns: 1fr; }
  .order-items-grid .item-head { display: none; }
}

/* 右侧金额 + 按钮 */
.order-total {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  font-weight: 700; font-size: 1.25rem; color: #0d8a6a;
  background: #e6f7f1; padding: 8px 20px; border-radius: 40px;
  border: 1px solid #a8ddc9; white-space: nowrap;
  transition: background .18s;
}

.order-price-block {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 18px; background: #f9fcff; border-radius: 14px;
  border: 1px solid #dde7f0; min-width: 170px;
}
.price-line { display: flex; justify-content: space-between; gap: 14px; font-size: .85rem; }
.price-line .price-label { color: #6a8097; }
.price-old { color: #849ab0; text-decoration: line-through; }
.price-discount { color: #b45309; font-weight: 600; }
.price-line.final { margin-top: 4px; padding-top: 6px; border-top: 1px dashed #cfe0ef; font-size: 1rem; }
.price-line.final .price-label { color: #1a2c3e; font-weight: 600; }
.price-final { color: #0d8a6a; font-weight: 700; font-size: 1.1rem; }

.order-actions {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  display: flex; gap: 8px;
}

/* ============================================================
   通用
   ============================================================ */
.empty-state { text-align: center; padding: 50px 20px; color: #5b7a9a; background: #fafdff; border-radius: 20px; border: 1px dashed #b9cee6; }
.badge { background: #e2eaf6; color: #1e5eb0; font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 30px; margin-left: 8px; }
.badge-discount { background: #fff1d9; color: #b45309; }

/* ============================================================
   统计页：筛选面板
   ============================================================ */
.filter-panel {
  background: #f9fcff;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid #dde7f0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}
.filter-row + .filter-row {
  padding-top: 14px;
  border-top: 1px dashed #dde7f0;
}
.filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
}
.filter-item label {
  font-size: .74rem;
  color: #4e6a85;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.filter-item input {
  padding: 0 10px;
  font-size: .85rem;
  height: 34px;
  line-height: 32px;
  min-width: 130px;
  border: 1px solid #cfddee;
  border-radius: 12px;
  outline: none;
  box-sizing: border-box;
  background: #fff;
}
.filter-item input:focus {
  border-color: #1e5eb0;
  box-shadow: 0 0 0 3px rgba(30,94,176,.12);
}
.filter-item input[type="date"] {
  min-width: 140px;
}
.filter-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
  height: 34px;
}
.filter-actions .btn {
  height: 34px;
  padding: 0 20px;
  font-size: .85rem;
  line-height: 1;
  box-sizing: border-box;
  white-space: nowrap;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   统计页：汇总卡片 / 明细表
   ============================================================ */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 30px; }
.summary-card { background: linear-gradient(135deg, #1e5eb0, #2c7be5); color: #fff; border-radius: 18px; padding: 22px; box-shadow: 0 8px 20px rgba(30,94,176,.2); }
.summary-label { font-size: .85rem; opacity: .9; margin-bottom: 8px; }
.summary-value { font-size: 1.7rem; font-weight: 700; }

.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid #e2eaf2; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: #f0f6fe; font-weight: 600; font-size: .85rem; color: #1f3b5c; text-align: left; padding: 12px 16px; border-bottom: 1px solid #d0ddee; white-space: nowrap; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid #e9eff6; font-size: .92rem; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafdff; }
.data-table .money { font-weight: 600; color: #1e5eb0; }
.empty-row { text-align: center; color: #849ab0; padding: 40px !important; }

.pct-bar-wrap { position: relative; background: #eef4fb; border-radius: 20px; height: 24px; min-width: 120px; overflow: hidden; }
.pct-bar { height: 100%; background: linear-gradient(90deg, #0d8a6a, #14a37f); border-radius: 20px; transition: width .3s; }
.pct-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: .78rem; font-weight: 600; color: #0a2a4a; }

/* ============================================================
   物品名称输入建议（自定义下拉，输入才显示）
   ============================================================ */
.name-cell {
  position: relative;
}
.name-suggest {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid #cfddee;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(30,94,176,.15);
  max-height: 240px;
  overflow-y: auto;
  margin-top: 4px;
}
.name-suggest-item {
  padding: 8px 14px;
  font-size: .88rem;
  color: #1d2f44;
  cursor: pointer;
  border-bottom: 1px solid #f0f5fb;
}
.name-suggest-item:last-child {
  border-bottom: none;
}
.name-suggest-item:hover {
  background: #eaf3ff;
  color: #1e5eb0;
}