/* ============================================================
 * 库存管理系统 Demo — 样式（零依赖，原生 CSS）
 * ============================================================ */
:root {
  --primary: #2f6bff;
  --primary-dark: #1e50cc;
  --primary-light: #eaf0ff;
  --success: #1f9d63;
  --success-bg: #e7f7ef;
  --warning: #e8a13c;
  --warning-bg: #fdf4e4;
  --danger: #e05252;
  --danger-bg: #fdecec;
  --info: #3aa5d8;
  --info-bg: #e8f5fb;
  --text: #1f2733;
  --text-2: #5b6572;
  --text-3: #9aa3af;
  --border: #e3e8ef;
  --bg: #f4f6fa;
  --card-bg: #ffffff;
  --sidebar-bg: #1c2536;
  --sidebar-text: #9aa7ba;
  --sidebar-active: #2f6bff;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(28, 37, 54, 0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
}

/* ---------------- 布局 ---------------- */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 224px;
  background: var(--sidebar-bg); color: #dfe5ef; z-index: 50;
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #3b82f6, #1e50cc);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.brand-text b { display: block; font-size: 16px; color: #fff; }
.brand-text span { font-size: 11px; color: var(--sidebar-text); }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-group { font-size: 11px; color: #5f6b7f; padding: 14px 10px 6px; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  color: var(--sidebar-text); text-decoration: none; border-radius: 8px;
  font-size: 13.5px; margin-bottom: 2px; transition: all .15s;
}
.nav-item .nav-ico { width: 18px; text-align: center; font-size: 14px; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: var(--sidebar-active); font-weight: 600; }
.sidebar-foot { padding: 12px 18px; font-size: 11px; color: #5f6b7f; border-top: 1px solid rgba(255,255,255,.06); }

.main { margin-left: 224px; min-height: 100vh; transition: margin .25s ease; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px; height: 56px; padding: 0 20px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-user { color: var(--text-2); font-size: 13px; }
.icon-btn {
  display: none; background: none; border: 1px solid var(--border);
  border-radius: 8px; width: 34px; height: 34px; font-size: 15px; cursor: pointer; color: var(--text-2);
}

.page { display: none; padding: 20px 22px 40px; max-width: 1400px; margin: 0 auto; }
.page.active { display: block; }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.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(--text-3); font-weight: 400; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 820px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* 统计卡片 */
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat-card .label { font-size: 12.5px; color: var(--text-2); }
.stat-card .value { font-size: 26px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.stat-card .desc { font-size: 12px; color: var(--text-3); }
.stat-card .value.danger { color: var(--danger); }
.stat-card .value.warn { color: var(--warning); }
.stat-card .value.success { color: var(--success); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
  font-size: 13px; cursor: pointer; transition: all .15s; font-family: inherit;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f3c6c6; }
.btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.success:hover { opacity: .9; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 表格 */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 9px 10px; background: #f7f9fc; color: var(--text-2);
  font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--border);
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
.tbl tr:hover td { background: #fafbff; }
.tbl .num { font-variant-numeric: tabular-nums; text-align: right; }
.tbl th.num { text-align: right; }
.tbl .money { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.money { text-align: right; }
.tbl .actions { white-space: nowrap; text-align: right; }

/* 标签 */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.tag.success { background: var(--success-bg); color: var(--success); }
.tag.warn { background: var(--warning-bg); color: var(--warning); }
.tag.danger { background: var(--danger-bg); color: var(--danger); }
.tag.info { background: var(--info-bg); color: var(--info); }
.tag.plain { background: #eef1f6; color: var(--text-2); }
.tag.clickable { cursor: pointer; }
.tag.clickable:hover { filter: brightness(.95); }

/* 表单 */
.form-row { margin-bottom: 13px; }
.form-row label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.form-row label .req { color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--text); background: #fff; outline: none; transition: border .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
select.input { cursor: pointer; }
.input[type=number] { font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* 弹窗 */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 100; background: rgba(20,28,45,.5);
  align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 640px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .18s ease;
}
.modal.lg { max-width: 860px; }
@keyframes pop { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15.5px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-3); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px 20px; max-height: 62vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* 明细表格（单据行编辑） */
.line-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.line-table th { text-align: left; padding: 6px 6px; background: #f7f9fc; border-bottom: 1px solid var(--border); white-space: nowrap; }
.line-table td { padding: 5px 6px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
.line-table .input { padding: 5px 7px; font-size: 12.5px; }

/* Toast */
.toast-wrap { position: fixed; top: 66px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #243044; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: slidein .25s ease; max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warning); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 工具栏 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.search { position: relative; }
.search input { width: 240px; padding: 7px 12px 7px 32px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none; }
.search input:focus { border-color: var(--primary); }
.search::before { content: "⌕"; position: absolute; left: 11px; top: 5px; font-size: 15px; color: var(--text-3); }

/* Tab */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 14px; }
.tab { padding: 8px 16px; font-size: 13.5px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }

/* 图表 */
.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

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

/* 详情/流水列表 */
.flow-list { font-size: 13px; }
.flow-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed #eef1f6; }
.flow-item:last-child { border-bottom: none; }
.flow-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.flow-dot.in { background: var(--success); }
.flow-dot.out { background: var(--danger); }
.flow-dot.tf { background: var(--info); }
.flow-main { flex: 1; min-width: 0; }
.flow-remark { font-size: 12px; color: var(--text-3); }
.flow-time { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.flow-qty { font-weight: 600; white-space: nowrap; }
.flow-qty.in { color: var(--success); }
.flow-qty.out { color: var(--danger); }

/* 预警条 */
.alert-banner { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.alert-banner.danger { background: var(--danger-bg); color: var(--danger); }
.alert-banner.warn { background: var(--warning-bg); color: #b2741a; }

/* 进度/库存条 */
.bar { height: 8px; border-radius: 999px; background: #eef1f6; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; border-radius: 999px; }

/* 辅助类 */
.text-3 { color: var(--text-3); font-size: 12.5px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.chk input { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }
.tf-path { display: flex; align-items: center; gap: 8px; }
.tf-path span { color: var(--text-3); }
.wh-info { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 12.5px; margin-bottom: 12px; }
.wh-stats { display: flex; gap: 26px; border-top: 1px dashed var(--border); padding-top: 12px; }
.wh-stats div { display: flex; flex-direction: column; }
.wh-stats b { font-size: 19px; font-variant-numeric: tabular-nums; }
.wh-stats span { font-size: 11.5px; color: var(--text-3); }
.quick-alert { list-style: none; }
.quick-alert li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed #eef1f6; font-size: 13px; }
.quick-alert li:last-child { border-bottom: none; }
.quick-alert b { font-variant-numeric: tabular-nums; }
.unit-label { color: var(--text-2); font-size: 12px; }

/* 响应式 */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .main { margin-left: 0; }
  .icon-btn { display: block; }
  .page { padding: 16px 14px 36px; }
}
