/* 备件仓库管理系统 - 全局样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.12);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 60px; }
label { display: block; font-size: 13px; color: var(--gray-500); margin-bottom: 6px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 8px; padding: 10px 18px;
  font-size: 14px; font-weight: 500; transition: all .15s;
  background: var(--gray-200); color: var(--gray-900);
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 登录页 */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
}
.auth-card {
  background: #fff; border-radius: 16px; padding: 36px 32px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.auth-logo { font-size: 42px; text-align: center; margin-bottom: 10px; }
.auth-card h1 { font-size: 20px; text-align: center; color: var(--gray-900); }
.auth-sub { text-align: center; color: var(--gray-500); margin: 6px 0 20px; font-size: 13px; }
.auth-tabs { display: flex; background: var(--gray-100); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; border: none; background: transparent; padding: 9px 0;
  border-radius: 8px; font-size: 14px; color: var(--gray-500); font-weight: 500;
}
.auth-tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.form-item { margin-bottom: 16px; }
.auth-msg { margin-top: 14px; text-align: center; font-size: 13px; color: var(--danger); min-height: 18px; }
.auth-msg.ok { color: var(--success); }

/* 主布局 */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 220px; background: var(--gray-900); color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-head { padding: 18px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo { font-size: 22px; }
.sidebar-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 8px; margin-bottom: 4px;
  color: #cbd5e1; font-size: 14px; cursor: pointer; border: none; background: transparent; width: 100%; text-align: left;
  transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .nav-ico { font-size: 17px; width: 22px; text-align: center; }
.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.user-mini { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-mini-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; flex-shrink: 0;
}
.user-mini-info { line-height: 1.3; min-width: 0; }
.user-mini-info b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini-info span { font-size: 12px; color: #94a3b8; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff; padding: 14px 22px; display: flex; align-items: center; gap: 14px;
  border-bottom: 1px solid var(--gray-200); flex-shrink: 0;
}
.menu-toggle { display: none; border: none; background: transparent; font-size: 22px; color: var(--gray-700); }
.page-title { font-size: 18px; font-weight: 600; flex: 1; }
.balance-chip {
  background: var(--primary-light); color: var(--primary-dark);
  font-weight: 600; padding: 7px 14px; border-radius: 20px; font-size: 14px;
}
.content { flex: 1; overflow-y: auto; padding: 22px; }

/* 公告（标红） */
.announcement {
  background: var(--danger-light);
  border: 1px solid #fca5a5;
  color: var(--danger);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.8;
  font-weight: 500;
}
.announcement b { font-weight: 700; }

/* 备件分类按钮 */
.cat-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-btn {
  border: 1.5px solid var(--gray-300);
  background: #fff;
  color: var(--gray-700);
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: all .15s;
  cursor: pointer;
}
.cat-btn:hover { border-color: var(--primary); color: var(--primary); }
.cat-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.35);
}


/* 卡片与网格 */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; border: 1px solid var(--gray-200);
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-title .sub { font-size: 12px; color: var(--gray-500); font-weight: 400; }
.stat-card { padding: 18px 20px; }
.stat-label { font-size: 13px; color: var(--gray-500); margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--gray-900); }
.stat-value small { font-size: 14px; font-weight: 500; color: var(--gray-500); }
.stat-ico { font-size: 24px; }
.stat-row { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-mini { background: var(--gray-50); border-radius: 10px; padding: 14px 16px; border: 1px solid var(--gray-200); }
.stat-mini .stat-label { margin-bottom: 4px; }
.stat-mini .stat-value { font-size: 20px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
th { color: var(--gray-500); font-weight: 500; font-size: 12.5px; background: var(--gray-50); }
tr:hover td { background: var(--gray-50); }
.td-multi { white-space: normal; max-width: 320px; }

/* 徽章 */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge-pending { background: var(--warning-light); color: var(--warning); }
.badge-approved { background: var(--success-light); color: var(--success); }
.badge-rejected { background: var(--danger-light); color: var(--danger); }
.badge-shipped { background: var(--primary-light); color: var(--primary-dark); }
.badge-info { background: var(--gray-100); color: var(--gray-500); }

/* 工具条 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.toolbar input, .toolbar select { width: auto; min-width: 130px; }
.toolbar input.search { width: 200px; }

/* 列表行 */
.row-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 14px 16px; background: #fff; margin-bottom: 10px;
}
.row-item .ico { font-size: 26px; }
.row-item .main { flex: 1; min-width: 0; }
.row-item .main b { display: block; font-size: 14.5px; margin-bottom: 3px; }
.row-item .main span { font-size: 12.5px; color: var(--gray-500); display: block; line-height: 1.5; }

/* 图片 */
.img-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--gray-200); background: var(--gray-100); cursor: zoom-in; }
.img-photo { height: 64px; width: auto; max-width: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--gray-200); cursor: zoom-in; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr-box img { width: 220px; height: 220px; object-fit: contain; border: 1px solid var(--gray-200); border-radius: 12px; background: #fff; }
.qr-placeholder {
  width: 220px; height: 220px; border: 2px dashed var(--gray-300); border-radius: 12px;
  display: flex; align-items: center; justify-content: center; color: var(--gray-500);
  flex-direction: column; gap: 8px; background: var(--gray-50); font-size: 13px;
}

/* 空状态 */
.empty { text-align: center; color: var(--gray-500); padding: 50px 20px; }
.empty .empty-ico { font-size: 44px; margin-bottom: 12px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  padding: 24px;
}
.modal-lg { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { font-size: 17px; }
.modal-close { border: none; background: transparent; font-size: 22px; color: var(--gray-500); line-height: 1; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Toast */
#toast-root { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--gray-900); color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow-lg); animation: toastIn .25s ease;
  max-width: 80vw; text-align: center;
}
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px);} to { opacity: 1; transform: translateY(0);} }

