/* ===== 进销存系统全局样式(浅色主题) ===== */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --info: #2563eb;
  --info-light: #eff6ff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .15);
}

* { 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);
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
.hidden { display: none !important; }
input, select, textarea { font-family: inherit; }

/* ===== 登录页(商务风格) ===== */
.login-page {
  position: relative;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(59,130,246,.35), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(30,64,175,.45), transparent 55%),
    linear-gradient(135deg, #0b1f3a 0%, #123c6e 55%, #1a4f8f 100%);
}
.login-deco {
  position: absolute; border-radius: 50%; pointer-events: none;
  border: 1px solid rgba(255,255,255,.08);
}
.login-deco-1 { width: 520px; height: 520px; top: -160px; right: -120px; }
.login-deco-2 { width: 420px; height: 420px; bottom: -140px; left: -100px; }
.login-wrap {
  position: relative; z-index: 1;
  display: flex; align-items: stretch; gap: 0;
  width: 960px; max-width: 94vw; min-height: 520px;
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(2, 12, 32, .45);
}
/* 左侧品牌区 */
.login-brand {
  flex: 1.15; color: #fff;
  padding: 56px 48px;
  display: flex; flex-direction: column; justify-content: center;
  background: linear-gradient(160deg, rgba(255,255,255,.06), rgba(255,255,255,0));
}
.brand-logo {
  width: 72px; height: 72px; border-radius: 18px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 10px 24px rgba(37,99,235,.45);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px; font-weight: 700;
}
.brand-logo-txt { font-size: 20px; letter-spacing: 2px; color: #fff; }
.brand-name { font-size: 30px; font-weight: 700; letter-spacing: 1px; margin-bottom: 6px; }
.brand-ver {
  display: inline-block; align-self: flex-start;
  font-size: 12px; padding: 3px 12px; border-radius: 20px;
  background: rgba(255,255,255,.14); color: #dbeafe;
  border: 1px solid rgba(255,255,255,.18); margin-bottom: 18px;
}
.brand-slogan { font-size: 14px; color: rgba(255,255,255,.72); margin-bottom: 30px; line-height: 1.8; }
.brand-points { list-style: none; }
.brand-points li {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; color: rgba(255,255,255,.85);
  margin-bottom: 14px; line-height: 1.6;
}
.bp-ico { width: 20px; text-align: center; font-size: 15px; }
/* 右侧表单卡片 */
.login-card {
  width: 420px; flex-shrink: 0;
  background: var(--card); color: var(--text);
  padding: 46px 42px 32px;
  display: flex; flex-direction: column; justify-content: center;
}
.login-card-head { margin-bottom: 24px; }
.login-card-head h2 { font-size: 24px; color: var(--gray-900); font-weight: 700; margin-bottom: 8px; }
.login-sub { color: var(--gray-500); font-size: 13px; }
.login-card-foot {
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid var(--gray-100);
  text-align: center; color: var(--gray-400); font-size: 11.5px; line-height: 1.7;
}
.login-tip { text-align: center; color: var(--gray-400); font-size: 12px; margin-top: 20px; line-height: 1.7; }
.login-links { text-align: right; margin-top: 12px; }
.login-links a { font-size: 13px; color: var(--primary); }
.login-links a:hover { text-decoration: underline; }
@media (max-width: 860px) {
  .login-brand { display: none; }
  .login-card { width: 100%; }
}

/* ===== 权限编辑器(设置页) ===== */
.perm-group { margin-bottom: 14px; }
.perm-group > label { display: block; font-size: 13px; color: var(--gray-600); margin-bottom: 6px; font-weight: 500; }
.perm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.perm-grid label {
  display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-700);
  background: var(--gray-50, #f8fafc); border: 1px solid var(--gray-200); border-radius: 8px;
  padding: 7px 10px; cursor: pointer; user-select: none;
}
.perm-grid label:hover { border-color: var(--primary); }
.perm-scroll {
  max-height: 130px; overflow-y: auto; border: 1px solid var(--gray-200);
  border-radius: 8px; padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 4px 14px;
}
.perm-scroll label { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--gray-700); cursor: pointer; }
.perm-switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gray-700); cursor: pointer; }
.perm-switch input { width: auto; }
.perm-empty { color: var(--gray-400); font-size: 12px; padding: 4px 0; }
.perm-subgroup { margin-bottom: 8px; }
.perm-subgroup-title {
  font-size: 12px; color: var(--gray-500); margin-bottom: 4px; padding-left: 2px;
}
.perm-subgroup .perm-grid { grid-template-columns: repeat(2, 1fr); }

