/* AVP V5.59 — Full-width workspace audit + dashboard refinement
   Rule: the page canvas uses the available desktop width. Width limits belong only
   to specific readable text/control groups, never to the working page itself. */
:root{
  --v559-line:#d8e2da;
  --v559-soft:#f5f8f5;
  --v559-ink:#17372a;
  --v559-muted:#607269;
  --v559-green:#2e6d3f;
}

/* ---------- Full-width canvas ---------- */
body.app-shell .content{
  width:100%!important;
  max-width:none!important;
  margin:0!important;
  padding:24px clamp(18px,1.45vw,30px) 54px!important;
}
@media(min-width:2300px){body.app-shell .content{max-width:none!important;margin:0!important}}

/* Remove surviving page-level width caps from earlier releases. */
body.app-shell :is(
  .page-heading,.metric-grid,.notice-filter-tabs,.tabs,.filter-bar,.ops-filter-bar,
  .catalogue-filter-panel,.products-grid,.result-toolbar,.customer-pricing-hero,
  .pricing-command-grid,.ops-bulk-toolbar,.customer-card-grid,.directory-stack,
  .commission-directory-stack,.avp-workflow-grid,.advanced-columns,.management-grid,
  .settings-grid,.account-directory-grid,.currency-manager-layout,.global-search-results,
  .dashboard-columns,.order-columns,.invoice-layout.invoice-layout-linear
){width:100%!important;max-width:none!important;margin-left:0!important;margin-right:0!important}

body.app-shell .content>.panel,
body.app-shell .content>section.panel,
body.app-shell .content>.notice,
body.app-shell .content>.table-scroll{width:100%!important;max-width:none!important}

/* Known legacy caps. */
.page-settings .panel,
.page-products .catalogue-filter-panel,
.page-products .products-grid,
.page-products .result-toolbar,
.page-pricing .customer-choice-filter,
.page-supplier_rates .customer-choice-filter,
.page-pricing .pricing-command-grid,
.page-supplier_rates .pricing-command-grid,
.page-pricing .panel,
.page-supplier_rates .panel{max-width:none!important;width:100%!important}

/* ---------- Full-width filters ---------- */
body.app-shell :is(.filter-bar,.filter-bar.smart-filter,.invoice-filter,.order-register-filter,.ops-filter-bar,.customer-choice-filter,.product-management-filter){
  width:100%!important;
  max-width:none!important;
  margin-left:0!important;
  margin-right:0!important;
}
body.app-shell .filter-bar.smart-filter{
  display:flex!important;
  flex-wrap:wrap!important;
  align-items:end!important;
  gap:10px!important;
}
body.app-shell .filter-bar.smart-filter>.field,
body.app-shell .filter-bar.smart-filter>label{
  flex:1 1 185px!important;
  min-width:170px!important;
}
body.app-shell .filter-bar.smart-filter>.field:first-of-type,
body.app-shell .filter-bar.smart-filter>label:first-of-type{
  flex:2.2 1 330px!important;
}
body.app-shell .filter-bar.smart-filter>.btn{flex:0 0 auto!important}

body.app-shell .ops-filter-bar{
  display:grid!important;
  grid-template-columns:minmax(300px,2fr) repeat(auto-fit,minmax(175px,1fr))!important;
  gap:10px!important;
  align-items:end!important;
}
body.app-shell .ops-filter-bar .ops-search{min-width:0!important}
body.app-shell .ops-filter-buttons{display:flex!important;gap:8px!important;align-items:center!important;justify-content:flex-end!important}
body.app-shell .customer-choice-filter{grid-template-columns:minmax(0,1fr) auto!important}

/* Catalogue filters were separately capped in V5.32. */
.page-products .catalogue-filter-primary,
.page-products .catalogue-filter-secondary{width:100%!important;max-width:none!important}
.page-products .catalogue-filter-secondary{grid-template-columns:repeat(auto-fit,minmax(170px,1fr))!important}

