/* 业务流程系统 v2.0 —— 浅色专业主题 */
:root {
  --bg: #f4f6fa; --panel: #ffffff; --panel-2: #f8fafc;
  --line: #e5e9f0; --line-2: #eef1f6;
  --ink: #1f2937; --ink-2: #5b6573; --ink-3: #97a1b0;
  --primary: #1e4d8b; --primary-2: #2f6fed; --primary-soft: #eaf1fb;
  --accent: #0f9d8a; --warn: #d98a00; --danger: #d6453d;
  --shadow: 0 1px 3px rgba(20,40,80,.08), 0 4px 16px rgba(20,40,80,.06);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.55;
}
h2 { font-size: 18px; margin: 0; }
h4 { margin: 18px 0 8px; font-size: 14px; color: var(--ink-2); }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 14px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px var(--primary-soft); }
label { font-size: 13px; }
.muted { color: var(--ink-3); }
.fld { display: flex; flex-direction: column; gap: 4px; }
.fld > span { color: var(--ink-2); font-size: 12px; }

/* ---------- 致命错误 ---------- */
#fatal { position: fixed; inset: 0; background: #fff; display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--danger); font-weight: 600; z-index: 999; }

/* ---------- 登录 ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #eaf1fb 0%, #f4f6fa 60%); }
.auth-card { width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-logo { width: 44px; height: 44px; border-radius: 12px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.auth-title { font-weight: 700; font-size: 17px; }
.auth-sub { color: var(--ink-3); font-size: 12px; }
.auth-tabs { display: flex; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.auth-tab { flex: 1; border: none; background: transparent; padding: 8px 4px; border-radius: 8px; color: var(--ink-2); font-size: 13px; }
.auth-tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; }
.auth-row { display: flex; gap: 8px; }
.auth-row input { flex: 1; }
.auth-btn { background: var(--primary); color: #fff; border: none; padding: 10px; border-radius: 9px; font-weight: 600; }
.auth-btn.ghost { background: var(--primary-soft); color: var(--primary); padding: 7px 12px; white-space: nowrap; }
.auth-btn:hover { filter: brightness(1.05); }
.auth-error { background: #fdecea; color: var(--danger); padding: 9px 11px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.auth-hint { margin-top: 16px; color: var(--ink-3); font-size: 12px; text-align: center; }

/* ---------- 外壳 ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 218px; background: #0f1f3d; color: #cdd6e6; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-2); display: flex; align-items: center; justify-content: center; font-size: 19px; }
.brand-txt { font-weight: 700; color: #fff; font-size: 15px; line-height: 1.2; }
.brand-txt small { display: block; color: #8092b3; font-weight: 400; font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; background: transparent; border: none; color: #b9c4da; padding: 9px 10px; border-radius: 9px; text-align: left; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary-2); color: #fff; font-weight: 600; }
.nav-ico { font-size: 16px; width: 20px; text-align: center; }
.side-foot { padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.side-signout { width: 100%; background: transparent; border: 1px solid rgba(255,255,255,.16); color: #cdd6e6; padding: 8px; border-radius: 8px; }
.side-signout:hover { background: rgba(255,255,255,.08); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 26px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.crumb { font-weight: 600; font-size: 16px; }
.userbox { display: flex; align-items: center; gap: 10px; }
.role-badge { background: var(--primary-soft); color: var(--primary); padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.uname { color: var(--ink-2); font-size: 13px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 24px 26px; flex: 1; }

/* ---------- 卡片 / KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.kpi-val { font-size: 26px; font-weight: 700; color: var(--primary); }
.kpi-val small { font-size: 14px; color: var(--ink-3); margin-left: 4px; }
.kpi-label { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.cards-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-h { font-weight: 600; margin-bottom: 12px; font-size: 15px; }
.pipe-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.pipe-label { width: 44px; color: var(--ink-2); font-size: 13px; }
.pipe-bar { flex: 1; height: 12px; background: var(--panel-2); border-radius: 8px; overflow: hidden; }
.pipe-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary-2), var(--accent)); border-radius: 8px; }
.pipe-val { width: 28px; text-align: right; color: var(--ink-2); font-size: 13px; }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--ink-2); font-weight: 600; padding: 9px 10px; border-bottom: 2px solid var(--line); background: var(--panel-2); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); }
.tbl tr:hover td { background: var(--panel-2); }
.tag { background: var(--primary-soft); color: var(--primary); padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.row-act { white-space: nowrap; }
.lnk { background: none; border: none; color: var(--primary-2); padding: 2px 6px; font-size: 13px; }
.lnk:hover { text-decoration: underline; }
.lnk.danger { color: var(--danger); }

/* ---------- 视图头 / 按钮 ---------- */
.view-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.btn { background: var(--panel); border: 1px solid var(--line); padding: 8px 14px; border-radius: 9px; font-weight: 600; color: var(--ink); }
.btn:hover { border-color: var(--primary-2); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.ghost { background: var(--panel-2); border-color: var(--line); color: var(--ink-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.editor .form-grid { grid-template-columns: repeat(3, 1fr); }
.editor h4:first-of-type { margin-top: 22px; }

/* ---------- BOM 编辑器 ---------- */
.bom-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; background: var(--panel-2); }
.bom-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bom-head input { width: 140px; }
.bom-mats, .rt-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.bom-mat { display: flex; align-items: center; gap: 8px; }
.bom-mat select { flex: 1; min-width: 0; }
.bom-mat input { width: 90px; }

/* ---------- 报价结果 ---------- */
.quote-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.quote-bar label { display: flex; flex-direction: column; gap: 4px; }
.quote-bar select, .quote-bar input { min-width: 120px; }
.quote-sum { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 16px; padding: 14px; background: var(--primary-soft); border-radius: 10px; color: var(--primary); }
.quote-sum b { font-size: 16px; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line); background: var(--panel-2); }

/* ---------- 占位 ---------- */
.placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 80px 20px; color: var(--ink-2); }
.ph-ico { font-size: 54px; margin-bottom: 10px; }
.placeholder h2 { margin-bottom: 8px; }
.ph-note { margin-top: 14px; color: var(--ink-3); font-size: 13px; max-width: 520px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1f2937; color: #fff; padding: 11px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .25s; z-index: 999; font-size: 13px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cards-2 { grid-template-columns: 1fr; }
  .form-grid, .editor .form-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 64px; }
  .brand-txt, .nav-item span:not(.nav-ico) { display: none; }
}
