/**
 * Global max content width for Sukuma ERP admin / app pages.
 * Loaded after page styles so it can normalize legacy 1200px shells.
 */
:root {
    --admin-page-max: 1400px;
}

/* Business create — wider wizard (must set token so later rules using var() stay 1700) */
body.bz-create-v2-page {
    --admin-page-max: 1700px;
}

/* Procurement create / edit (pe-head-wrap pages) — match admin content width */
body:has(> section.pe-head-wrap) {
    --admin-page-max: 1350px;
}

/* Business records list (/admin/business) — match admin home content width */
body.biz-v2-layout {
    --admin-page-max: 1350px;
}

/* Procurement list (/admin/procurement) — match admin home content width */
body.proc-v2-page {
    --admin-page-max: 1350px;
}

/* Executions hub (/admin/executions) — match admin home content width */
body.exec-v2-hub {
    --admin-page-max: 1350px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.exec-v2-hub > header.v2-topbar,
body.exec-v2-hub > header.hw-top {
    flex-shrink: 0;
    width: 100%;
    max-width: none !important;
}

/* Batches list (/admin/batches) — match admin home content width */
body.batch-v2-page {
    --admin-page-max: 1350px;
}

/* Header + sub-nav stay full viewport width; only page content is capped below. */

/* Top-level page shells */
body > .wrap,
body > .main-content,
body > main,
body > main.main-content,
body.proc-v2-page > section.v2-pagehead,
body.proc-v2-page > section.v2-stats,
body > section.bz-head,
body.bz-create-v2-page > section.bz-head,
body.bz-create-v2-page > main.main-content,
body > section.pe-head-wrap,
body > .page-shell,
body > .content-area,
body > .biz-v2-wrap,
body > .eb-v2-layout {
    max-width: var(--admin-page-max);
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    box-sizing: border-box;
}

/* Hub / card landing pages */
body > .group-cards-page {
    max-width: var(--admin-page-max);
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    box-sizing: border-box;
}

/* Common inner content bands (batches, requisitions-style heroes, etc.) */
body .hero-inner,
body .search-strip-inner,
body .content-card,
body .incoming-receipt-panel,
body .secbar,
body .page-inner,
body .toolbar-inner,
body .batch-toolbar-inner,
body .cards-section-inner,
body .alert,
body .content-wrap,
body .page-wrap,
body .detail-wrap,
main.ws-main,
body .eb-v2-wrap,
body .eb-v2-hero,
body .eb-v2-toolbar {
    max-width: var(--admin-page-max) !important;
}

/* Legacy inline shells (1200–1280px) */
body .main-content:not(.modal .main-content) {
    max-width: var(--admin-page-max) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Accounting / legacy hero bars */
body .hero {
    max-width: var(--admin-page-max) !important;
}

/* Card grids that cap at 1400 in some views — ensure consistency */
body .action-cards-grid {
    max-width: var(--admin-page-max);
}

/* Fixed sidebar layouts: cap readable width in the main column */
body:has(> .sidebar) > .main-content,
body:has(> .sidebar) > main.main-content {
    max-width: min(var(--admin-page-max), calc(100vw - 280px));
}

body.bz-create-v2-page > section.bz-head,
body.bz-create-v2-page > main.main-content {
    max-width: 1700px !important;
}

body:has(> section.pe-head-wrap) > section.pe-head-wrap,
body:has(> section.pe-head-wrap) > main.main-content {
    max-width: 1350px !important;
    width: 100%;
    box-sizing: border-box;
}

body.proc-v2-page > .v2-pagehead,
body.proc-v2-page > .v2-stats,
body.proc-v2-page > main.main-content {
    max-width: 1350px !important;
    width: 100%;
    box-sizing: border-box;
}

body.exec-v2-hub > main.hw-wrap {
    flex: 1 0 auto;
    max-width: 1350px !important;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

body.exec-v2-hub > .hw-foot {
    flex-shrink: 0;
    margin-top: auto;
    width: 100%;
    max-width: none !important;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
    border-top: 1px solid #E5E7EB;
    background: #fff;
}

body.batch-v2-page > main.main-content.bt-main {
    max-width: 1350px !important;
    width: 100%;
    box-sizing: border-box;
}

body.batch-v2-page .bt-card.content-card {
    max-width: none !important;
}

/* Warehouse stock detail (/admin/accounts/stock/warehouse/*) */
body.stock-wd-v2-page {
    --admin-page-max: 1350px;
}

body.stock-wd-v2-page > main.main-content {
    max-width: 1350px !important;
    width: 100%;
    box-sizing: border-box;
}

body.stock-wd-v2-page .content-card,
body.stock-wd-v2-page .incoming-receipt-panel,
body.stock-wd-v2-page .asof-results-banner,
body.stock-wd-v2-page .hero-inner,
body.stock-wd-v2-page .ws-stats-wrap,
body.stock-wd-v2-page .asof-toolbar-inner {
    max-width: 1350px !important;
}

body.stock-wd-v2-page .wd-panel > .content-card,
body.stock-wd-v2-page .wd-grid .content-card {
    max-width: 100% !important;
}

/* Production cost (/admin/production-cost, execution mirror) */
body.pc-v2-page {
    --admin-page-max: 1350px;
}

body.pc-v2-page > .pc-v2-shell {
    max-width: 1350px !important;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

body.pc-v2-page > .pc-v2-shell > main.main-content {
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

body.pc-v2-page .main-content .content-card,
body.pc-v2-page .main-content > .panel,
body.pc-v2-page .main-content > .period-strip {
    max-width: 100% !important;
}

/* Production cost report show (/admin/production-cost/{id}) */
body.pc-show-v2-page {
    --admin-page-max: 1350px;
}

body.pc-show-v2-page > main.pc-wrap,
body.pc-show-v2-page > footer.pc-foot {
    max-width: 1350px !important;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* Batch production / allocation report (/admin/executions/reports/batch/*) */
body.batch-report-v2-page {
    --admin-page-max: 1350px;
}

body.batch-report-v2-page > main.main-content {
    max-width: 1350px !important;
    width: 100%;
    box-sizing: border-box;
}

body.batch-report-v2-page .hero-inner,
body.batch-report-v2-page .form-container,
body.batch-report-v2-page .brp-workspace {
    max-width: 1350px !important;
}

/* Expense budgets (/admin/accounting/expense-budgets) — not requisitions (.pr-page) */
body:has(> .wrap > .eb-v2-layout:not(.pr-page)) {
    --admin-page-max: 1350px;
}

body:has(> .wrap > .eb-v2-layout:not(.pr-page)) > .wrap {
    max-width: 1350px !important;
    width: 100%;
    box-sizing: border-box;
}

/* Operation dashboard (/admin/executions/allocation-position) */
body.alloc-v2-page {
    --admin-page-max: 1350px;
}

body.alloc-v2-page > .v2-pagehead,
body.alloc-v2-page > section.v2-stats,
body.alloc-v2-page > main.main-content {
    max-width: 1350px !important;
    width: 100%;
    box-sizing: border-box;
}

body.alloc-v2-page > main.main-content .alloc-v2-card {
    max-width: none !important;
    width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box;
}

@media (max-width: 900px) {
    body:has(> .sidebar) > .main-content,
    body:has(> .sidebar) > main.main-content {
        max-width: 100%;
    }
}
