/* CyberliteERP 样式（浅色主题） */
:root {
  --bg: #f4f6f9; --panel: #ffffff; --border: #e2e6ec;
  --text: #2b3440; --muted: #7a8699;
  --primary: #2563eb; --primary-dark: #1d4ed8;
  --green: #16a34a; --red: #dc2626; --orange: #ea580c; --blue: #0284c7;
  --radius: 8px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }

/* 登录 */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #38bdf8 100%); }
.login-card { background: var(--panel); padding: 40px 36px; border-radius: 14px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card h1 { font-size: 22px; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); margin: 6px 0 22px; font-size: 13px; }
.login-card label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
.login-card input { width: 100%; }
.login-card .btn { margin-top: 22px; }
.login-card .hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }
.error { color: var(--red); font-size: 13px; margin-top: 10px; text-align: center; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: #f8fafc; border-right: 1px solid var(--border); color: #475569; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; }
.logo { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.logo-block { width: 100%; }
.logo-block .logo-img { display: block; width: 100%; height: auto; margin: 0 auto; }
#nav { flex: 1; padding: 10px 0; }
#nav a { display: block; padding: 11px 20px; color: #475569; text-decoration: none; font-size: 14px; border-left: 3px solid transparent; }
#nav a:hover { background: #e8edf3; }
#nav a.active { background: #eff6ff; color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 13px; color: #64748b; }
.sidebar-footer .btn { margin-top: 8px; width: 100%; }
.content { flex: 1; margin-left: 210px; padding: 22px 26px; }

/* 通用组件 */
.btn { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 14px; cursor: pointer; font-size: 13px; color: var(--text); }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; font-size: 13px; width: 100%; font-family: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel h2 { font-size: 15px; margin-bottom: 12px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: #f8fafc; }
tr.low-row td { background: #fef2f2 !important; color: var(--red); }
tr.overdue td { background: #fef2f2 !important; }
td.wrap { white-space: normal; min-width: 160px; word-break: break-word; }
/* 收付记录行：自动换行（不出横向滚动条），行内可带凭证预览/下载按钮 */
.rec-line { white-space: normal; word-break: break-word; line-height: 1.9; margin: 2px 0; }
.rec-line .btn { margin-left: 4px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; color: #fff; }
.badge.purchase { background: var(--orange); }  /* 采购=橙 */
.badge.sale { background: var(--blue); }        /* 销售=蓝 */
.badge.st0 { background: #94a3b8; } .badge.st1 { background: #f59e0b; }
.badge.st2 { background: var(--green); } .badge.st3 { background: var(--primary); }
.badge.st4 { background: #475569; } .badge.st5 { background: var(--red); }
.badge.inv-void { background: #94a3b8; } .badge.inv-red { background: var(--red); }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 9px 16px; cursor: pointer; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; font-size: 14px; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.progress { background: #e2e8f0; border-radius: 999px; height: 8px; width: 110px; display: inline-block; vertical-align: middle; }
.progress i { display: block; height: 100%; border-radius: 999px; background: var(--green); }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 18px; }
.kv div b { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-bottom: 2px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; padding: 22px; width: 560px; max-width: 94vw; max-height: 88vh; overflow: auto; }
.modal.wide { width: 860px; }
.modal h3 { margin-bottom: 16px; font-size: 16px; }
/* 表单样式同时用于弹窗与独立页面表单（page-form） */
.form-row { display: flex; gap: 12px; margin-bottom: 10px; }
.form-row > div { flex: 1; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
/* 表单内联错误提示：持久显示，保存成功或修改输入后消失 */
.form-error { margin-top: 12px; padding: 9px 12px; border-radius: 8px; background: #fef2f2; border: 1px solid #fecaca; color: var(--red); font-size: 13px; }

.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #1e293b; color: #fff; padding: 10px 22px; border-radius: 999px; z-index: 200; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--red); }

/* Logo（登录页：与名称等宽，保持比例） */
.login-card .logo-block { display: block; width: fit-content; max-width: 100%; margin: 0 auto 6px; text-align: center; }
.login-card .logo-img { display: block; width: 50%; margin: 0 auto 8px; height: auto; }

/* 对方主体组合框：输入 + 下拉合一 */
.combobox { position: relative; }
.combobox input { width: 100%; }
.cb-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.14); max-height: 240px; overflow-y: auto; z-index: 60; display: none; }
.cb-item { padding: 9px 12px; cursor: pointer; font-size: 13px; color: #1e293b; }
.cb-item:hover { background: #eff6ff; }
.cb-item.selected { background: #dbeafe; font-weight: 600; }
.cb-item .muted { margin-left: 4px; }
.cb-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

/* 合同备注框：最少 3 行，随内容自动增高，支持自动换行 */
.remark-box {
  display: block; width: 100%; box-sizing: border-box;
  min-height: calc(3 * 1.5em + 18px);
  padding: 8px 10px; font: inherit; line-height: 1.5;
  color: #1e293b; background: #f8fafc;
  border: 1px solid var(--border); border-radius: var(--radius);
  resize: none; overflow: hidden;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}
.remark-box[readonly] { cursor: default; color: #334155; }
.remark-box.editing { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* 附件预览弹窗 */
.preview-box { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #f8fafc; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.preview-box iframe { width: 100%; height: 62vh; border: 0; background: #fff; }
.preview-box img { max-width: 100%; max-height: 62vh; object-fit: contain; }

/* 拖拽上传区 */
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 14px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; transition: all .15s; margin-top: 8px; }
.drop-zone:hover, .drop-zone.drag { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.drop-zone .picked { color: var(--text); font-weight: 600; }
.drop-zone .parse-ok { color: var(--green); }
.drop-zone .parse-err { color: var(--red); }

.items-editor table td { padding: 5px 6px; }
.items-editor input, .items-editor select { padding: 5px 7px; font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-card .v { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat-card .t { color: var(--muted); font-size: 12px; }

/* 二次确认弹窗 */
.confirm-msg { font-size: 14px; line-height: 1.7; margin: 6px 0 4px; word-break: break-word; }
.confirm-msg b { font-weight: 700; }
.confirm-warn { margin-top: 8px; padding: 8px 10px; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; color: #9a3412; font-size: 12.5px; line-height: 1.6; }

/* 合同明细合计与自动汇总金额 */
.items-total { margin-top: 8px; font-size: 13px; color: var(--muted); text-align: right; }
.items-total b { color: var(--text); font-size: 15px; }
input.auto-amount { background: #f8fafc; color: #334155; cursor: not-allowed; }
/* 明细/价格历史弹窗内的表格滚动 */
.modal table tfoot td { background: #f8fafc; font-weight: 600; }

/* 盘点调整：序列号选择区 */
.serial-pick { max-height: 190px; overflow: auto; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 16px; background: #fbfcfe; }
.serial-item { display: flex; align-items: center; gap: 5px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.serial-item input { margin: 0; }
