:root{--ink:#1d1d1f;--muted:#6e6e73;--line:#e8e8ed;--paper:#fff;--bg:#f5f5f7;--primary:#0071e3;--primary-dark:#0077ed;--accent:#eef6ff;--warn:#9a5a00;--danger:#b42318}
*{box-sizing:border-box}html,body{max-width:100%;overflow-x:hidden}body{margin:0;background:var(--bg);color:var(--ink);font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC",sans-serif}main{width:min(1120px,calc(100% - clamp(28px,8vw,96px)));margin:0 auto;padding:30px 0 76px}.card{margin-bottom:18px;padding:20px;border:1px solid var(--line);border-radius:16px;background:var(--paper)}.toolbar,.section-heading,.heading-actions,.form-row,.inline-panel{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.toolbar{margin-bottom:18px}.toolbar .muted{margin-left:auto}.mode-switch{display:flex;padding:3px;border-radius:999px;background:#e8e8ed}.mode-button{border:0;background:transparent;color:var(--muted)}.mode-button.active{background:#fff;color:var(--ink);box-shadow:0 1px 4px rgba(0,0,0,.1)}.file-button input{display:none}.disabled{pointer-events:none;opacity:.45}.muted,.hint,.section-heading p{color:var(--muted);font-size:13px}.workspace-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(280px,330px);gap:18px;align-items:start}.workspace-grid>*{min-width:0}.side-stack>*{min-width:0}.section-heading{justify-content:space-between;margin-bottom:14px}.section-heading h2,.card h2{margin:0;font-size:18px}.section-heading p{margin:4px 0 0}.heading-actions{justify-content:flex-end}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:10px}.form-grid button{grid-column:2}.form-row{margin-top:10px}.form-row input,.form-row select{min-width:0;flex:1}.inline-panel{margin-top:12px;padding:12px;border-radius:12px;background:var(--accent)}.inline-panel span{flex:1 1 260px}.message{margin-bottom:14px;padding:11px 14px;border-radius:10px;background:#eef6ff;color:#145ea8}.message.error{background:#fff0f0;color:var(--danger)}.message.warn{background:#fff7e8;color:var(--warn)}.hidden{display:none}.compact-list{max-height:150px;margin-top:10px;overflow:auto}.compact-item{display:flex;justify-content:space-between;padding:7px 0;border-top:1px solid var(--line)}.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.stat{padding:13px;border-radius:12px;background:#f5f5f7}.stat span{display:block;color:var(--muted);font-size:12px}.stat strong{font-size:22px}.tabulator{max-width:100%;border-color:var(--line);border-radius:12px}.tabulator-cell.pusher-mark{position:relative;background:#fff0b8}.tabulator-cell.pusher-mark:after{content:"推";position:absolute;right:2px;top:1px;color:#8a5800;font-size:10px}.tabulator-cell.selected-mark-cell{background:#e8f3ff;outline:2px solid var(--primary);outline-offset:-2px}.result-card{min-height:180px}.embedded-context-label{color:var(--primary);font-size:13px}.embedded-bundling main{padding-top:14px}
.table-scroll{max-width:100%;overflow-x:auto}.table-scroll .tabulator{min-width:980px}#group-config-status{font-weight:600}.compact-item button{flex:0 0 auto;margin-left:10px}.group-config-item{padding:8px 0;border-top:1px solid var(--line)}.group-config-item .compact-item{padding:0 0 8px;border:0}.group-config-fields{display:grid;grid-template-columns:1fr 1fr;gap:7px}.group-config-fields label{color:var(--muted);font-size:11px}.group-config-fields input{width:100%;margin-top:3px;padding:7px}
@media(max-width:1000px){.workspace-grid{grid-template-columns:1fr}.side-stack{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}}@media(max-width:720px){main{width:calc(100% - 28px);padding-top:20px}.side-stack{display:block}.stats{grid-template-columns:1fr 1fr}.toolbar .muted{width:100%;margin-left:0}}

/* Bundling is a table-first workflow: keep the schedule at full working width. */
.bundling-page .workspace-grid{grid-template-columns:minmax(0,1fr)}
.bundling-page .schedule-card{min-width:0;overflow:hidden}
.bundling-page .side-stack{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
body.bundling-page .side-stack .card{min-width:0;margin-bottom:0}
.bundling-page #fixed-rules-card{grid-column:1/-1}
.bundling-page #schedule-table,.bundling-page #grain-table,.bundling-page #reduction-table,.bundling-page #aggregate-table{width:100%;min-width:0}
.bundling-page .tabulator .tabulator-tableholder{overflow-x:auto}
.bundling-page .toolbar>button,.bundling-page .toolbar>.button,.bundling-page .toolbar>.file-button{min-width:104px;flex:0 0 auto;white-space:nowrap}
.bundling-page .toolbar>.muted{min-width:200px;flex:1 1 240px;text-align:right}
.tabulator-cell.proxy-mark:after{content:"代"}.tabulator-cell.fixed-bundle-cell{background:#e8f3ff;color:#145ea8;font-weight:650;box-shadow:inset 0 0 0 1px #9dc9f3}
.import-error{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.import-error>span{min-width:240px;flex:1}.import-error.hidden{display:none}
.fixed-rule-editor{display:grid;grid-template-columns:minmax(150px,1fr) 110px minmax(150px,1fr) 110px auto auto;gap:9px;align-items:end}.fixed-rule-editor label{display:grid;gap:4px;color:var(--muted);font-size:11px}.fixed-rule-editor select,.fixed-rule-editor input{width:100%;min-width:0}.fixed-rule-editor .fixed-offset{display:flex;min-height:40px;align-items:center;gap:7px;white-space:nowrap}.fixed-rule-editor .fixed-offset input{width:16px;min-height:16px}.fixed-rule-list{display:grid;gap:7px;margin-top:12px}.fixed-rule-item{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;border:1px solid var(--line);border-radius:11px;background:#fafafa}.fixed-rule-item>div{display:flex;min-width:0;align-items:baseline;gap:9px;flex-wrap:wrap}.fixed-rule-item span{color:var(--muted);font-size:12px}.fixed-reduction-panel{margin-top:16px;padding-top:14px;border-top:1px solid var(--line)}.fixed-reduction-panel h3{margin:0;font-size:15px}.fixed-reduction-row{display:grid;grid-template-columns:minmax(180px,1fr) 110px minmax(150px,1fr) auto;gap:9px;align-items:center;margin-top:8px}.fixed-reduction-row input{width:100%}.fixed-reduction-row small{color:var(--muted)}
.schedule-format-dialog{width:min(680px,calc(100% - 28px));padding:0;border:0;border-radius:18px;background:#fff;box-shadow:0 24px 80px rgba(0,0,0,.24)}.schedule-format-dialog::backdrop{background:rgba(0,0,0,.38);backdrop-filter:blur(3px)}.schedule-format-dialog form{padding:22px}.schedule-format-dialog header,.schedule-format-dialog footer{display:flex;align-items:flex-start;justify-content:space-between;gap:14px}.schedule-format-dialog h2{margin:0;font-size:21px}.schedule-format-dialog header p{margin:4px 0 0;color:var(--muted)}.schedule-format-dialog ol{margin:16px 0;padding-left:22px;color:var(--muted);line-height:1.7}.schedule-format-dialog footer{justify-content:flex-end}.format-preview-wrap{margin-top:18px;overflow-x:auto;border:1px solid var(--line);border-radius:12px}.format-preview{width:100%;min-width:480px;border-collapse:collapse}.format-preview th,.format-preview td{height:38px;padding:7px 12px;border-right:1px solid var(--line);border-bottom:1px solid var(--line);text-align:left}.format-preview th{background:#1d1d1f;color:#fff}.format-preview tr:last-child td{border-bottom:0}.format-preview th:last-child,.format-preview td:last-child{border-right:0}

@media(max-width:900px){
  .bundling-page .side-stack{grid-template-columns:repeat(2,minmax(0,1fr))}
  .bundling-page #group-config-card{grid-column:1/-1}
}
@media(max-width:780px){.fixed-rule-editor{grid-template-columns:1fr 100px}.fixed-rule-editor label:nth-child(3){grid-column:1}.fixed-rule-editor .fixed-offset{grid-column:1/-1}.fixed-rule-editor button{grid-column:1/-1}.fixed-reduction-row{grid-template-columns:1fr 90px}.fixed-reduction-row small{grid-column:1}.fixed-reduction-row button{grid-column:2;grid-row:2}}
@media(max-width:620px){
  .bundling-page .toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
  .bundling-page .toolbar>button,.bundling-page .toolbar>.button,.bundling-page .toolbar>.file-button{width:100%;min-width:0}
  .bundling-page .toolbar>#export-button{grid-column:1/-1}
  .bundling-page .toolbar>.muted{grid-column:1/-1;width:auto;min-width:0;text-align:left}
  .bundling-page .side-stack{grid-template-columns:1fr}
  .bundling-page #group-config-card{grid-column:auto}
  .bundling-page #fixed-rules-card{grid-column:auto}
}
@media(max-width:420px){.bundling-page .toolbar{grid-template-columns:1fr}}
.cart-import-preview{margin:18px 0;padding:14px;border:1px solid var(--line);border-radius:12px;background:#f8faf9}.cart-import-preview dl{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:0}.cart-import-preview div{padding:9px;border-radius:9px;background:#fff}.cart-import-preview dt{color:var(--muted);font-size:12px}.cart-import-preview dd{margin:3px 0 0;font-size:20px;font-weight:700}.cart-import-preview p{margin:12px 0 0;color:var(--muted);font-size:13px}@media(max-width:520px){.cart-import-preview dl{grid-template-columns:1fr 1fr}}