/* ===== 布局 ===== */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--gray-800);
  display: flex; flex-direction: column; color: #cbd5e1;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px; font-size: 16px; font-weight: 600; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.logo-icon { font-size: 22px; }
.menu { flex: 1; padding: 12px 10px; overflow-y: auto; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px; margin-bottom: 2px;
  color: #cbd5e1; font-size: 14px; transition: all .15s;
}
.menu-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.menu-item.active { background: var(--primary); color: #fff; font-weight: 500; }
.mi-icon { width: 20px; text-align: center; font-size: 16px; }
.menu-divider { height: 1px; background: rgba(255,255,255,.08); margin: 10px 8px; }
.sidebar-footer { padding: 14px 20px; font-size: 12px; color: #64748b; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: var(--card); border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.topbar-left h2 { font-size: 17px; color: var(--gray-900); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user { color: var(--gray-600); font-size: 13px; }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ===== 卡片 ===== */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card-title {
  font-size: 15px; font-weight: 600; color: var(--gray-900);
  margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between;
}
.card-title .sub { font-size: 12px; color: var(--gray-400); font-weight: 400; }

/* ===== 统计卡片 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat-info .stat-label { font-size: 13px; color: var(--gray-500); }
.stat-info .stat-value { font-size: 22px; font-weight: 700; color: var(--gray-900); margin-top: 2px; }
.stat-info .stat-value small { font-size: 13px; font-weight: 400; color: var(--gray-500); }
.stat-info .stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; cursor: pointer; transition: all .15s; white-space: nowrap;
  background: var(--gray-100); color: var(--gray-700);
}
.btn:hover { background: var(--gray-200); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: #fff; border-color: var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-ghost { background: transparent; color: var(--gray-500); border-color: var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 表单 ===== */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--gray-600); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--gray-300);
  border-radius: 8px; font-size: 14px; color: var(--text); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field textarea { resize: vertical; min-height: 60px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; padding: 10px 12px; background: var(--gray-50);
  color: var(--gray-600); font-weight: 600; font-size: 12.5px;
  border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .th-num { text-align: right; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions .btn { margin-left: 6px; }
.table-empty { text-align: center; color: var(--gray-400); padding: 40px 0 !important; }

/* ===== 徽章 ===== */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-green { background: var(--success-light); color: var(--success); }
.badge-blue { background: var(--info-light); color: var(--info); }
.badge-orange { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }
.badge-purple { background: var(--primary-light, #ede9fe); color: #6d28d9; }

/* ===== 分页 ===== */
.pagination {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  margin-top: 16px; font-size: 13px; color: var(--gray-600);
}
.pagination .btn { min-width: 32px; padding: 4px 10px; }
.pagination .page-info { margin-right: auto; }
.pagination .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== 搜索栏 ===== */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input[type="text"], .toolbar input[type="date"], .toolbar select {
  padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: 8px;
  font-size: 13.5px; background: #fff; color: var(--text);
}
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--primary); }
.toolbar .spacer { flex: 1; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  animation: fadeIn .15s;
}
.modal {
  background: var(--card); border-radius: 14px; width: 560px; max-width: 92vw;
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: slideUp .18s;
}
.modal.modal-lg { width: 800px; }
.modal.modal-md { width: 640px; }
.modal.modal-sm { width: 420px; }
.modal.modal-xl { width: 1000px; }
.modal-header {
  padding: 16px 22px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; color: var(--gray-900); font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 20px; color: var(--gray-400);
  cursor: pointer; line-height: 1; padding: 4px;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Toast ===== */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 18px; border-radius: 10px; color: #fff; font-size: 14px;
  box-shadow: var(--shadow-lg); animation: slideIn .2s; min-width: 220px; max-width: 360px;
}
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-info { background: #2563eb; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== 详情页 / 订单明细 ===== */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.detail-item { background: var(--gray-50); border-radius: 8px; padding: 10px 14px; }
.detail-item .k { font-size: 12px; color: var(--gray-500); }
.detail-item .v { font-size: 14px; font-weight: 500; color: var(--gray-800); margin-top: 2px; word-break: break-all; }
.detail-total { text-align: right; font-size: 15px; font-weight: 600; color: var(--gray-900); padding: 12px; }

/* 明细编辑行 */
.line-items { border: 1px solid var(--gray-200); border-radius: 10px; overflow: hidden; }
.line-items .table th { background: var(--gray-50); }
.line-row td { padding: 6px 8px; }
.line-row input, .line-row select {
  width: 100%; padding: 7px 9px; border: 1px solid var(--gray-300);
  border-radius: 6px; font-size: 13px;
}
.line-row input:focus, .line-row select:focus { outline: none; border-color: var(--primary); }
.line-row .rm-btn { color: var(--danger); background: none; border: none; cursor: pointer; font-size: 16px; }
.add-line-row { background: var(--gray-50); padding: 10px; text-align: center; }

/* 金额汇总条 */
.summary-bar {
  display: flex; justify-content: flex-end; align-items: center; gap: 16px;
  padding: 12px 4px; font-size: 14px;
}
.summary-bar .total { font-size: 18px; font-weight: 700; color: var(--danger); }

/* ===== 图表 ===== */
.chart-box { position: relative; height: 300px; }
.chart-box-sm { position: relative; height: 240px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 1100px) { .two-col, .three-col { grid-template-columns: 1fr; } }

/* 选项卡 */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--gray-200); margin-bottom: 18px; }
.tab-item {
  padding: 9px 18px; font-size: 14px; color: var(--gray-500); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s;
}
.tab-item:hover { color: var(--gray-800); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* 列表/卡片切换 */
.list-switch { display: flex; gap: 8px; }
.list-switch .btn { padding: 6px 12px; }

/* 盘点差异 */
.diff-plus { color: var(--success); font-weight: 600; }
.diff-minus { color: var(--danger); font-weight: 600; }

/* 文件上传 */
.upload-zone {
  border: 2px dashed var(--gray-300); border-radius: 10px; padding: 28px;
  text-align: center; color: var(--gray-500); cursor: pointer; transition: all .15s;
}
.upload-zone:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.upload-zone .up-icon { font-size: 30px; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
::-webkit-scrollbar-track { background: transparent; }

/* 空状态 */
.empty-state { text-align: center; color: var(--gray-400); padding: 60px 0; }
.empty-state .es-icon { font-size: 48px; margin-bottom: 12px; }

/* 警示框 */
.alert {
  padding: 12px 16px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px;
  display: flex; gap: 10px; align-items: flex-start;
}
.alert-warn { background: var(--warning-light); color: var(--warning); border: 1px solid #fde68a; }
.alert-info { background: var(--info-light); color: var(--info); border: 1px solid #bfdbfe; }
.alert-red { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }

/* ===== 系统对接 ===== */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.int-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.int-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.int-name { font-size: 16px; font-weight: 500; color: var(--text); }
.int-tags { display: flex; gap: 6px; margin-top: 6px; }
.int-switch { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-500); cursor: pointer; }
.int-switch input { width: 34px; height: 18px; accent-color: var(--primary); }
.int-dir { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--bg-secondary); }
.int-dir b { font-size: 13px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 8px; }
.int-dir small { font-size: 12px; color: var(--gray-400); line-height: 1.5; }
.int-help { font-size: 12px; color: var(--gray-400); }
.int-help summary { cursor: pointer; color: var(--info); user-select: none; }
.int-help p { margin: 8px 0 0; line-height: 1.7; background: var(--bg-secondary); padding: 10px; border-radius: 8px; }
.int-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.int-syncrow { display: inline-flex; gap: 8px; margin-left: auto; }
.int-foot { font-size: 12px; color: var(--gray-400); border-top: 1px dashed var(--border); padding-top: 10px; }
.int-none { font-size: 13px; color: var(--gray-400); padding: 8px 0; }
.card-sub { font-size: 13px; font-weight: 500; color: var(--text); margin-top: 4px; }
.log-msg { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.pager .page-info { font-size: 12px; color: var(--gray-400); margin-right: 6px; }
