/* ============================================================
   微码ERP 设计系统 / 后台样式
   品牌色沿用官网：蓝 #2563eb + 青 #0ea5e9 + 橙点缀 #f59e0b
   深色侧边栏 + 浅色内容区（经典 admin 风格）
   ============================================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #0ea5e9;
    --accent: #f59e0b;
    --sidebar-bg: #0f172a;
    --sidebar-bg-2: #1e293b;
    --bg: #f1f5f9;
    --bg-soft: #f8fafc;
    --bg-hover: #eef2f7;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
    --shadow: 0 4px 14px rgba(15,23,42,.08);
    --shadow-lg: 0 12px 40px rgba(15,23,42,.16);
    --sidebar-w: 220px;
    --topbar-h: 60px;
    --transition: all .2s ease;
    --font: "PingFang SC","Microsoft YaHei",-apple-system,"Segoe UI",sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 整体布局 ---------- */
.erp-app { display: flex; height: 100vh; overflow: hidden; }

.erp-sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width .22s ease;
    position: relative;
}
.erp-logo {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 20px;
    font-size: 18px; font-weight: 700; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
    white-space: nowrap; overflow: hidden;
}
.erp-logo .logo-icon {
    width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 800;
}
.erp-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.erp-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px; color: #cbd5e1; font-size: 14px;
    border-left: 3px solid transparent;
    white-space: nowrap; transition: var(--transition);
}
.erp-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.erp-nav a.active {
    background: linear-gradient(90deg, rgba(37,99,235,.35), rgba(14,165,233,.12));
    color: #fff; border-left-color: var(--secondary);
}
.erp-nav a .nav-ico {
    width: 20px; height: 20px; flex-shrink: 0; display: inline-flex;
    align-items: center; justify-content: center; font-size: 16px;
}
.erp-sidebar-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.erp-collapse-btn {
    width: 100%; background: rgba(255,255,255,.06); border: none; color: #cbd5e1;
    padding: 8px; border-radius: 8px; font-size: 18px; transition: var(--transition);
}
.erp-collapse-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.erp-sidebar.collapsed { width: 64px; }
.erp-sidebar.collapsed .logo-text,
.erp-sidebar.collapsed .erp-nav a span.nav-text { display: none; }
.erp-sidebar.collapsed .erp-nav a { justify-content: center; padding: 12px 0; }
.erp-sidebar.collapsed .erp-demo-badge { display: none; }

