/* ---------- 原料价格表：通用 ---------- */
.material-grid{table-layout:fixed}
.material-grid td{height:44px}
.material-input{width:100%;box-sizing:border-box;height:32px;padding:0 8px;border:1px solid transparent;border-radius:5px;background:transparent;font:inherit;color:#344f61}
.material-input:hover{border-color:#d7e8e5;background:#fff}
.material-input:focus{border-color:#16b8a6;background:#fff;outline:0;box-shadow:0 0 0 3px #16b8a61f}
.material-input.changed{background:#fff8e1!important;border-color:#f0c36d!important}
.material-input[type=number]{text-align:right}
textarea.material-input{display:block;resize:none;overflow:hidden;height:30px;min-height:30px;padding:5px 8px;line-height:1.4;white-space:pre-wrap;word-break:break-word}
.material-grid .danger-link{border:0;background:none;color:#c53030;cursor:pointer;padding:4px 6px;white-space:nowrap;font-size:13px}
.material-grid .danger-link:hover{background:#fff1f1;border-radius:4px}
.material-missing{color:#c05621;font-size:12px;white-space:normal}
.material-switch{display:inline-flex;border:1px solid #c9dcde;border-radius:7px;overflow:hidden}
.material-switch button{border:0;border-radius:0;background:#fff}
.material-switch button.active{background:#273d50;color:#fff}
.material-fee{display:inline-flex;align-items:center;gap:4px;padding:0 9px;border:1px solid #c9dcde;border-radius:7px;color:#40556c;background:#fff}
.material-fee input{width:56px;height:34px;border:0;outline:0;text-align:right;font:inherit;background:transparent}
.material-fee input.changed{background:#fff8e1}
.material-filter{height:36px;padding:0 8px;border:1px solid #c9dcde;border-radius:7px;background:#fff;color:#344f61;font:inherit}
.small{font-size:12px}

/* ---------- 原料单价 ---------- */
.material-grid.raw-grid th:first-child,.material-grid.raw-grid td:first-child{width:56px;text-align:center}
.material-grid.raw-grid th:last-child,.material-grid.raw-grid td:last-child{width:72px;text-align:center}
.raw-grid{min-width:1000px}
.raw-grid th:nth-child(2),.raw-grid td:nth-child(2){width:100px}
.raw-grid th:nth-child(3),.raw-grid td:nth-child(3){width:220px}
.raw-grid th:nth-child(4),.raw-grid td:nth-child(4){width:90px}
.raw-grid th:nth-child(5),.raw-grid td:nth-child(5){width:150px}
.raw-grid th:nth-child(6),.raw-grid td:nth-child(6),.raw-grid th:nth-child(7),.raw-grid td:nth-child(7){width:110px}

/* ---------- 产品原料成本 ---------- */
.product-cost-grid{width:100%;min-width:930px;table-layout:fixed;white-space:normal}
.product-cost-grid th{position:sticky;top:0;z-index:2;background:#eef6f5!important;color:#3b5568;font-size:13px;vertical-align:bottom;padding:10px 10px!important;line-height:1.3}
.product-cost-grid th small{display:block;margin-top:2px;font-weight:400;color:#8a9aa8;font-size:11px;line-height:1.35}
.product-cost-grid td{vertical-align:top;padding:10px 10px!important;border-color:#e8eef1;height:auto!important}
.product-cost-grid tbody tr:nth-child(even){background:#fbfdfd}
.product-cost-grid tbody tr:hover{background:#f2faf8}
.product-cost-grid tr.flagged{background:#f3fbf9}
.product-cost-grid tr.flagged td:first-child{box-shadow:inset 4px 0 #16b8a6}

/* 列宽由 colgroup 控制 */
.product-cost-grid .th-r{display:block;text-align:right}
.product-cost-grid td.cost-box{text-align:right}
.product-cost-grid td.op-cell{text-align:center}

/* 标记 */
.flag-cell{text-align:left}
.row-no{font-size:12px;color:#9aa9b5;margin-bottom:6px}
.flag-chip{display:flex;align-items:center;gap:5px;margin-bottom:5px;padding:3px 7px;border:1px solid #dbe6ea;border-radius:12px;font-size:12px;color:#6b7f8e;cursor:pointer;background:#fff;white-space:nowrap;width:max-content}
.flag-chip input{margin:0;accent-color:#16b8a6}
.flag-chip.on{border-color:#16b8a6;background:#e8f8f5;color:#0e8174;font-weight:600}
.flag-chip.hot.on{border-color:#ed8936;background:#fff4ea;color:#c05621}
.flag-chip.hot input{accent-color:#ed8936}

/* 产品 */
.product-cell .material-input{padding-left:6px;padding-right:6px}
.product-cell .p-code{height:28px;font-weight:700;font-size:15px;color:#1f3a4d}
.product-cell .p-name{min-height:26px;height:26px;padding-top:3px;padding-bottom:3px;color:#40556c}
.product-cell .p-spec{height:26px;font-size:12px;color:#7a8c99}

/* 配方 */
.formula-cell .p-formula{height:30px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px;font-weight:600;color:#1f3a4d;background:#f4f8f9;border-color:#e3ebee}
.formula-detail{margin-top:6px;font-size:12px;line-height:1.75;color:#6f8290}
.fd-line{display:flex;align-items:baseline;gap:8px}
.fd-code{flex:none;min-width:32px;font-weight:600;color:#3e5a6d}
.fd-calc{flex:1;min-width:0;color:#8395a2}
.fd-line b{flex:none;color:#344f61;font-weight:600;font-variant-numeric:tabular-nums}
.fd-fee{border-top:1px dashed #dbe5e9;margin-top:2px;padding-top:2px}
.fd-fee .fd-code{color:#8395a2;font-weight:400}

/* 生产成本 */
.cost-box{padding-top:14px!important}
.cost-box b{display:inline-block;font-size:17px;color:#078c7f;font-variant-numeric:tabular-nums}

/* 代理价 */
.tier-list{display:grid;gap:3px}
.tier-line{display:flex;justify-content:space-between;align-items:center;padding:2px 8px;border-radius:5px;font-size:12px;background:#f5f8fa}
.tier-line span{color:#7a8c99}
.tier-line b{font-size:13px;color:#263b50;font-variant-numeric:tabular-nums}
.tier-line.tier-i0{background:#f3eefc}.tier-line.tier-i0 span{color:#6b46c1}
.tier-line.tier-i1{background:#eaf4fd}.tier-line.tier-i1 span{color:#2b6cb0}
.tier-line.tier-i2{background:#fdf6e3}.tier-line.tier-i2 span{color:#b7791f}
.tier-line.tier-i3{background:#f1f4f6}.tier-line.tier-i3 span{color:#5a6b78}

/* 同行报价 */
.competitor-cell{background:#fcfaff}
.competitor-cell .p-comp::placeholder{font-size:12px;font-weight:400;color:#b8aed0}
.competitor-cell .p-comp{height:34px;font-size:16px;font-weight:700;color:#5b3fa0;border-color:#e6dcf7;background:#fff}
.competitor-ratio{margin-top:6px;display:flex;flex-direction:column;align-items:flex-end;gap:3px}
.competitor-ratio:empty{display:none}
.cr-tag{padding:2px 8px;border-radius:10px;font-size:12px;font-weight:600;white-space:nowrap}
.cr-k{font-size:11px;color:#8a9aa8}
.competitor-ratio.cheap .cr-tag{background:#fde8e8;color:#c53030}
.competitor-ratio.mid .cr-tag{background:#fef3dc;color:#b7791f}
.competitor-ratio.pricey .cr-tag{background:#def7ef;color:#0e8174}

.product-cost-grid .material-input::placeholder{color:#b9c5ce}
.product-cost-grid th,.product-cost-grid td{padding-left:8px!important;padding-right:8px!important}
/* 备注 */
.product-cost-grid .p-note{font-size:12px;color:#6f8290}
.op-cell{padding-top:12px!important}
.formula-cell .p-formula,.formula-detail{max-width:360px}

/* 全显按钮 / 密码框 */
.sheet-title{position:relative}
.reveal-btn{margin-left:auto;align-self:center;padding:6px 14px;border:1px solid #273d50;border-radius:18px;background:#273d50;color:#fff;font-weight:600;font-size:13px;cursor:pointer;white-space:nowrap}
.reveal-btn:hover{background:#1c2e3d}
.reveal-btn.on{background:#fff;color:#273d50}
.reveal-btn.on:hover{background:#eef4f7}
.reveal-dialog{width:340px!important;border:0;border-radius:12px;padding:0}
.reveal-dialog form{padding:22px 24px!important}
.reveal-dialog h3{margin:0 0 4px;font-size:17px;color:#1f3a4d}
.reveal-dialog p{margin:0 0 14px;color:#7a8c99;font-size:13px}
.reveal-dialog input{width:100%;box-sizing:border-box;height:40px;padding:0 12px;border:1px solid #c4d3df;border-radius:7px;font:inherit;font-size:15px}
.reveal-dialog input:focus{outline:0;border-color:#16b8a6;box-shadow:0 0 0 3px #16b8a61f}
.reveal-err{min-height:18px;margin-top:6px;color:#c53030;font-size:12px}
.reveal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:8px}
.sheet-title h1{white-space:nowrap}
.sheet-title:has(#materialReveal){display:flex!important;align-items:center!important;gap:12px}
.sheet-title:has(#materialReveal) #hint:empty{display:none!important}

/* 隐藏配方时的布局：各列均衡、内容居中（列：标记/产品/代理价/同行/备注/操作） */
.product-cost-grid.locked td,.product-cost-grid.locked th{vertical-align:middle}
.product-cost-grid.locked .flag-cell{vertical-align:top}
.product-cost-grid.locked .tier-list{max-width:240px;margin:0 auto}
.product-cost-grid.locked .tier-line{padding:3px 10px}
.product-cost-grid.locked th:nth-child(3),.product-cost-grid.locked th:nth-child(4){text-align:center}
.product-cost-grid.locked .competitor-cell .p-comp,.product-cost-grid.locked .competitor-ratio{max-width:190px;margin-left:auto;margin-right:auto}
.product-cost-grid.locked .competitor-ratio{align-items:center}
.product-cost-grid.locked .product-cell .p-code{font-size:16px}
.product-cost-grid.locked .cr-k{display:none}

/* ===== 紧凑布局（笔记本屏幕） ===== */
.sheet-title.mt-hide{display:none!important}
#controls.cost-toolbar{margin:8px 0 8px!important;padding:7px 9px!important;gap:6px!important;flex-wrap:nowrap;align-items:center}
#controls.cost-toolbar>button,#controls.cost-toolbar .material-filter,#controls.cost-toolbar .material-switch button{height:32px;padding:0 11px;font-size:13px;white-space:nowrap}
#controls.cost-toolbar .cost-search{flex:1;min-width:120px;height:32px}
#controls.cost-toolbar .cost-search input{height:30px}
#controls.cost-toolbar .cost-count{margin-left:6px;white-space:nowrap;font-size:12px}
#controls.cost-toolbar .reveal-btn{margin-left:4px;height:32px;padding:0 13px}
main:has(.product-cost-grid){padding-top:4px!important}

.product-cost-grid th{padding:6px 8px!important;font-size:12px}
.product-cost-grid th small{font-size:10.5px;margin-top:1px}
.product-cost-grid td{padding:5px 8px!important}
.product-cost-grid .material-input{height:26px}
.product-cost-grid textarea.material-input{min-height:24px;height:24px;padding:3px 6px;line-height:1.3}

/* 标记：两个小胶囊竖排 */
.flag-chip{margin:0 0 3px;padding:1px 7px;font-size:11.5px;line-height:18px}
.flag-cell{vertical-align:middle!important}

/* 产品：序号+简称+规格一行，名称一行 */
.p-top{display:flex;align-items:center;gap:4px}
.p-top .row-no{flex:none;min-width:20px;margin:0;font-size:11px;color:#a5b3be;text-align:right}
.product-cell .p-top .p-code{flex:none;width:44%;height:26px;font-size:14px}
.product-cell .p-top .p-spec{flex:1;min-width:0;height:24px;font-size:12px}
.product-cell .p-name{margin-left:24px;width:calc(100% - 24px)!important;font-size:13px}

/* 代理价：2×2 */
.tier-list{grid-template-columns:1fr 1fr;gap:3px 4px!important;max-width:280px!important}
.tier-line{padding:1px 7px!important;line-height:19px;font-size:11.5px}
.tier-line b{font-size:12.5px}

/* 同行报价 */
.competitor-cell .p-comp{height:28px!important;font-size:15px}
.competitor-ratio{margin-top:3px!important;flex-direction:row!important;justify-content:center;gap:6px!important;flex-wrap:wrap}
.cr-tag{padding:0 7px;line-height:18px;font-size:11.5px}

/* 配方（解锁后） */
.formula-cell .p-formula{height:26px!important;font-size:12.5px}
.formula-detail{margin-top:3px!important;line-height:1.5!important;font-size:11.5px!important}
.cost-box{padding-top:5px!important;vertical-align:middle!important}
.cost-box b{font-size:16px!important}
.product-cost-grid td,.product-cost-grid th{vertical-align:middle}
.op-cell{padding-top:5px!important}
/* 再压缩一点 */
#viewHead:has(.sheet-title.mt-hide){padding:6px 22px 2px!important}
#viewHead:has(.sheet-title.mt-hide) #controls{margin:0!important}
main:has(.product-cost-grid){padding-top:6px!important}
.flag-cell{white-space:nowrap}
.flag-cell .flag-chip{display:inline-flex;margin:0 2px 0 0;padding:0 6px;line-height:20px}
.product-cost-grid td{padding:4px 7px!important}
.product-cell .p-top .p-code{height:22px!important;font-size:13.5px}
.product-cell .p-top .p-spec{height:22px!important}
.product-cost-grid .product-cell textarea.p-name{min-height:20px!important;height:20px;padding:1px 6px!important;font-size:12.5px}
.tier-line{line-height:18px!important}
.competitor-cell .p-comp{height:26px!important}
.product-cost-grid textarea.p-note{min-height:22px!important;height:22px}
.competitor-cell .p-comp{display:inline-block;width:88px!important;max-width:88px!important;margin:0!important;vertical-align:middle}
.competitor-cell .competitor-ratio{display:inline-flex!important;margin:0 0 0 6px!important;max-width:none!important;vertical-align:middle}
.competitor-cell .competitor-ratio:empty{display:none!important}
.product-cost-grid.locked .competitor-cell{text-align:center}
.grid-wrap #grid.product-cost-grid tbody tr td{height:auto!important;padding-top:3px!important;padding-bottom:3px!important}
.competitor-cell{white-space:nowrap}
.formula-detail .fd-line{gap:6px}
.product-cost-grid:not(.locked){min-width:1120px}
.tier-line{white-space:nowrap}
.product-cell .p-top .p-code{width:36%!important}
/* 代理价可编辑 */
.tier-line{gap:2px}
.tier-line span{flex:none}
.tier-line i{flex:none;margin-left:auto;font-style:normal;font-size:11px;color:#8a9aa8}
.product-cost-grid .tier-line .tier-input{flex:0 1 62px;width:62px;min-width:0;height:18px!important;padding:0 2px!important;border:1px solid transparent;background:transparent;text-align:right;font-weight:700;font-size:12.5px;color:#263b50;-moz-appearance:textfield}
.tier-input::-webkit-outer-spin-button,.tier-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
.product-cost-grid .tier-line .tier-input:hover{border-color:#cfdde3;background:#fff}
.product-cost-grid .tier-line .tier-input:focus{border-color:#16b8a6;background:#fff;box-shadow:none}
.tier-line.manual{background:#fff1e0!important;box-shadow:inset 0 0 0 1px #f6ad55}
.tier-line.manual span{color:#c05621!important;font-weight:700}
.tier-line.manual span:after{content:'改';margin-left:2px;padding:0 2px;border-radius:3px;background:#ed8936;color:#fff;font-size:9px;vertical-align:1px}
.product-cost-grid .tier-line .tier-input.changed{background:#fff8e1!important;border-color:#f0c36d!important}

/* 导出代理报价 */
#controls.cost-toolbar .agent-export-btn{background:#16b8a6;border-color:#16b8a6;color:#fff;font-weight:600}
#controls.cost-toolbar .agent-export-btn:hover{background:#119e8f}
.agent-export-dialog{width:400px!important}
.ae-label{margin:12px 0 6px;font-size:12px;font-weight:600;color:#3b5568}
.ae-tiers{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}
.ae-scope{display:grid;gap:6px}
.ae-opt{display:flex;align-items:center;gap:6px;padding:7px 10px;border:1px solid #d7e2e8;border-radius:7px;cursor:pointer;font-size:13px;color:#40556c}
.ae-opt:has(input:checked){border-color:#16b8a6;background:#e8f8f5;color:#0e8174;font-weight:600}
.ae-opt input{margin:0;accent-color:#16b8a6}
.ae-tiers .ae-opt{justify-content:center;padding:7px 4px}
.agent-export-dialog .ae-opt input{width:auto!important;height:auto!important;padding:0!important;border:0!important;box-shadow:none!important;flex:none}