/* ---------- Customer pricing ---------- */
.page-pricing .customer-pricing-hero,
.page-supplier_rates .customer-pricing-hero{padding:20px 24px!important}
.page-pricing .pricing-command-grid,
.page-supplier_rates .pricing-command-grid{
  grid-template-columns:minmax(320px,.75fr) minmax(0,1.25fr)!important;
  gap:14px!important;
}
.page-pricing .customer-price-product-list,
.page-supplier_rates .customer-price-product-list{width:100%!important}
.page-pricing .customer-price-product,
.page-supplier_rates .customer-price-product{width:100%!important;max-width:none!important}
.page-pricing .customer-price-product-actions .quick-price-form,
.page-supplier_rates .customer-price-product-actions .quick-price-form{max-width:none!important;flex:1 1 620px!important}
.page-pricing .customer-tier-table,
.page-supplier_rates .customer-tier-table{width:100%!important}

/* ---------- Invoice register + invoice document ---------- */
.page-invoices .notice-filter-tabs,
.page-invoices .invoice-filter,
.page-invoices .panel{width:100%!important;max-width:none!important}
body.app-shell .invoice-layout.invoice-layout-linear{
  display:block!important;
  width:100%!important;
  max-width:none!important;
  margin:0!important;
}
body.app-shell .invoice-layout.invoice-layout-linear>.invoice-paper,
body.app-shell .invoice-layout.invoice-layout-linear>.invoice-editor-linear{
  width:100%!important;
  max-width:none!important;
  margin-left:0!important;
  margin-right:0!important;
}
body.app-shell .invoice-paper-simple{padding:34px clamp(30px,3vw,58px)!important}
body.app-shell .invoice-simple-info{grid-template-columns:minmax(0,1fr) minmax(300px,.65fr)!important}
body.app-shell .invoice-simple-line,
body.app-shell .invoice-simple-total{max-width:620px!important}
body.app-shell .invoice-payment-section .form-stack{max-width:none!important}