/* 金额 */
.money { font-weight: 600; font-variant-numeric: tabular-nums; }
.money-in { color: var(--success); }
.money-out { color: var(--danger); }

/* 备件卡片 */
.parts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.part-card {
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 16px; transition: box-shadow .15s; display: flex; flex-direction: column; gap: 8px;
}
.part-card:hover { box-shadow: var(--shadow-lg); }
.part-card .name { font-size: 15px; font-weight: 600; }
.part-card .meta { font-size: 12.5px; color: var(--gray-500); }
.part-card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.part-card .price { color: var(--danger); font-size: 16px; font-weight: 700; }
.retail-price { color: var(--gray-500); }
.form-tip { font-size: 12.5px; color: var(--gray-500); background: var(--gray-50); border-radius: 6px; padding: 8px 10px; margin: -4px 0 10px; line-height: 1.6; }
.import-summary { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 12px; font-size: 13.5px; line-height: 1.9; }
.import-summary .import-errors { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--gray-300); color: var(--danger); font-size: 12.5px; line-height: 1.7; max-height: 200px; overflow: auto; }
.part-card .stock { font-size: 12.5px; }
.stock-low { color: var(--danger); font-weight: 600; }

/* 响应式 */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 90; transform: translateX(-100%); transition: transform .25s; width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .content { padding: 14px; }
  .topbar { padding: 12px 14px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
  .toolbar input.search { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input, .toolbar select { width: 100%; }
  .parts-grid { grid-template-columns: 1fr 1fr; }
  .hide-mobile { display: none !important; }
  .cat-btns { justify-content: center; }
  .cat-btn { flex: 1; padding: 8px 8px; font-size: 13px; text-align: center; }
}

/* 扫码：摄像头取景框 + 扫中卡片高亮 */
.scan-box { position: relative; width: 100%; background: #0b0b0b; border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.scan-box video { width: 100%; max-height: 340px; display: block; object-fit: cover; }
.scan-frame {
  position: absolute; left: 50%; top: 50%; width: 66%; height: 32%;
  border: 2px solid var(--success); border-radius: 8px; transform: translate(-50%, -50%);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .38);
}
.scan-hint { font-size: 12.5px; color: var(--gray-500); margin: 4px 0 14px; line-height: 1.7; }
.part-card.scan-hit { border-color: var(--success); box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }

/* 盘点：实盘数量输入 + 差异着色 + 扫码定位高亮 */
.count-input {
  width: 88px; padding: 6px 8px; text-align: center; font-size: 14px;
  border: 1.5px solid var(--gray-300); border-radius: 8px; background: #fff;
}
.count-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
tr.count-row.has-diff td { background: #fffbeb; }
tr.count-row.hl td { background: var(--success-light); }
.diff-pos { color: var(--success); font-weight: 600; }
.diff-neg { color: var(--danger); font-weight: 600; }
#ct-sum b { font-size: 15px; }

/* 入库/出库：常用备注快捷标签 */
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -6px 0 16px; }
.chip-label { font-size: 12.5px; color: var(--gray-500); }
.chip {
  padding: 5px 11px; border-radius: 999px; font-size: 13px; line-height: 1.4;
  border: 1px solid var(--gray-300); background: var(--gray-50); color: var(--gray-600); cursor: pointer;
}
.chip:hover { border-color: var(--primary); color: var(--primary); background: #fff; }
.chip:active { transform: scale(.97); }
