/* Batch18：全系统 UI 一致性、按钮对齐与响应式布局修复。仅用于 8766 验证版。 */
:root{
  --b18-control-h:38px;
  --b18-touch-h:44px;
  --b18-gap:10px;
  --b18-panel-gap:14px;
  --b18-radius:14px;
  --b18-border:#dbe5ef;
  --b18-soft:#f7faff;
  --b18-text:#1f2f46;
  --b18-muted:#6d7c90;
}

/* 路由页面必须互斥显示，防止“界面布局”面板覆盖其他业务页面。 */
body.erp-mode .erp-page:not(.erp-page-active){display:none!important}
body.erp-mode .layout-bar{display:none!important}
body.erp-mode .layout-bar.erp-page-active{
  display:grid!important;
  grid-template-columns:minmax(250px,1.35fr) repeat(3,minmax(150px,1fr)) auto;
  align-items:end!important;
  gap:var(--b18-gap)!important;
  width:100%;
  margin:0 0 16px!important;
  padding:17px!important;
  border:1px solid var(--b18-border);
  border-radius:var(--b18-radius);
  background:#fff;
}

/* 统一内容区的间距、溢出边界和标题排版。 */
body.erp-mode .erp-content{min-width:0;overflow:visible}
body.erp-mode .erp-page.erp-page-active{width:100%;max-width:100%;min-width:0}
body.erp-mode .erp-page-heading{
  display:flex!important;
  align-items:flex-start!important;
  justify-content:space-between!important;
  gap:16px!important;
  margin-bottom:18px!important;
}
body.erp-mode .erp-page-heading>div:first-child{flex:1 1 420px;min-width:0}
body.erp-mode .erp-page-heading h1{line-height:1.25!important;overflow-wrap:anywhere}
body.erp-mode .erp-page-heading p{margin-top:6px!important;line-height:1.65!important}
body.erp-mode .erp-page-heading>.actions{
  flex:0 1 auto;
  display:flex!important;
  align-items:center!important;
  justify-content:flex-end!important;
  flex-wrap:wrap!important;
  gap:8px!important;
  min-width:0;
}
body.erp-mode :is(.card,.erp-panel,.erp-module-card,.yd-bridge-panel,.mp-panel,.intel-card,.maint-box){min-width:0}
body.erp-mode :is(.box-head,.result-head,.chart-head,.erp-panel-head,.modal-head){gap:12px}
body.erp-mode :is(.box-head,.result-head,.chart-head,.erp-panel-head,.modal-head)>div:first-child{min-width:0}
body.erp-mode :is(.box-head,.result-head,.chart-head,.erp-panel-head,.modal-head) :is(h2,h3,p){overflow-wrap:anywhere}

/* 内容区按钮统一为真正的居中按钮；表格内按钮保持紧凑。 */
body.erp-mode .erp-content button:not(.icon-button):not(.erp-menu-toggle):not(.erp-top-icon):not(.erp-sidebar-collapse),
body.erp-mode .modal button:not(.icon-button),
body.erp-mode .intel-modal button:not([data-intel-close]),
body.erp-mode .v83-exception-modal button,
body.erp-mode .small-upload{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  min-height:var(--b18-control-h);
  padding:8px 13px;
  border-radius:10px;
  line-height:1.2;
  text-align:center;
  vertical-align:middle;
  white-space:normal;
}
body.erp-mode .erp-content table button:not(.icon-button),
body.erp-mode .modal table button:not(.icon-button){
  min-height:31px;
  padding:5px 9px;
  border-radius:8px;
  font-size:11px;
  white-space:nowrap;
}
body.erp-mode :is(.mini,.link){min-height:30px!important;padding:5px 9px!important}
body.erp-mode .ui-btn-icon{display:inline-grid;place-items:center;flex:0 0 16px;width:16px;height:16px;margin:0!important;vertical-align:middle}
body.erp-mode .ui-btn-icon svg{display:block;width:15px;height:15px}
body.erp-mode button:disabled{cursor:not-allowed;opacity:.62}

