/* ================= 物料管理系统样式（蓝调浅色主题） ================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: #eef3fc; color: #1f2937; font-size: 14px; line-height: 1.6;
}
.hidden { display: none !important; }
.muted { color: #94a3b8; font-size: 12px; }
.text-danger { color: #dc2626; }
.text-green { color: #16a34a; }
.text-blue { color: #2563eb; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 14px; border-radius: 7px; border: 1px solid #b9c9e6;
  background: #fff; color: #334155; cursor: pointer; font-size: 13px;
  transition: all .15s; user-select: none; white-space: nowrap;
}
.btn:hover { border-color: #7d9bd4; background: #f3f7ff; }
.btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.btn.block { width: 100%; justify-content: center; padding: 10px; font-size: 15px; }
.link-btn {
  background: none; border: none; color: #2563eb; cursor: pointer; font-size: 12px; padding: 2px 4px;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: #dc2626; }

/* ---------- 登录页 ---------- */
.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #d8e5fb 0%, #eef4ff 50%, #e2ecfd 100%);
}
.login-card {
  width: 400px; background: #fff; border-radius: 16px; padding: 36px 34px 28px;
  box-shadow: 0 20px 60px rgba(37, 99, 235, .18); border: 1px solid #dbe6f7;
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo-icon {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px;
  background: #2563eb; color: #fff; font-size: 24px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.login-logo h1 { font-size: 19px; color: #111827; }
.login-logo p { color: #94a3b8; font-size: 12px; margin-top: 4px; }
.login-err { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; border-radius: 7px; padding: 8px 12px; font-size: 12px; margin-bottom: 12px; }

/* ---------- 主布局 ---------- */
.app-view { display: flex; height: 100vh; }
.sidebar {
  width: 216px; flex-shrink: 0;
  background: linear-gradient(180deg, #1e3a8a 0%, #1d4ed8 100%);
  border-right: none;
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.14);
}
.sidebar-logo .logo-badge {
  width: 34px; height: 34px; border-radius: 9px; background: #fff; color: #1d4ed8;
  font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.sidebar-logo .logo-text { font-weight: 700; font-size: 14px; color: #fff; }
.sidebar-logo .logo-sub { font-size: 10px; color: #bfdbfe; }
.nav-group { padding: 10px 0 4px; }
.nav-group-label { font-size: 11px; color: #93b4e8; padding: 0 16px 4px; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px; cursor: pointer;
  color: #cfe0fa; font-size: 13px; border-left: 3px solid transparent;
}
.nav-item .nav-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.35); flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.09); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.16); color: #fff; border-left-color: #fff; font-weight: 600; }
.nav-item.active .nav-dot { background: #fff; }
.sidebar-foot { margin-top: auto; padding: 14px 16px; font-size: 11px; color: #93b4e8; border-top: 1px solid rgba(255,255,255,.14); }

.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid #dbe6f7;
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px; flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 600; color: #1e3a8a; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #475569; }
.main { padding: 20px 22px; overflow-y: auto; }

/* ---------- 页面头部 / 卡片 / 表格 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-title { font-size: 17px; font-weight: 600; }
.page-desc { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: #fff; border: 1px solid #dce6f4; border-radius: 12px; padding: 18px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(30,58,138,.06); }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: #1e3a8a; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { background: #fff; border: 1px solid #dce6f4; border-radius: 12px; padding: 16px 18px; box-shadow: 0 1px 3px rgba(30,58,138,.06); }
.stat-label { font-size: 12px; color: #64748b; }
.stat-num { font-size: 23px; font-weight: 700; margin-top: 4px; color: #111827; }
.stat-num.blue { color: #2563eb; }
.stat-num.red { color: #dc2626; }
.stat-num.green { color: #16a34a; }
.stat-num.orange { color: #d97706; }
.stat-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; padding: 9px 10px; background: #f0f6ff; color: #3f5b8f;
  font-size: 12px; font-weight: 600; border-bottom: 1px solid #d9e5f6; white-space: nowrap;
}
table.grid td { padding: 9px 10px; border-bottom: 1px solid #eef3fb; vertical-align: middle; }
table.grid tbody tr:hover { background: #f6faff; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid .th-num { text-align: right; }
.empty-cell { text-align: center; color: #b0b8c4; padding: 26px 0 !important; }

/* 分页器 */
.pager { display: flex; align-items: center; gap: 6px; padding: 12px 4px 4px; flex-wrap: wrap; }
.pager-info { color: #64748b; font-size: 12px; margin-right: auto; }
.pager-btn { border: 1px solid #e2e8f0; background: #fff; color: #475569; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; min-width: 32px; line-height: 1.4; }
.pager-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.pager-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; font-weight: 600; }
.pager-ellipsis { color: #94a3b8; padding: 0 4px; }

/* 同步状态指示器 */
.sync-badge { display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; font-size: 11px; color: #64748b; }
.sync-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.sync-on { background: #16a34a; box-shadow: 0 0 4px rgba(22,163,74,.5); }
.sync-off { background: #dc2626; }

/* ---------- 角色权限矩阵 ---------- */
.perm-grid th { text-align: center; font-size: 11.5px; }
.perm-grid th[rowspan="2"] { text-align: left; }
.perm-grid .perm-cell { text-align: center; padding: 6px 6px; }
.perm-grid .perm-cell input { cursor: pointer; width: 15px; height: 15px; accent-color: #2563eb; }
.perm-grid .perm-cell.on { background: #eff6ff; }
.perm-grid .perm-cell input:disabled { cursor: not-allowed; opacity: 0.55; }
.perm-grid .perm-role { white-space: nowrap; text-align: left; }

/* ---------- 徽标 ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.b-green { background: #dcfce7; color: #15803d; }
.b-red { background: #fee2e2; color: #b91c1c; }
.b-orange { background: #ffedd5; color: #c2410c; }
.b-blue { background: #dbeafe; color: #1d4ed8; }
.b-gray { background: #f1f5f9; color: #64748b; }
.b-purple { background: #ede9fe; color: #6d28d9; }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid #dbe6f7; margin-bottom: 16px; }
.tab {
  padding: 8px 16px; cursor: pointer; font-size: 13px; color: #64748b;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: #1e3a8a; }
.tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(23, 37, 84, .5); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto;
}
.modal { background: #fff; border-radius: 14px; box-shadow: 0 25px 60px rgba(23,37,84,.28); width: 100%; max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid #e8effa; }
.modal-head h3 { font-size: 15px; color: #1e3a8a; }
.modal-x { border: none; background: none; font-size: 20px; color: #94a3b8; cursor: pointer; line-height: 1; }
.modal-x:hover { color: #334155; }
.modal-body { padding: 18px 20px; max-height: 68vh; overflow-y: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid #e8effa; display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- 表单 ---------- */
.f-form { display: flex; flex-direction: column; gap: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .span2 { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: #3f5b8f; margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #b9c9e6; border-radius: 7px;
  font-size: 13px; background: #fff; color: #1f2937; outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.field input[readonly] { background: #f4f8ff; color: #64748b; }
.field .req { color: #dc2626; margin-left: 2px; }

/* ---------- 明细行编辑器 ---------- */
.items-editor { border: 1px solid #d9e5f6; border-radius: 9px; padding: 10px; background: #f7faff; }
.ie-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ie-table th { text-align: left; padding: 6px 6px; color: #3f5b8f; font-size: 11.5px; border-bottom: 1px solid #d9e5f6; white-space: nowrap; }
.ie-table td { padding: 5px 6px; border-bottom: 1px solid #eef3fb; }
.ie-table select, .ie-table input {
  width: 100%; padding: 5px 6px; border: 1px solid #b9c9e6; border-radius: 5px; font-size: 12.5px;
}
.ie-table .ie-amt { font-weight: 600; color: #1d4ed8; text-align: right; white-space: nowrap; }
.ie-table .ie-cost { color: #64748b; text-align: right; white-space: nowrap; font-size: 12px; }
.ie-add { margin-top: 9px; }
.ie-total { text-align: right; margin-top: 8px; font-size: 13px; color: #475569; }
.ie-total b { color: #1d4ed8; font-size: 15px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1e293b; color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(15,23,42,.25); animation: toastIn .25s ease; max-width: 340px;
}
.toast.t-ok { background: #16a34a; }
.toast.t-err { background: #dc2626; }
.toast.t-info { background: #2563eb; }
.toast.out { opacity: 0; transform: translateX(12px); transition: all .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 利润看板 ---------- */
.profit-big { text-align: center; padding: 6px 0 14px; }
.profit-big .num { font-size: 34px; font-weight: 800; }
.profit-big .num.green { color: #16a34a; }
.profit-big .num.red { color: #dc2626; }
.chart-box { display: flex; align-items: flex-end; gap: 18px; height: 190px; padding: 10px 6px 0; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; flex: 1; }
.bar-pair { display: flex; align-items: flex-end; gap: 5px; height: 150px; }
.bar { width: 26px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.gross { background: #60a5fa; }
.bar.net { background: #34d399; }
.bar-label { font-size: 11px; color: #64748b; }
.chart-legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: #475569; margin-top: 8px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }

.dash-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .dash-quick { grid-template-columns: 1fr; } }
.detail-list { font-size: 13px; }
.detail-list .row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed #e6eefb; }
.detail-list .row:last-child { border-bottom: none; }

/* ---------- 数据备份与恢复模块 ---------- */
.backup-card { padding: 20px 22px; }
.backup-card-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.backup-icon {
  width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; flex-shrink: 0;
}
.backup-icon-green { background: #dcfce7; color: #15803d; }
.backup-icon-blue { background: #dbeafe; color: #1d4ed8; }
.backup-icon-orange { background: #ffedd5; color: #c2410c; }
.backup-icon-gray { background: #f1f5f9; color: #64748b; }
.backup-auto-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.backup-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.backup-toggle input { width: 16px; height: 16px; cursor: pointer; }
.backup-freq { display: inline-flex; align-items: center; gap: 6px; }
.backup-freq select { padding: 5px 10px; border-radius: 6px; border: 1px solid #b9c9e6; font-size: 13px; }
.backup-dropzone {
  border: 2px dashed #9db8e2; border-radius: 10px; padding: 30px 20px; text-align: center;
  transition: all .15s; cursor: pointer; background: #f4f8ff;
}
.backup-dropzone.drag-over { border-color: #2563eb; background: #e8f0fe; }
.backup-dropzone-inner { display: flex; flex-direction: column; align-items: center; }
.backup-tips { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 800px) { .backup-tips { grid-template-columns: 1fr; } }
.backup-tip-item { display: flex; gap: 10px; padding: 12px; background: #f4f8ff; border-radius: 8px; border: 1px solid #e6eefb; }
.backup-tip-icon { font-size: 20px; flex-shrink: 0; }
.backup-tip-title { font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 2px; }

/* ---------- 通用筛选条 ---------- */
.filter-bar {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px;
  background: linear-gradient(180deg, #f6faff 0%, #edf3fc 100%);
  border: 1px solid #d5e2f5; border-radius: 10px;
  padding: 11px 14px; margin-bottom: 14px;
}
.filter-bar .fb-items { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.filter-bar .fb-item { display: flex; flex-direction: column; gap: 4px; }
.filter-bar .fb-item label { font-size: 11px; color: #64748b; font-weight: 600; letter-spacing: .5px; }
.filter-bar input, .filter-bar select {
  padding: 6px 9px; border: 1px solid #c2d3ec; border-radius: 7px;
  font-size: 13px; background: #fff; color: #1f2937; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.filter-bar .fb-keyword input { min-width: 210px; }
.filter-bar .fb-actions { display: flex; align-items: center; gap: 10px; }
.filter-bar .fb-count { font-size: 12px; color: #64748b; white-space: nowrap; }
.filter-bar .btn.ghost { background: #fff; border-color: #c2d3ec; }
.filter-bar .btn.ghost:hover { border-color: #2563eb; color: #2563eb; }

/* ---------- 费用支出单：行级勾选分摊面板 ---------- */
.lnk-docs { border: 1px solid #d5e2f5; border-radius: 10px; background: #fbfdff; max-height: 420px; overflow: auto; padding: 8px; }
.lnk-doc { border: 1px solid #e2e9f5; border-radius: 8px; background: #fff; padding: 8px 10px; margin-bottom: 8px; }
.lnk-doc:last-child { margin-bottom: 0; }
.lnk-doc-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; cursor: pointer; color: #1f2937; }
.lnk-doc-head input { cursor: pointer; }
.lnk-table { margin: 0; }
.lnk-table input[type=checkbox] { cursor: pointer; }
.lnk-amt { width: 100%; min-width: 90px; padding: 5px 7px; border: 1px solid #c2d3ec; border-radius: 7px; font-size: 13px; background: #fff; color: #1f2937; outline: none; transition: border-color .15s, box-shadow .15s; }
.lnk-amt:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.lnk-summary { margin-top: 8px; font-size: 13px; color: #475569; background: #f6faff; border: 1px solid #d5e2f5; border-radius: 8px; padding: 8px 12px; }

/* ---------- 商品可搜索下拉（ItemEditor 商品列） ---------- */
.ie-pick { position: relative; }
.ie-search { width: 100%; box-sizing: border-box; cursor: text; }
.ie-pick .ie-search:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); outline: none; }
.ie-drop { display: none; position: fixed; z-index: 999; background: #fff; border: 1px solid #d5e2f5; border-radius: 8px; box-shadow: 0 8px 22px rgba(30,64,175,.16); max-height: 230px; overflow: auto; padding: 4px; box-sizing: border-box; }
.ie-opt { padding: 6px 9px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ie-opt:hover, .ie-opt.on { background: #1d4ed8; color: #fff; }
.ie-opt .ie-opt-code { color: #64748b; font-family: ui-monospace, Consolas, monospace; font-size: 11px; margin-right: 8px; }
.ie-opt:hover .ie-opt-code, .ie-opt.on .ie-opt-code { color: #dbe6ff; }
.ie-opt .ie-opt-spec { color: #94a3b8; font-size: 11px; margin-left: 8px; }
.ie-opt:hover .ie-opt-spec, .ie-opt.on .ie-opt-spec { color: #dbe6ff; }
.ie-opt-empty { padding: 8px; color: #94a3b8; font-size: 12px; text-align: center; }
.ie-opt-new { border-top: 1px dashed #d5e2f5; margin-top: 3px; padding-top: 7px; color: #1d4ed8; font-weight: 600; }
.ie-opt-new:hover { background: #1d4ed8; color: #fff; }