.erp-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.erp-topbar {
    height: var(--topbar-h); background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px;
    padding: 0 20px; flex-shrink: 0;
}
.erp-menu-btn {
    display: none; background: none; border: none; font-size: 20px; color: var(--text);
}
.erp-breadcrumb { font-size: 16px; font-weight: 600; color: var(--text); }
.erp-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.erp-search input {
    width: 240px; max-width: 40vw; padding: 8px 14px; border: 1px solid var(--border);
    border-radius: 999px; font-size: 13px; outline: none; transition: var(--transition);
    background: var(--bg);
}
.erp-search input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.erp-user { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.erp-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.erp-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ---------- 演示提示条 ---------- */
.erp-demo-banner {
    display: flex; align-items: flex-start; gap: 10px;
    background: linear-gradient(90deg, rgba(245, 158, 11, .14), rgba(245, 158, 11, .06));
    border-bottom: 1px solid rgba(245, 158, 11, .35);
    color: #92400e; padding: 10px 16px; font-size: 13px; line-height: 1.6; flex-shrink: 0;
}
.erp-demo-dot {
    flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #f59e0b;
    margin-top: 6px; box-shadow: 0 0 0 3px rgba(245, 158, 11, .25);
}
.erp-demo-text { flex: 1; }
.erp-demo-text strong { color: #b45309; }
.erp-demo-close {
    flex: 0 0 auto; background: none; border: none; color: #92400e; font-size: 18px;
    line-height: 1; cursor: pointer; padding: 0 4px; opacity: .7;
}
.erp-demo-close:hover { opacity: 1; }

/* ---------- 侧栏演示徽标 ---------- */
.erp-demo-badge {
    display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .5px;
    color: #f59e0b; background: rgba(245, 158, 11, .12); border: 1px solid rgba(245, 158, 11, .4);
    padding: 3px 8px; border-radius: 6px; margin-bottom: 8px;
}
.erp-sidebar-foot { display: flex; flex-direction: column; }

/* ---------- 页面头（模块标题 + 操作） ---------- */
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.page-head h2 { font-size: 20px; font-weight: 700; }
.page-head .page-sub { color: var(--text-light); font-size: 13px; margin-top: 2px; }

/* ---------- 子标签（客户维护） ---------- */
.subtabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.subtab {
    padding: 8px 18px; border-radius: 9px; font-size: 14px; font-weight: 500;
    color: var(--text-light); background: var(--bg-soft); text-decoration: none;
    border: 1px solid var(--border); transition: all .2s;
}
.subtab:hover { background: var(--bg-hover); color: var(--text); }
.subtab.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(37, 99, 235, .25); }
.up { color: var(--success); font-weight: 600; }
.down { color: var(--danger); font-weight: 600; }
.muted { color: var(--text-muted); font-size: 12px; }

/* ---------- 入库单：数量高亮 / 副文本 ---------- */
.up { color: var(--success); font-weight: 600; }
.muted { color: var(--text-light); font-size: 12px; }

/* ---------- 防窜货：溯源轨迹时间轴 ---------- */
.trace-timeline { position: relative; padding-left: 20px; margin: 6px 0 4px; }
.trace-node { position: relative; padding-bottom: 18px; }
.trace-node:last-child { padding-bottom: 0; }
.trace-node:before { content: ""; position: absolute; left: -14px; top: 6px; bottom: -6px; width: 2px; background: var(--border); }
.trace-node:last-child:before { display: none; }
.trace-dot { position: absolute; left: -20px; top: 4px; width: 11px; height: 11px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.trace-node.active .trace-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, .18); }
.trace-time { font-size: 12px; color: var(--text-light); margin-bottom: 2px; }
.trace-loc { font-weight: 600; color: var(--text); }
.trace-region { font-size: 11px; color: #fff; background: var(--info); padding: 1px 6px; border-radius: 4px; margin-left: 4px; }
.trace-node.active .trace-region { background: var(--danger); }
.trace-type { font-size: 12px; color: var(--text-light); margin-top: 1px; }

/* ---------- 防窜货：预警提示条 ---------- */
.card-warn-tip { background: rgba(239, 68, 68, .08); border: 1px solid rgba(239, 68, 68, .25); color: #b91c1c; border-radius: var(--radius); padding: 12px 16px; font-size: 13px; margin-bottom: 16px; }

/* ---------- 卡片 ---------- */
.erp-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 20px; margin-bottom: 18px;
}
.erp-card-title {
    font-size: 15px; font-weight: 600; margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between;
}
.erp-card-title .more { font-size: 13px; color: var(--primary); cursor: pointer; }

/* ---------- KPI 卡 ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi-card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
}
.kpi-label { color: var(--text-light); font-size: 13px; }
.kpi-value { font-size: 26px; font-weight: 700; margin: 6px 0 4px; }
.kpi-trend { font-size: 12px; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-ico {
    position: absolute; right: 16px; top: 16px; width: 40px; height: 40px; border-radius: 10px;
    background: rgba(37,99,235,.1); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-size: 20px;
}

/* ---------- 图表 ---------- */
.chart-row { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }
.chart-box { width: 100%; }
.chart-box svg { width: 100%; height: auto; display: block; }

/* ---------- 工具栏（搜索/筛选/新增） ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.field-inline {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; outline: none; background: #fff; color: var(--text);
}
.field-inline:focus { border-color: var(--primary); }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500;
    border: 1px solid var(--border); background: #fff; color: var(--text);
    transition: var(--transition);
}
.btn:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff; border-color: transparent; box-shadow: var(--shadow-sm);
}
.btn-primary:hover { opacity: .92; box-shadow: var(--shadow); }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); padding: 5px 8px; }
.btn-ghost:hover { background: rgba(37,99,235,.08); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.erp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.erp-table th, .erp-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.erp-table th {
    background: #f8fafc; color: var(--text-light); font-weight: 600; font-size: 12px;
    text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; z-index: 1;
}
.erp-table tbody tr { transition: var(--transition); }
.erp-table tbody tr:hover { background: #f8fafc; cursor: pointer; }
.erp-table tbody tr:last-child td { border-bottom: none; }
.col-actions { text-align: right; }
.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }
.empty-tip { text-align: center; color: var(--text-light); padding: 40px 0; }

/* ---------- 状态标签 ---------- */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 500; line-height: 1.6;
}
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.green { background: #d1fae5; color: #047857; }
.badge.orange { background: #fef3c7; color: #b45309; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.gray { background: #f1f5f9; color: #475569; }
.badge.cyan { background: #cffafe; color: #0e7490; }

/* ---------- 进度条 ---------- */
.progress { background: var(--border); border-radius: 999px; height: 8px; overflow: hidden; width: 120px; display: inline-block; vertical-align: middle; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--secondary)); }

/* ---------- 表单 ---------- */
.erp-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.erp-form .full { grid-column: 1 / -1; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item label { font-size: 13px; color: var(--text-light); font-weight: 500; }
.form-item label .req { color: var(--danger); margin-left: 2px; }
.form-control {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; outline: none; background: #fff; color: var(--text); width: 100%;
    transition: var(--transition);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- 弹窗 ---------- */
.overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.45);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
    animation: fade .15s ease;
}
.modal {
    background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
    width: 560px; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column;
    animation: pop .18s ease;
}
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 17px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-light); line-height: 1; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 抽屉 ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 1000; animation: fade .15s ease; }
.drawer {
    position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 92vw;
    background: #fff; box-shadow: var(--shadow-lg); z-index: 1001;
    display: flex; flex-direction: column; animation: slideIn .2s ease;
}
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.drawer-head h3 { font-size: 17px; }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-close { background: none; border: none; font-size: 22px; color: var(--text-light); }
.detail-section { margin-bottom: 18px; }
.detail-section h4 { font-size: 13px; color: var(--text-light); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .03em; }
.detail-row { display: flex; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.detail-row .k { color: var(--text-light); width: 96px; flex-shrink: 0; }
.detail-row .v { color: var(--text); flex: 1; }

/* ---------- 分页 ---------- */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pagination button {
    min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--border);
    background: #fff; border-radius: 7px; font-size: 13px; color: var(--text); transition: var(--transition);
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination .total { color: var(--text-light); font-size: 13px; margin-right: 8px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
    background: #1e293b; color: #fff; padding: 11px 20px; border-radius: 10px;
    font-size: 14px; box-shadow: var(--shadow-lg); animation: toastIn .2s ease;
    display: flex; align-items: center; gap: 8px;
}
.toast.success { background: #047857; }
.toast.error { background: #b91c1c; }

/* ---------- 两列布局 ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 1024px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- 列表型小卡（待办等） ---------- */
.mini-list { display: flex; flex-direction: column; gap: 10px; }
.mini-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 9px; transition: var(--transition);
}
.mini-item:hover { border-color: var(--primary); background: #f8fafc; }
.mini-item .mi-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.mini-item .mi-main { flex: 1; min-width: 0; }
.mini-item .mi-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-item .mi-sub { font-size: 12px; color: var(--text-light); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .erp-sidebar { position: fixed; z-index: 900; height: 100vh; left: 0; top: 0; transform: translateX(-100%); }
    .erp-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .erp-menu-btn { display: block; }
    .erp-content { padding: 16px; }
    .erp-search input { width: 150px; }
    .erp-user-name { display: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* 加载态 */
.loading { text-align: center; color: var(--text-light); padding: 50px 0; font-size: 14px; }