/* 工具栏和操作区：有空间时自然排列，空间不足时整齐换行。 */
body.erp-mode :is(
  .toolbar,.sales-toolbar,.receipt-toolbar,.peer-trend-toolbar,.intel-toolbar,
  .yd-toolbar,.yd-head-actions,.yd-session-actions,.yd-pager,.record-fold-actions,
  .mp-toolbar,.mp-button-row,.mp-task-actions,.mp-detail-actions,.mp-hero-actions,
  .promo-shop-actions,.modal-footer>.actions,.box-head>.actions,.result-head>.actions
){
  align-items:center;
  gap:8px!important;
}
body.erp-mode :is(.toolbar,.sales-toolbar,.receipt-toolbar,.peer-trend-toolbar,.intel-toolbar,.yd-toolbar,.mp-toolbar){min-width:0}
body.erp-mode :is(.toolbar,.sales-toolbar,.receipt-toolbar,.peer-trend-toolbar,.yd-toolbar,.mp-toolbar) label{min-width:0}
body.erp-mode :is(.toolbar,.sales-toolbar,.receipt-toolbar,.peer-trend-toolbar,.yd-toolbar,.mp-toolbar) :is(input,select){max-width:100%}
body.erp-mode :is(.box-head,.result-head,.chart-head,.yd-bridge-head,.yd-model-head,.modal-head){align-items:flex-start}
body.erp-mode .record-fold-actions{display:flex;justify-content:flex-end;flex-wrap:wrap}
body.erp-mode .modal-footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:10px!important;
}
body.erp-mode .modal-footer>.message{flex:1 1 320px;min-width:0;overflow-wrap:anywhere}
body.erp-mode .modal-footer>.actions{display:flex;justify-content:flex-end;flex-wrap:wrap}

/* 运营总控：修复旧样式把外层分组也设为网格造成的覆盖与横向越界。 */
body.erp-mode .control-filter-panel{
  display:grid!important;
  grid-template-columns:minmax(0,1fr)!important;
  gap:var(--b18-panel-gap)!important;
  width:100%;
  min-width:0;
}
body.erp-mode .control-filter-panel>.control-filter-group,
body.erp-mode .control-filter-panel>.control-filter-advanced{
  display:block!important;
  grid-column:1/-1;
  width:100%;
  min-width:0;
  margin:0!important;
}
body.erp-mode .control-filter-group-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:5px 14px;
  margin-bottom:12px;
}
body.erp-mode .control-filter-group-head span{color:var(--b18-muted);line-height:1.5}
body.erp-mode #controlUnifiedFilters .control-unified-filter-grid,
body.erp-mode .control-statistics-grid,
body.erp-mode .control-filter-advanced-grid{
  display:grid!important;
  align-items:end!important;
  gap:10px!important;
  width:100%;
  min-width:0;
}
body.erp-mode #controlUnifiedFilters .control-unified-filter-grid{
  grid-template-columns:repeat(4,minmax(135px,1fr)) minmax(210px,1.45fr)!important;
}
body.erp-mode .control-statistics-grid{grid-template-columns:repeat(auto-fit,minmax(185px,1fr))!important}
body.erp-mode .control-filter-advanced-grid{grid-template-columns:repeat(auto-fit,minmax(165px,1fr))!important}
body.erp-mode :is(.control-unified-filter-grid,.control-statistics-grid,.control-filter-advanced-grid)>label{width:auto!important;min-width:0!important}
body.erp-mode :is(.control-unified-filter-grid,.control-statistics-grid,.control-filter-advanced-grid) :is(input,select){width:100%!important;min-width:0!important}
body.erp-mode .control-unified-timebar{
  display:grid!important;
  grid-template-columns:minmax(150px,.65fr) minmax(350px,1.8fr) repeat(2,minmax(155px,.72fr))!important;
  align-items:end!important;
  gap:10px!important;
  width:100%;
  min-width:0;
  margin-top:13px!important;
  padding-top:13px!important;
}
body.erp-mode .control-unified-timebar>label{width:auto!important;min-width:0!important}
body.erp-mode .control-unified-timebar :is(input,select){width:100%!important;min-width:0!important}
body.erp-mode .control-quick-date-buttons{
  display:flex!important;
  align-items:center;
  flex-wrap:wrap!important;
  gap:7px!important;
  min-width:0!important;
  overflow:visible!important;
}
body.erp-mode .control-quick-date-buttons button{flex:0 0 auto;min-height:36px;padding:7px 11px;white-space:nowrap}
body.erp-mode .control-filter-advanced>summary{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  min-height:50px;
  cursor:pointer;
}
body.erp-mode .control-filter-advanced>summary>span:first-child{min-width:0}
body.erp-mode .control-action-bar{
  display:flex!important;
  align-items:flex-start!important;
  justify-content:space-between!important;
  flex-wrap:wrap!important;
  gap:10px 16px!important;
  width:100%;
  min-width:0;
}
body.erp-mode :is(.control-action-primary,.control-action-secondary){display:flex!important;align-items:center!important;flex-wrap:wrap!important;gap:8px!important;min-width:0}
body.erp-mode .control-action-primary{flex:0 1 auto}
body.erp-mode .control-action-secondary{flex:1 1 560px;justify-content:flex-end}
body.erp-mode .control-valuation-status{flex:1 1 150px;min-width:0;overflow-wrap:anywhere}
body.erp-mode .control-result-pager{position:relative;z-index:1}