/* ---------- Dashboard ---------- */
.page-dashboard .welcome-banner{display:none!important}
.page-dashboard .dashboard-command-bar{
  display:flex;align-items:center;justify-content:space-between;gap:26px;
  width:100%;padding:18px 20px;margin:0 0 14px;border:1px solid #d8e3da;
  border-radius:10px;background:linear-gradient(105deg,#173a2b,#24583a);color:#fff;
}
.page-dashboard .dashboard-command-bar>div:first-child{min-width:0}
.page-dashboard .dashboard-command-bar span{display:block;margin-bottom:4px;font-size:10px;font-weight:850;letter-spacing:.11em;color:#a9d690}
.page-dashboard .dashboard-command-bar h2{margin:0;font-size:21px;line-height:1.2;letter-spacing:-.4px}
.page-dashboard .dashboard-command-bar p{margin:5px 0 0;font-size:12.5px;color:#c9d9ce}
.page-dashboard .dashboard-command-links{display:flex;align-items:center;gap:7px;flex-wrap:wrap;justify-content:flex-end}
.page-dashboard .dashboard-command-links a{padding:8px 11px;border:1px solid rgba(255,255,255,.18);border-radius:7px;background:rgba(255,255,255,.07);font-size:12px;font-weight:750;color:#fff}
.page-dashboard .dashboard-command-links a:hover{background:rgba(255,255,255,.13)}
.page-dashboard .dashboard-metrics{grid-template-columns:repeat(auto-fit,minmax(190px,1fr))!important;margin-bottom:14px!important}
.page-dashboard .dashboard-quick-panel,
.page-dashboard .dashboard-orders-panel,
.page-dashboard .dashboard-approval-panel{width:100%!important;max-width:none!important}
.page-dashboard .dashboard-action-grid{
  display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:9px;width:100%;
}
.page-dashboard .dashboard-action-grid>a{
  display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-areas:"icon copy" "link copy";
  align-items:center;gap:6px 12px;min-height:96px;padding:14px;border:1px solid #dfe7e1;border-radius:9px;background:#fff;
}
.page-dashboard .dashboard-action-grid>a>svg{grid-area:icon;width:21px;height:21px;color:#5f9961}
.page-dashboard .dashboard-action-grid>a>span{grid-area:copy;display:grid;gap:3px;align-content:center}
.page-dashboard .dashboard-action-grid strong{font-size:13px;color:#244333}
.page-dashboard .dashboard-action-grid small{font-size:11.5px;line-height:1.4;color:#6d7d73}
.page-dashboard .dashboard-action-grid b{grid-area:link;font-size:10.5px;color:#397448;white-space:nowrap}
.page-dashboard .dashboard-action-grid>a:hover{border-color:#bcd2bf;background:#f8fbf7}
.page-dashboard .dashboard-section-actions{display:flex;justify-content:flex-end;padding-top:12px}
.page-dashboard .dashboard-review-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:8px}
.page-dashboard .dashboard-review-grid .review-line{border:1px solid #e1e8e3!important;border-radius:8px!important;padding:12px!important;background:#fff}
.page-dashboard .dashboard-columns{display:block!important}

/* ---------- Other wide workspaces ---------- */
body.app-shell :is(.page-customers,.page-customer_detail,.page-suppliers,.page-orders,.page-commission_orders,
.page-commission_customers,.page-customer_cash,.page-credit_control,.page-commission_center,.page-currency_rates,
.page-import_center,.page-product_management,.page-pricing_matrix,.page-settings,.page-payment_terms,.page-sharing,
.page-system_health,.page-returns,.page-credit_notes) :is(.panel,.filter-bar,.ops-filter-bar,.metric-grid,.table-scroll){
  max-width:none!important;width:100%!important;
}
.page-settings .form-stack,
.page-payment_terms .form-stack,
.page-sharing .form-stack{max-width:none!important}

/* Wider pages should use width through columns, not giant single controls. */
@media(min-width:1450px){
  body.app-shell .fields-grid{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))!important}
  body.app-shell .form-section-grid.two{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  body.app-shell .form-section-grid.three{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  body.app-shell .form-section-grid.four{grid-template-columns:repeat(4,minmax(0,1fr))!important}
}

@media(max-width:1050px){
  body.app-shell .ops-filter-bar{grid-template-columns:1fr 1fr!important}
  body.app-shell .ops-filter-bar .ops-search{grid-column:1/-1!important}
  body.app-shell .ops-filter-buttons{grid-column:1/-1!important;justify-content:flex-start!important}
  .page-pricing .pricing-command-grid,.page-supplier_rates .pricing-command-grid{grid-template-columns:1fr!important}
  .page-dashboard .dashboard-command-bar{align-items:flex-start;flex-direction:column}
  .page-dashboard .dashboard-command-links{justify-content:flex-start}
}
@media(max-width:760px){
  body.app-shell .content{padding:18px 13px 38px!important}
  body.app-shell .filter-bar.smart-filter>.field,
  body.app-shell .filter-bar.smart-filter>label,
  body.app-shell .filter-bar.smart-filter>.field:first-of-type,
  body.app-shell .filter-bar.smart-filter>label:first-of-type{flex:1 1 100%!important;min-width:0!important}
  body.app-shell .filter-bar.smart-filter>.btn{flex:1 1 calc(50% - 5px)!important}
  body.app-shell .ops-filter-bar{grid-template-columns:1fr!important}
  body.app-shell .ops-filter-bar>*{grid-column:1!important}
  body.app-shell .customer-choice-filter{grid-template-columns:1fr!important}
  .page-dashboard .dashboard-command-bar{padding:16px}
  .page-dashboard .dashboard-action-grid,.page-dashboard .dashboard-review-grid{grid-template-columns:1fr!important}
  body.app-shell .invoice-paper-simple{padding:22px!important}
  body.app-shell .invoice-simple-info{grid-template-columns:1fr!important}
}

@media print{
  body.app-shell .invoice-layout.invoice-layout-linear>.invoice-paper{width:100%!important;max-width:none!important}
}
