:root {
  --blue: #2563eb;
  --blue-d: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --yellow: #d97706;
  --red: #dc2626;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
       background: var(--bg); color: var(--text); font-size: 14px; }
#app { min-height: 100vh; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p { color: var(--muted); margin-bottom: 24px; }
.login-card input { width: 100%; padding: 12px; border: 1.5px solid var(--border);
  border-radius: 8px; margin-bottom: 14px; font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--blue); }
.login-card button { width: 100%; padding: 12px; background: var(--blue); color: #fff;
  border: none; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; }
.login-card button:hover { background: var(--blue-d); }
.login-err { color: var(--red); margin-bottom: 12px; font-size: 13px; }

/* ---- layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: #0f172a; color: #cbd5e1; padding: 20px 0;
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; z-index: 10; }
.sidebar .brand { padding: 0 20px 20px; border-bottom: 1px solid #1e293b; }
.sidebar .brand b { color: #fff; font-size: 17px; }
.sidebar .brand span { font-size: 11px; color: #64748b; display: block; }
.nav-item { padding: 12px 20px; cursor: pointer; font-size: 14px; display: flex;
  justify-content: space-between; align-items: center; }
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; font-weight: 600; }
.nav-badge { background: var(--red); color: #fff; border-radius: 10px; padding: 1px 8px;
  font-size: 11px; }
.sidebar .foot { margin-top: auto; padding: 16px 20px; border-top: 1px solid #1e293b;
  font-size: 12px; color: #64748b; }
.sidebar .foot button { margin-top: 8px; width: 100%; padding: 7px; background: #1e293b;
  color: #cbd5e1; border: none; border-radius: 6px; cursor: pointer; }
.main { flex: 1; margin-left: 210px; padding: 24px; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

/* ---- cards / grids ---- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px;
  border: 1px solid var(--border); margin-bottom: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px;
  border: 1px solid var(--border); }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat .value.warn { color: var(--red); }

/* ---- table ---- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border);
  font-size: 13px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tr:hover td { background: #f8fafc; }
.mono { font-family: ui-monospace, Consolas, monospace; }

/* ---- status dots ---- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: var(--green); }
.dot.low { background: var(--yellow); }
.dot.out { background: var(--red); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.tag.ok { background: #dcfce7; color: var(--green); }
.tag.low { background: #fef3c7; color: var(--yellow); }
.tag.out { background: #fee2e2; color: var(--red); }
.tag.rev { background: #f1f5f9; color: var(--muted); text-decoration: line-through; }

/* ---- buttons / inputs ---- */
.btn { padding: 8px 16px; border-radius: 8px; border: 1.5px solid var(--border);
  background: #fff; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 600; }
.btn.primary:hover { background: var(--blue-d); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 12px; }
input, select { padding: 8px 10px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; background: #fff; }
input:focus, select:focus { outline: none; border-color: var(--blue); }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }

/* ---- scan page ---- */
.scan-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.scan-input { width: 100%; font-size: 22px; padding: 16px; letter-spacing: 1px;
  border: 2.5px solid var(--blue); border-radius: 12px; font-weight: 700; }
.scan-input:focus { outline: none; box-shadow: 0 0 0 4px rgba(37,99,235,.15); }
.scan-mode { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; align-items: center; }
.scan-found { border: 2px solid var(--green); border-radius: 12px; padding: 16px; margin-top: 14px;
  background: #f0fdf4; }
.scan-found .fname { font-size: 18px; font-weight: 800; }
.scan-found .fmeta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.scan-found .fnums { display: flex; gap: 26px; margin-top: 12px; }
.scan-found .fnums .n { font-size: 24px; font-weight: 800; }
.scan-found .fnums .l { font-size: 11px; color: var(--muted); }
.flash-ok { background: #dcfce7; border-radius: 8px; padding: 10px 14px; margin-top: 12px;
  color: var(--green); font-weight: 700; }
.flash-err { background: #fee2e2; border-radius: 8px; padding: 10px 14px; margin-top: 12px;
  color: var(--red); font-weight: 700; }
.hint { background: #eff6ff; border-radius: 10px; padding: 14px; color: #1e40af;
  font-size: 13px; line-height: 1.8; }
.switch { display: flex; align-items: center; gap: 6px; font-size: 13px; }

/* ---- product accordion ---- */
.prod-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  cursor: pointer; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 6px; }
.prod-head:hover { border-color: var(--blue); }
.prod-head.open { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: none; }
.prod-head .pname { font-weight: 700; font-size: 15px; }
.prod-head .pcat { color: var(--muted); font-size: 12px; }
.prod-head .ptotal { margin-left: auto; font-weight: 800; font-size: 16px; }
.prod-body { border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius);
  background: #fbfdff; padding: 4px 16px 12px; margin-bottom: 6px; }
.store-cols td { text-align: center; }
.store-cols th { text-align: center; }

/* ---- misc ---- */
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.col { flex: 1; min-width: 200px; }
label.f { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
label.f + input, label.f + select { width: 100%; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; justify-content: flex-end; }
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 420px;
  max-width: 92vw; max-height: 86vh; overflow: auto; }
.modal h3 { margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.tab { padding: 8px 16px; cursor: pointer; font-size: 14px; border-bottom: 2.5px solid transparent;
  margin-bottom: -2px; color: var(--muted); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---- 手机端适配：侧边栏变底部导航，内容单列 ---- */
/* 手机端顶部用户栏（默认隐藏，手机才显示） */
.mobile-topbar {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: #0f172a; color: #fff; padding: 10px 14px;
  justify-content: space-between; align-items: center; font-size: 13px;
}
.mobile-topbar .btn { background: #1e293b; color: #cbd5e1; border: none; }

@media (max-width: 860px) {
  .mobile-topbar { display: flex; }
  .main { margin-top: 48px; }
  .layout { flex-direction: column; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; height: 56px; flex-direction: row; padding: 0;
    overflow-x: auto; z-index: 50; align-items: center;
  }
  .sidebar .brand, .sidebar .foot { display: none; }
  .nav-item {
    padding: 8px 12px; font-size: 12px; white-space: nowrap;
    flex-direction: column; gap: 2px; align-items: center; flex-shrink: 0;
  }
  .nav-item.active { background: none; color: #fff; border-top: 2px solid var(--blue); }
  .nav-badge { position: absolute; top: 2px; right: 6px; }
  .main { margin-left: 0; margin-bottom: 64px; padding: 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat .value { font-size: 20px; }
  .row { flex-direction: column; }
  .row .col, .col.card { max-width: 100% !important; }
  .scan-grid { grid-template-columns: 1fr; }
  /* 表格可横向滑动 */
  .card table { display: block; overflow-x: auto; white-space: nowrap; }
  .toolbar { flex-wrap: wrap; gap: 6px; }
  .page-title { font-size: 17px; }
  /* 调拨/库存等宽表格保持可读 */
  .store-cols td, .store-cols th { padding: 6px 8px; font-size: 12px; }
}
