/* ============================================================
 * 皮料 ERP 网站版 · 样式
 * ============================================================ */
:root {
  --navy: #3A2358;
  --navy-2: #4A2D6E;
  --blue: #6B3FA0;
  --cyan: #C02B6B;
  --ink: #1b2733;
  --muted: #6b7a8d;
  --line: #e4e9ef;
  --bg: #f3f6fa;
  --card: #ffffff;
  --red: #d92d20;
  --green: #0f9d58;
  --amber: #e08b00;
  --shadow: 0 1px 3px rgba(58, 35, 88, .08), 0 6px 18px rgba(58, 35, 88, .05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px;
  background: linear-gradient(165deg, #4A2D6E 0%, #3A2358 45%, #2E1B47 100%);
  color: #d6cbe6;
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 20;
}
.logo { padding: 20px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo h1 { color: #fff; font-size: 17px; font-weight: 700; letter-spacing: .5px; display: flex; align-items: center; gap: 9px; }
.logo .mark { width: 26px; height: 26px; border-radius: 6px; background: var(--cyan); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; font-weight: 800; }
.logo p { color: #a89bbd; font-size: 11px; margin-top: 6px; letter-spacing: 1px; }
.nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group { margin-bottom: 16px; }
.nav-title { font-size: 11px; color: #9385ab; padding: 6px 12px; letter-spacing: 1px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 8px;
  cursor: pointer; font-size: 14px; color: #cbc0dc; margin-bottom: 2px; transition: .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(107,63,160,.38); }
.nav-item .ico { width: 18px; text-align: center; opacity: .95; }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11px; color: #9b8db4; }

.main { flex: 1; margin-left: 232px; min-width: 0; }
.topbar {
  height: 62px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 26px;
  position: sticky; top: 0; z-index: 15;
}
.crumb { font-size: 15px; font-weight: 600; color: var(--ink); }
.crumb small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 10px; }
.top-right { display: flex; align-items: center; gap: 16px; }
.top-right .date { color: var(--muted); font-size: 13px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy-2); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }

.page { padding: 24px 26px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-head h2 { font-size: 21px; font-weight: 700; color: var(--ink); }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- 通用组件 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 15px;
  border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; transition: .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #553188; color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 11px; font-size: 12px; }
.btn.danger { color: var(--red); border-color: #f3c6c2; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.card-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.card-h h3 { font-size: 15px; font-weight: 700; }
.card-b { padding: 18px 20px; }

.grid { display: grid; gap: 18px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2,1fr); } .g3,.g2 { grid-template-columns: 1fr; } }

/* KPI 卡 */
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 30px; font-weight: 750; color: var(--navy); letter-spacing: -.5px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi .sub b { color: var(--green); }
.kpi .badge { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 16px; color: #fff; }
.bg-blue { background: #F1EAF9; } .bg-blue .badge { background: var(--blue); }
.bg-cyan { background: #FCEEF4; } .bg-cyan .badge { background: var(--cyan); }
.bg-green { background: #e8f7ef; } .bg-green .badge { background: var(--green); }
.bg-amber { background: #fdf3e2; } .bg-amber .badge { background: var(--amber); }
.bg-purple { background: #EEE7F7; } .bg-purple .badge { background: #4A2D6E; }
.bg-magenta { background: #FBE9F1; } .bg-magenta .badge { background: #C02B6B; }

/* 表格 */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 11px 14px; background: #f8fafc; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 11px 14px; border-bottom: 1px solid #eef1f5; white-space: nowrap; }
tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: none; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.tag.green { background: #e6f6ed; color: var(--green); }
.tag.amber { background: #fdf1dc; color: var(--amber); }
.tag.red { background: #fdecea; color: var(--red); }
.tag.blue { background: #F1EAF9; color: var(--blue); }
.tag.gray { background: #eef1f5; color: var(--muted); }

/* 工具栏 */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select, .field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 11px; font-size: 13px; background: #fff; color: var(--ink); outline: none;
}
.toolbar input:focus, .toolbar select:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(107,63,160,.12); }
.toolbar .spacer { flex: 1; }

/* 表单 / 模态框 */
.modal-mask { position: fixed; inset: 0; background: rgba(58,35,88,.5); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 720px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.sm { max-width: 480px; }
.modal-h { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-h h3 { font-size: 17px; }
.modal-h .x { cursor: pointer; font-size: 22px; color: var(--muted); line-height: 1; }
.modal-b { padding: 22px; }
.modal-f { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
@media (max-width: 640px){ .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field label .req { color: var(--red); }
.field input, .field select { width: 100%; }
.field.full { grid-column: 1 / -1; }

.line-items { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.line-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr 34px; gap: 8px; padding: 10px; align-items: center; border-bottom: 1px solid #eef1f5; }
.line-row.head { background: #f8fafc; font-size: 11px; color: var(--muted); font-weight: 600; }
.line-row input, .line-row select { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; }
.line-row .del { cursor: pointer; color: var(--red); text-align: center; font-size: 16px; }
.total-bar { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 14px 10px; font-size: 14px; }
.total-bar b { font-size: 20px; color: var(--navy); }

/* 空状态 */
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty .ic { font-size: 40px; opacity: .35; }

/* 库存分布交叉表 */
.matrix td, .matrix th { text-align: center; padding: 9px 8px; font-size: 12px; }
.matrix td:first-child, .matrix th:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; }
.matrix th:first-child { background: #f8fafc; }
.matrix .has { color: var(--blue); font-weight: 600; }
.matrix .dot { color: #cfd8e3; }

/* 预警 */
.alert-list .row { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid #eef1f5; gap: 10px; }
.alert-list .row:last-child { border: none; }
.alert-list .nm { font-weight: 600; font-size: 13px; }
.alert-list .meta { color: var(--muted); font-size: 12px; }

/* 迷你柱图 */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bars .b .bar { width: 100%; background: linear-gradient(180deg, var(--cyan), var(--blue)); border-radius: 5px 5px 0 0; min-height: 3px; }
.bars .b .lb { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bars .b .vl { font-size: 11px; font-weight: 600; color: var(--navy); }

/* AI 助手 */
.ai-layout { display: grid; grid-template-columns: 1fr 300px; gap: 18px; }
@media (max-width: 960px){ .ai-layout { grid-template-columns: 1fr; } }
.chat { display: flex; flex-direction: column; height: 560px; }
.chat-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 82%; padding: 11px 15px; border-radius: 12px; font-size: 13px; line-height: 1.6; }
.msg.me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 3px; }
.msg.ai { align-self: flex-start; background: #f2f5f9; color: var(--ink); border-bottom-left-radius: 3px; }
.msg.ai b { color: var(--navy); }
.chat-input { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; font-size: 13px; outline: none; }
.chat-input input:focus { border-color: var(--blue); }
.quick-q { display: flex; flex-direction: column; gap: 8px; }
.quick-q button { text-align: left; border: 1px solid var(--line); background: #fff; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; color: var(--ink); }
.quick-q button:hover { border-color: var(--blue); color: var(--blue); background: #F7F3FB; }
.typing { color: var(--muted); font-size: 12px; font-style: italic; }

/* 提示条 */
.notice { padding: 12px 16px; border-radius: 9px; background: #F1EAF9; color: #4A2D6E; font-size: 13px; margin-bottom: 18px; border: 1px solid #d9c9ec; }
.notice b { font-weight: 700; }

/* Toast */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 20px; border-radius: 8px; font-size: 13px; z-index: 100; box-shadow: 0 8px 30px rgba(0,0,0,.25); opacity: 0; transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; flex-wrap: wrap; gap: 10px; }
.pager b { color: var(--navy); }
.pager-btns { display: flex; gap: 6px; }

.role-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(190px,1fr)); gap: 12px; margin-top: 14px; }
.role-card { border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; background: #fbfcfe; }
.role-card b { font-size: 13px; color: var(--navy); }
.role-card p { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.role-sel { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px; margin-right: 6px; max-width: 110px; }

/* 品牌标志 */
.side-logo-img { display:block; max-width:180px; width:100%; height:auto; background:#fff; border-radius:8px; padding:6px 8px; }
.logo p { margin-top:8px; }
