* { box-sizing: border-box; }
body { margin: 0; font-family: "Microsoft YaHei", "PingFang SC", sans-serif; font-size: 13px; color: #222; background: #f4f5f7; }
header { background: #1f3a5f; color: #fff; padding: 8px 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
header h1 { font-size: 15px; margin: 0 14px 0 0; font-weight: 600; }
nav button { background: #2f4f73; color: #fff; border: 1px solid #3d5f86; border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
nav button:hover { background: #3d5f86; }
nav button.active { background: #e8a33d; border-color: #e8a33d; color: #222; font-weight: 600; }
main { padding: 12px 14px; }
h2 { font-size: 14px; margin: 4px 0 10px; }
.cards { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.card { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 10px 14px; min-width: 150px; }
.card .n { font-size: 22px; font-weight: 600; color: #1f3a5f; }
.card .n.warn { color: #c0392b; }
.card .t { color: #666; font-size: 12px; margin-top: 2px; }
.panel { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { border: 1px solid #cfd6dd; padding: 4px 7px; text-align: left; white-space: nowrap; }
th { background: #eef2f6; font-weight: 600; }
tbody tr:nth-child(even) { background: #fafbfc; }
td.low { color: #c0392b; font-weight: 600; }
/* 库存明细：入库(加)红、出库(减)绿（遵循国内涨红跌绿习惯） */
td.in { color: #c0392b; font-weight: 600; }
td.out { color: #1f8a3b; font-weight: 600; }
.alerts { list-style: none; padding: 0; margin: 0; }
.alerts li { padding: 5px 8px; border-bottom: 1px solid #eee; font-size: 12px; display: flex; align-items: baseline; gap: 6px; }
.alerts .tag { display: inline-block; color: #fff; border-radius: 3px; padding: 1px 6px; font-size: 11px; margin-right: 6px; }
.alerts .red { background: #c0392b; }
.alerts .orange { background: #d9772b; }
.alerts .blue { background: #2b6cb0; }
.alerts .alert-msg { flex: 1; min-width: 0; }
.alerts .alert-date { color: #999; font-size: 11px; margin-left: auto; }
.alert-x { margin-left: 8px; border: none; background: transparent; color: #bbb; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; border-radius: 3px; }
.alert-x:hover { background: #fdecea; color: #c0392b; }
.list-scroll { max-height: 270px; overflow-y: auto; }
.table-scroll { max-height: 290px; overflow-y: auto; }
.table-scroll thead th { position: sticky; top: 0; z-index: 1; }
.stock-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.stock-grid .panel { margin-bottom: 0; }
.panel-h { display: flex; align-items: center; justify-content: space-between; margin: 0 0 8px; }
.panel-tools { display: flex; gap: 6px; }
@media (max-width: 760px) { .stock-grid { grid-template-columns: 1fr; } }
.empty { color: #999; font-size: 12px; padding: 8px 0; }
.btn { background: #1f3a5f; color: #fff; border: none; border-radius: 4px; padding: 5px 14px; cursor: pointer; font-size: 12px; }
.btn:hover { background: #2f4f73; }
.btn-ghost { background: #fff; border: 1px solid #c4ccd4; color: #444; }
.btn-ghost:hover { background: #f0f3f6; }
.btn-add { margin-bottom: 10px; background: #2e7d4f; }
.btn-add:hover { background: #37935e; }
.btn-sm { padding: 2px 8px; font-size: 11px; margin-right: 4px; }
.btn-edit { background: #2f6fb0; }
.btn-del { background: #b04a3a; }
.row-actions { white-space: nowrap; }

/* 新增/编辑表单 */
form.add { background: #fbfcfe; border: 1px solid #dde3ea; border-radius: 6px; padding: 10px; margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
form.add label { display: flex; flex-direction: column; font-size: 11px; color: #555; gap: 3px; }
form.add input, form.add select { font-size: 12px; padding: 4px 6px; border: 1px solid #c4ccd4; border-radius: 4px; min-width: 120px; }
form.add .chk { flex-direction: row; align-items: center; gap: 5px; }
form.add button { background: #1f3a5f; color: #fff; border: none; border-radius: 4px; padding: 6px 16px; cursor: pointer; font-size: 12px; }

/* 催款单 */
.urge-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.urge-tools select { padding: 5px 8px; font-size: 13px; }
.total-line { text-align: right; font-size: 15px; font-weight: 600; margin-top: 10px; color: #1f3a5f; }

/* modal */
.modal { position: fixed; left: 0; top: 0; right: 0; bottom: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding-top: 40px; }
.modal-box { background: #fff; border-radius: 8px; width: 680px; max-width: 94vw; max-height: 90vh; overflow: auto; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.modal-box.wide { width: 920px; max-width: 97vw; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid #eee; font-weight: 600; }
.modal-head button { border: none; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: #888; }
.modal-body { padding: 8px 10px; }
.modal-body form { display: block; }
.form-group { margin-bottom: 8px; padding: 6px 8px; background: #fafbfd; border: 1px solid #e6eaef; border-radius: 6px; }
.form-group-title { font-size: 12px; font-weight: 600; color: #1f3a5f; border-left: 3px solid #e8a33d; padding-left: 7px; margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.spec-group .form-grid { grid-template-columns: 1fr 1fr 1fr; gap: 6px 10px; }
.ship-head-grid { grid-template-columns: repeat(4, 1fr); gap: 6px 10px; }
.ship-head-grid .field:nth-child(1) { grid-column: span 2; }
.ship-head-grid .field:nth-child(2) { grid-column: span 2; }
.ship-head-grid .field:nth-child(5) { grid-column: span 2; }
.ship-head-grid .field.wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 2px; }
.field label { font-size: 11px; color: #555; }
.field input, .field select { font-size: 12px; padding: 4px 6px; border: 1px solid #c4ccd4; border-radius: 4px; width: 100%; box-sizing: border-box; background: #fff; }

/* 发货单价提示：最近三次成交价（可点选回填） */
.price-hint { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11px; color: #555; }
.ph-label { color: #888; }
.ph-tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; text-decoration: none; }
.ph-rec { background: #e8f0f8; color: #2f6fb0; border: 1px solid #c8dcf0; cursor: pointer; }
.ph-rec:hover { background: #d4e4f5; }
.ph-cur { background: #2f6fb0; color: #fff; border-color: #2f6fb0; font-weight: 600; }
.field input:focus, .field select:focus { border-color: #1f3a5f; outline: none; }
/* 整行占满（字段少时右列留空也无妨；备注等可设 wide 占满） */
.field.wide { grid-column: 1 / -1; }
.form-actions { margin-top: 4px; text-align: right; }
.form-actions .btn { margin-left: 8px; }

/* 关联下拉：搜索框 + 动态列表（模糊搜索 + 拼音码 + * 通配） */
.combo { position: relative; width: 100%; }
.combo-in { width: 100%; font-size: 12px; padding: 5px 7px; border: 1px solid #c4ccd4; border-radius: 4px; box-sizing: border-box; background: #fff; }
.combo-in:focus { border-color: #1f3a5f; outline: none; }
.combo-pop { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #c4ccd4; border-top: none; border-radius: 0 0 4px 4px; max-height: 220px; overflow: auto; z-index: 60; box-shadow: 0 4px 10px rgba(0,0,0,.12); }
.combo-opt { padding: 5px 7px; font-size: 12px; cursor: pointer; border-bottom: 1px solid #f0f0f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-opt:last-child { border-bottom: none; }
.combo-opt:hover { background: #eef4fb; }

/* 刀模两级列表：类型主行 + 具体刀模下一级 */
.dies-table td.expander { width: 30px; text-align: center; padding: 2px 4px; }
.note-cell { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-btn { width: 22px; height: 22px; line-height: 1; border: 1px solid #c4ccd4; background: #fff; border-radius: 4px; cursor: pointer; font-size: 14px; color: #1f3a5f; padding: 0; }
.exp-btn:hover { background: #eef4fb; }
.dies-table .inst-zone.collapsed { display: none; }
.dies-table .inst-zone td { background: #f6f8fb; padding: 0; }
.inst-wrap { padding: 8px 12px 12px 28px; }
.inst-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.inst-head b { font-size: 12px; color: #1f3a5f; }
.inst-table { width: 100%; background: #fff; }
.inst-table th, .inst-table td { background: #fff; }
.btn-add2 { background: #2e7d4f; padding: 2px 8px; font-size: 11px; }
.btn-add2:hover { background: #37935e; }
.btn-scrap { background: #c0772b; }
.btn-scrap:hover { background: #d98a3b; }
.btn-del2 { background: #b04a3a; }
/* 采购入库金额：去掉数字输入框的上下步进箭头 */
input.no-spin::-webkit-outer-spin-button,
input.no-spin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.no-spin { -moz-appearance: textfield; }

.modal-head { user-select: none; }

/* 产品表：长表头折成两行、列宽随内容(数字窄)，超出窗口则横向滚动而非撑宽 */
.tbl-scroll { overflow-x: auto; }
.cat-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 8px 0 4px; padding: 6px 10px; background: #f5f7fa; border: 1px solid #e3e8ee; border-radius: 6px; }
.cat-filter .cf-label { color: #6b7785; font-size: 13px; }
.cat-filter .cf-item { font-size: 13px; cursor: pointer; user-select: none; }
.cat-filter .cf-item input { vertical-align: -1px; margin-right: 3px; }
.cat-filter .cf-all { color: #2c6ecb; font-weight: 600; }
.prod-table { width: auto; }
.prod-table th { white-space: normal; vertical-align: top; text-align: center; }

/* 关联下拉：键盘方向键高亮项 */
.combo-opt.active { background: #e8f0fe; color: #1a73e8; }

/* 发货单：一单可出多个产品（单头 + 多行明细表格） */
.ship-table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; margin-bottom: 2px; }
.ship-table th { background: #f5f7fa; padding: 3px 4px; text-align: center; font-weight: 600; border: 1px solid #dde3ea; white-space: nowrap; font-size: 11px; }
.ship-table td { padding: 2px 3px; border: 1px solid #dde3ea; vertical-align: middle; }
.ship-table .st-no { width: 34px; text-align: center; color: #666; }
.ship-table .st-product { width: 38%; }
.ship-table .st-unit { width: 44px; text-align: center; }
.ship-table .st-qty { width: 70px; }
.ship-table .st-up { width: 80px; }
.ship-table .st-amt { width: 90px; }
.ship-table .st-note { width: 18%; }
.ship-table .st-del { width: 36px; text-align: center; }
.ship-table input { width: 100%; padding: 3px 4px; border: 1px solid #c4ccd4; border-radius: 0; font-size: 12px; box-sizing: border-box; }
.ship-table .ship-code, .ship-table .ship-unit { background: #f2f4f7; color: #555; text-align: center; }
.ship-table .ship-amt { background: #f2f4f7; color: #333; text-align: right; }
.ship-table .ship-qty, .ship-table .ship-up { text-align: right; }
.ship-table .btn-del-line { background: #b04a3a; padding: 2px 5px; font-size: 11px; border-radius: 0; }
.ship-table .btn-del-line:hover { background: #c45a49; }
.ship-row .combo { width: 100%; }
.ship-row .combo-in { padding: 3px 4px; border-radius: 0; }
.ship-sum td { border: 1px solid #dde3ea; padding: 3px 4px; background: #fafbfd; font-weight: 600; }
.ship-sum .sum-label { text-align: right; color: #555; }
.ship-sum .sum-qty, .ship-sum .sum-amt { text-align: right; color: #1f3a5f; }

.ship-group { background: #fff; border: 1px solid #dde3ea; border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; }
.ship-group-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-bottom: 6px; border-bottom: 1px solid #eee; margin-bottom: 6px; }
.sg-cust { font-weight: 600; color: #1f3a5f; }
.sg-meta { font-size: 12px; color: #666; }
.sg-settle { font-size: 11px; padding: 1px 8px; border-radius: 10px; }
.sg-settle.set-yes { background: #e3f1e8; color: #2e7d4f; }
.sg-settle.set-no { background: #fbe9e7; color: #c0392b; }
.sg-no { font-size: 11px; color: #888; background: #eef2f6; padding: 1px 8px; border-radius: 10px; }
.sg-actions { margin-left: auto; }
.ship-detail { width: 100%; margin-top: 4px; }
.ship-detail th { background: #f5f7fa; }
.sg-note { font-size: 12px; color: #666; margin-top: 4px; }
.ln-note-cell { color: #555; font-size: 12px; max-width: 220px; word-break: break-all; }
.muted { color: #999; font-weight: 400; font-size: 11px; }

/* 列表序号列：窄、居中、灰色、等宽数字，方便口头指认"第几行" */
td.seq, th.seq { width: 42px; text-align: center; color: #8a94a0; font-variant-numeric: tabular-nums; padding-left: 4px; padding-right: 4px; }
.sg-seq { font-size: 11px; color: #fff; background: #1f3a5f; padding: 1px 8px; border-radius: 10px; font-weight: 600; }

/* 财务板块：Tab 切换 + 通用表格 */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #e3e8ee; margin-bottom: 2px; }
.tab { background: #eef2f6; border: 1px solid #dde3ea; border-bottom: none; padding: 6px 16px; font-size: 13px; cursor: pointer; border-radius: 6px 6px 0 0; color: #444; }
.tab:hover { background: #e3e9f0; }
.tab.active { background: #1f3a5f; color: #fff; border-color: #1f3a5f; font-weight: 600; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; background: #fff; }
table.tbl th { background: #f5f7fa; border: 1px solid #e0e5eb; padding: 5px 8px; text-align: left; font-weight: 600; white-space: nowrap; }
table.tbl td { border: 1px solid #e0e5eb; padding: 4px 8px; vertical-align: middle; }
table.tbl tr:hover td { background: #fafbfc; }
.fin-amt, .fin-note { padding: 3px 4px; border: 1px solid #c4ccd4; border-radius: 0; font-size: 12px; box-sizing: border-box; }
.panel { background: #fafbfd; border: 1px solid #e6eaef; border-radius: 6px; padding: 12px 14px; margin-bottom: 6px; }
.btn-ok { background: #2e7d32; }
.btn-ok:hover { background: #388e3c; }
.fin-save { background: #c08a2e; }
.fin-save:hover { background: #d09a3e; }
.fin-ledger-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.fin-ledger-tools select, .fin-ledger-tools input { padding: 4px 6px; border: 1px solid #c4ccd4; border-radius: 4px; font-size: 12px; }