/* 易打单订单池：卡片自动填充，金额与数量不再挤出边界。 */
body.erp-mode .yd-bridge-head>div:first-child{flex:1 1 460px;min-width:0}
body.erp-mode .yd-head-actions{flex:0 1 auto;display:flex;justify-content:flex-end;flex-wrap:wrap}
body.erp-mode .yd-pool-kpis{
  grid-template-columns:repeat(auto-fit,minmax(145px,1fr))!important;
  gap:10px!important;
}
body.erp-mode .yd-pool-kpis>div{min-width:0}
body.erp-mode .yd-pool-kpis :is(span,b){max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body.erp-mode .yd-pool-kpis b{font-size:clamp(16px,1.4vw,20px)}
body.erp-mode .yd-settings,
body.erp-mode .yd-filters,
body.erp-mode .promo-settings{
  grid-template-columns:repeat(auto-fit,minmax(155px,1fr))!important;
}
body.erp-mode .yd-quick-time{grid-column:1/-1;min-width:0}

/* 顶栏在普通笔记本宽度下自动收敛，控件保持垂直居中。 */
body.erp-mode .erp-topbar{gap:12px;min-width:0}
body.erp-mode .erp-topbar-left{flex:1 1 280px;min-width:0;overflow:hidden}
body.erp-mode .erp-topbar-right{flex:0 1 auto;min-width:0;justify-content:flex-end}
body.erp-mode :is(.erp-date-chip,.erp-status-pill,.erp-top-icon,.erp-user-chip,.intel-global-search){align-self:center}
body.erp-mode .intel-global-search{height:38px;min-width:0}
body.erp-mode .erp-user-chip{justify-content:flex-start}

/* 信息卡与系统模块按内容宽度自动排版，减少一边拥挤一边空白。 */
body.erp-mode .erp-module-grid{grid-template-columns:repeat(auto-fit,minmax(245px,1fr))!important;align-items:stretch}
body.erp-mode .erp-module-card{display:flex;flex-direction:column;height:100%}
body.erp-mode .erp-module-card p{min-height:0!important;flex:1 1 auto}
body.erp-mode .erp-module-card .actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-top:auto;padding-top:12px}
body.erp-mode :is(.erp-kpi-grid,.sales-kpis,.receipt-kpis,.peer-trend-kpis,.intel-kpis){align-items:stretch}
body.erp-mode :is(.erp-kpi-card,.kpi,.intel-kpi){min-width:0;overflow:hidden}
body.erp-mode :is(.erp-kpi-card,.kpi,.intel-kpi) :is(strong,b,.erp-kpi-value){overflow:hidden;text-overflow:ellipsis}

