/* ---- 设计变量 ---- */
:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --ink: #1a2233;
  --ink-2: #5b6478;
  --ink-3: #9aa3b5;
  --line: #e4e8f0;
  --accent: #4f5ce5;
  --accent-ink: #fff;
  --accent-soft: #eef0ff;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --red: #dc2626;
  --red-soft: #fdecec;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --blue: #2563eb;
  --blue-soft: #e9f1fe;
  --gray-soft: #eef1f6;
  --sidebar: #171d2e;
  --sidebar-ink: #aab3c8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(23, 29, 46, .07);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.55 -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- 布局 ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; flex: none; background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  padding: 20px 20px 16px; color: #fff; font-size: 17px; font-weight: 700; letter-spacing: .5px;
  display: flex; align-items: center; gap: 9px;
}
.sidebar .brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.nav { flex: 1; padding: 6px 10px; overflow-y: auto; }
.nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #5d6780; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 1px 0;
  color: var(--sidebar-ink); border-radius: 8px; font-size: 13.5px;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a .ico { width: 17px; text-align: center; opacity: .9; }
.sidebar .foot { padding: 14px 20px; font-size: 12px; color: #4d5670; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 0 24px; height: 54px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
}
.topbar .crumb { font-size: 15px; font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 14px; color: var(--ink-2); font-size: 13px; }
.content { padding: 22px 24px 40px; }

/* ---- 卡片 ---- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.card + .card { margin-top: 16px; }
.card .card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.card .card-body { padding: 16px 18px; }

/* ---- 看板 ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat .label { color: var(--ink-2); font-size: 13px; display: flex; justify-content: space-between; }
.stat .value { font-size: 24px; font-weight: 700; margin: 6px 0 8px; font-variant-numeric: tabular-nums; }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }
.stat .bar { height: 5px; border-radius: 3px; background: var(--gray-soft); overflow: hidden; margin-bottom: 8px; }
.stat .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.stat .sub { font-size: 12.5px; color: var(--ink-3); display: flex; justify-content: space-between; }
.stat .sub + .sub { margin-top: 3px; }

/* ---- 表单控件 ---- */
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; outline: none; transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { font-size: 13px; color: var(--ink-2); }

.btn {
  font: inherit; font-size: 13.5px; cursor: pointer; border: 1px solid var(--line); background: #fff;
  color: var(--ink); border-radius: 8px; padding: 7px 14px; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.danger { color: var(--red); border-color: #f3c1c1; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.filters .f { display: flex; flex-direction: column; gap: 4px; }
.filters .f input, .filters .f select { min-width: 130px; }

/* ---- 表格 ---- */
.table-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
table.grid th {
  text-align: left; padding: 10px 10px; color: var(--ink-2); font-weight: 600; font-size: 12.5px;
  border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; position: sticky; top: 0;
}
table.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:hover td { background: #f8f9fd; }
table.grid td.num { font-variant-numeric: tabular-nums; }
.prod-cell { display: flex; align-items: center; gap: 9px; min-width: 220px; }
.prod-cell img { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; background: var(--gray-soft); flex: none; }
.prod-cell .t { max-width: 340px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---- 状态徽章 ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; cursor: pointer; border: none; font-family: inherit; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-confirmed { background: var(--blue-soft); color: var(--blue); }
.st-shipped { background: var(--amber-soft); color: var(--amber); }
.st-delivered { background: var(--green-soft); color: var(--green); }
.st-cancelled, .st-soldout { background: var(--red-soft); color: var(--red); }
.st-returning, .st-returned { background: #f4e8fd; color: #9333ea; }
.st-transiting { background: #e0f2fe; color: #0284c7; }
.st-stored { background: var(--gray-soft); color: var(--ink-2); }
.st-listing { background: #fdf9e3; color: #a16207; }
.st-sold { background: #d1fae5; color: #047857; }

/* ---- 下拉菜单 ---- */
.dropdown { position: relative; display: inline-block; }
.dropdown .menu {
  display: none; position: absolute; z-index: 50; top: calc(100% + 4px); left: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(23,29,46,.13);
  min-width: 140px; padding: 5px; max-height: 320px; overflow-y: auto;
}
.dropdown.open .menu { display: block; }
.dropdown .menu button, .dropdown .menu label {
  display: flex; width: 100%; text-align: left; border: none; background: none; font: inherit; font-size: 13px;
  padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--ink); align-items: center; gap: 8px;
}
.dropdown .menu button:hover, .dropdown .menu label:hover { background: var(--accent-soft); }

/* ---- 分页 ---- */
.pager { display: flex; align-items: center; gap: 6px; padding: 14px 0 2px; flex-wrap: wrap; }
.pager button {
  min-width: 32px; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 7px;
  cursor: pointer; font: inherit; font-size: 13px; color: var(--ink-2);
}
.pager button.cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager .info { color: var(--ink-3); font-size: 12.5px; margin-right: 8px; }

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(23,29,46,.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px;
}
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 100%; max-height: 84vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .m-head { padding: 16px 20px; font-weight: 600; font-size: 15px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .m-head .x { cursor: pointer; color: var(--ink-3); font-size: 18px; border: none; background: none; }
.modal .m-body { padding: 18px 20px; overflow-y: auto; }
.modal .m-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 14px; }
.form-grid .f { display: flex; flex-direction: column; gap: 4px; }
.form-grid .f.full { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; }

/* ---- 提示 ---- */
#toast-box { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #232a3d; color: #fff; padding: 9px 18px; border-radius: 9px; font-size: 13.5px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: pop .18s ease;
}
.toast.err { background: var(--red); }
@keyframes pop { from { opacity: 0; transform: translateY(-8px); } }

/* ---- 库存卡片 ---- */
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.inv-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; gap: 12px; }
.inv-card img { width: 62px; height: 62px; object-fit: cover; border-radius: 8px; background: var(--gray-soft); flex: none; }
.inv-card .t { font-weight: 600; font-size: 13.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.inv-card .meta { font-size: 12.5px; color: var(--ink-2); margin-top: 5px; }
.inv-card .badges { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 5px; }

/* ---- 空状态 ---- */
.empty { text-align: center; color: var(--ink-3); padding: 46px 0; }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ---- 登录页 ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #171d2e 0%, #232a3d 60%, #2c3550 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 38px 36px 32px; width: 380px; box-shadow: 0 24px 80px rgba(0,0,0,.4); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.login-card .sub { color: var(--ink-3); font-size: 13px; margin-bottom: 22px; }
.login-card input { width: 100%; padding: 11px 12px; margin-bottom: 14px; }
.login-card .btn { width: 100%; padding: 11px; font-size: 15px; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .content { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
}