/* AI 任务中心标题在深色背景上始终保持可读。 */
body.erp-mode .ai-center-hero h2{color:#fff!important}
body.erp-mode .ai-center-hero p{color:#d6e5fb!important}
body.erp-mode .ai-center-hero small{color:#bad4ff!important}

/* 表格只在自己的滚动容器中横向滚动，不撑宽整页。 */
body.erp-mode :is(.table-wrap,.table-editor,.control-display-wrap,.yd-table-wrap,.mp-table-wrap,.intel-table-wrap){max-width:100%;min-width:0;overflow:auto}
body.erp-mode :is(td,th){overflow-wrap:break-word}
body.erp-mode .control-display-wrap :is(td,th),
body.erp-mode .yd-table-wrap :is(td,th){overflow-wrap:normal}

@media(max-width:1450px){
  body.erp-mode .erp-topbar{padding-inline:18px!important}
  body.erp-mode .intel-global-search{width:190px!important}
  body.erp-mode .intel-global-search b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  body.erp-mode .intel-global-search kbd{display:none}
  body.erp-mode .erp-status-pill{max-width:145px;overflow:hidden}
  body.erp-mode .erp-status-pill span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  body.erp-mode .erp-user-chip{min-width:118px;max-width:132px}
  body.erp-mode .erp-user-chip>div:nth-child(2){min-width:0;overflow:hidden}
  body.erp-mode .erp-user-chip :is(b,span){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  body.erp-mode #controlUnifiedFilters .control-unified-filter-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  body.erp-mode #controlUnifiedFilters .control-unified-filter-grid .grow{grid-column:span 2}
  body.erp-mode .control-unified-timebar{grid-template-columns:minmax(160px,.55fr) minmax(0,1.45fr)!important}
}

@media(max-width:1180px){
  body.erp-mode .erp-date-chip{display:none!important}
  body.erp-mode .erp-breadcrumb small{display:none}
  body.erp-mode .intel-global-search{width:42px!important;padding:0!important;justify-content:center}
  body.erp-mode .intel-global-search :is(b,kbd){display:none!important}
  body.erp-mode .control-action-secondary{justify-content:flex-start}
  body.erp-mode .layout-bar.erp-page-active{grid-template-columns:repeat(2,minmax(0,1fr))}
  body.erp-mode .layout-title{grid-column:1/-1}
}

@media(max-width:900px){
  body.erp-mode .erp-page-heading{flex-direction:column!important;gap:11px!important}
  body.erp-mode .erp-page-heading>div:first-child{flex-basis:auto}
  body.erp-mode .erp-page-heading>.actions{width:100%;justify-content:flex-start!important;overflow:visible!important;flex-wrap:wrap!important}
  body.erp-mode #controlUnifiedFilters .control-unified-filter-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  body.erp-mode #controlUnifiedFilters .control-unified-filter-grid .grow{grid-column:1/-1}
  body.erp-mode .control-statistics-grid,
  body.erp-mode .control-filter-advanced-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  body.erp-mode .control-unified-timebar{grid-template-columns:minmax(150px,.7fr) minmax(0,1.3fr)!important}
  body.erp-mode .control-action-bar{display:grid!important;grid-template-columns:minmax(0,1fr)!important}
  body.erp-mode .control-action-secondary{justify-content:flex-start}
  body.erp-mode .yd-bridge-head{display:flex!important;flex-direction:column}
  body.erp-mode .yd-bridge-head>div:first-child{flex:0 1 auto}
  body.erp-mode .yd-head-actions{width:100%;justify-content:flex-start}
  body.erp-mode .yd-head-actions button{flex:1 1 160px}
}

@media(max-width:820px){
  :root{--b18-control-h:var(--b18-touch-h)}
  body.erp-mode .erp-content{padding:13px 10px calc(84px + env(safe-area-inset-bottom))!important}
  body.erp-mode .erp-topbar{height:62px!important;min-height:62px!important;padding-inline:10px!important}
  body.erp-mode .erp-topbar-left{gap:8px!important}
  body.erp-mode .erp-breadcrumb strong{font-size:15px!important}
  body.erp-mode .erp-page-updated{display:none!important}
  body.erp-mode .erp-status-pill,
  body.erp-mode .erp-date-chip,
  body.erp-mode .intel-global-search{display:none!important}
  body.erp-mode .erp-user-chip{width:42px!important;min-width:42px!important;max-width:42px!important;height:42px!important;padding:4px!important}
  body.erp-mode .erp-user-chip>div:nth-child(2),
  body.erp-mode .erp-user-chevron{display:none!important}
  body.erp-mode .erp-page-heading{padding-left:11px!important}
  body.erp-mode .layout-bar.erp-page-active{grid-template-columns:minmax(0,1fr)!important;padding:14px!important}
  body.erp-mode .layout-title{grid-column:auto}
  body.erp-mode #controlUnifiedFilters .control-unified-filter-grid,
  body.erp-mode .control-statistics-grid,
  body.erp-mode .control-filter-advanced-grid,
  body.erp-mode .control-unified-timebar{grid-template-columns:minmax(0,1fr)!important}
  body.erp-mode #controlUnifiedFilters .control-unified-filter-grid .grow{grid-column:auto}
  body.erp-mode .control-quick-date-buttons{
    flex-wrap:nowrap!important;
    overflow-x:auto!important;
    padding:2px 1px 5px;
    scrollbar-width:thin;
  }
  body.erp-mode .control-quick-date-buttons button{min-height:40px;flex:0 0 auto}
  body.erp-mode .control-action-primary,
  body.erp-mode .control-action-secondary{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));width:100%}
  body.erp-mode .control-action-primary button,
  body.erp-mode .control-action-secondary button{width:100%;min-width:0}
  body.erp-mode .control-valuation-status{grid-column:1/-1}
  body.erp-mode .yd-pool-kpis{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  body.erp-mode .yd-settings,
  body.erp-mode .yd-filters,
  body.erp-mode .promo-settings{grid-template-columns:minmax(0,1fr)!important}
  body.erp-mode .yd-settings .yd-folder,
  body.erp-mode .yd-filters label.grow{grid-column:auto!important}
  body.erp-mode .record-fold-actions{width:100%;justify-content:flex-start}
  body.erp-mode .modal-footer{align-items:stretch}
  body.erp-mode .modal-footer>.message{flex-basis:100%}
  body.erp-mode .modal-footer>.actions{width:100%;display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
  body.erp-mode .modal-footer>.actions button{width:100%}
}

@media(max-width:540px){
  body.erp-mode .erp-content{padding-inline:8px!important}
  body.erp-mode .erp-page-heading h1{font-size:20px!important}
  body.erp-mode .erp-page-heading>.actions,
  body.erp-mode .yd-head-actions,
  body.erp-mode .record-fold-actions{display:grid!important;grid-template-columns:minmax(0,1fr)!important;width:100%}
  body.erp-mode .erp-page-heading>.actions button,
  body.erp-mode .yd-head-actions button,
  body.erp-mode .record-fold-actions button{width:100%;min-width:0}
  body.erp-mode .control-action-primary,
  body.erp-mode .control-action-secondary{grid-template-columns:minmax(0,1fr)!important}
  body.erp-mode .control-valuation-status{grid-column:auto}
  body.erp-mode .yd-pool-kpis{grid-template-columns:minmax(0,1fr)!important}
  body.erp-mode .erp-module-grid{grid-template-columns:minmax(0,1fr)!important}
  body.erp-mode .modal-footer>.actions{grid-template-columns:minmax(0,1fr)}
  body.erp-mode .modal-footer>button{width:100%}
}

@media(prefers-reduced-motion:reduce){
  body.erp-mode .erp-page.erp-page-active{animation:none!important}
}
