:root {
    --bg:#f4f6f8;
    --surface:#fff;
    --surface-2:#f8fafb;
    --text:#20262e;
    --muted:#6d7682;
    --border:#dfe4ea;
    --primary:#2f5d50;
    --primary-dark:#23473d;
    --danger:#b42318;
    --warning:#9a6700;
    --success:#18794e;
    --sidebar:220px;
    --topbar:54px;
    --radius:8px;
    --shadow:0 5px 18px rgba(20,30,40,.07)
}

* {
    box-sizing:border-box
}

html,body {
    margin:0;
    height:100%;
    font-family:Arial,"Noto Sans Sinhala",sans-serif;
    color:var(--text);
    background:var(--bg);
    font-size:13px
}

a {
    color:var(--primary);
    text-decoration:none
}

button,input,select,textarea {
    font:inherit
}

.muted {
    color:var(--muted)
}

.auth-body {
    min-height:100vh;
    display:grid;
    place-items:center;
    padding:24px
}

.auth-wrap {
    width:min(720px,100%)
}

.auth-card {
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:12px;
    box-shadow:var(--shadow);
    padding:28px
}

.auth-logo {
    text-align:center
}

.auth-logo img {
    width:72px;
    height:72px
}

.auth-card h1 {
    text-align:center;
    font-size:21px;
    margin:9px 0 2px
}

.auth-subtitle {
    text-align:center;
    margin:0 0 22px
}

.auth-links {
    display:flex;
    justify-content:space-between;
    margin-top:14px
}

.form-grid {
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px
}

.form-grid .full {
    grid-column:1/-1
}

label {
    display:grid;
    gap:6px;
    font-weight:600;
    margin-bottom:12px
}

input,select,textarea {
    width:100%;
    border:1px solid #ccd3db;
    background:#fff;
    border-radius:6px;
    padding:9px 10px;
    outline:none;
    min-height:36px
}

textarea {
    min-height:72px;
    resize:vertical
}

select[multiple] {
    min-height:90px
}

input:focus,select:focus,textarea:focus {
    border-color:#789d92;
    box-shadow:0 0 0 2px rgba(47,93,80,.1)
}

.btn {
    border:0;
    border-radius:6px;
    padding:9px 13px;
    cursor:pointer;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:6px;
    font-weight:600
}

.btn:disabled {
    opacity:.5;
    cursor:not-allowed
}

.btn-primary {
    background:var(--primary);
    color:#fff
}

.btn-primary:hover {
    background:var(--primary-dark)
}

.btn-light {
    background:#eef1f4;
    color:var(--text)
}

.btn-danger {
    background:var(--danger);
    color:#fff
}

.btn-sm {
    padding:6px 9px;
    font-size:12px
}

.btn-block {
    width:100%
}

.alert {
    padding:10px 12px;
    border-radius:7px;
    margin:0 0 14px;
    border:1px solid
}

.alert.success {
    background:#edf8f2;
    border-color:#b8e0c9;
    color:#17663f
}

.alert.danger {
    background:#fff1f0;
    border-color:#f1b7b2;
    color:#8f1b14
}

.alert.warning {
    background:#fff8e6;
    border-color:#f0d18b;
    color:#745000
}

.alert ul {
    margin:0;
    padding-left:19px
}

.connection-banner {
    position:fixed;
    z-index:9999;
    left:0;
    right:0;
    top:0;
    padding:8px;
    text-align:center;
    background:#fff3cd;
    border-bottom:1px solid #e4c56f;
    color:#664d03;
    font-weight:700
}

.app-shell {
    height:100vh;
    display:grid;
    grid-template-columns:var(--sidebar) 1fr;
    grid-template-rows:var(--topbar) 1fr;
    overflow:hidden
}

.topbar {
    grid-column:1/-1;
    display:flex;
    align-items:center;
    justify-content:space-between;
    background:#fff;
    border-bottom:1px solid var(--border);
    padding:0 16px;
    z-index:4
}

.brand-inline,.topbar-user {
    display:flex;
    align-items:center;
    gap:10px
}

.brand-inline img {
    width:32px;
    height:32px
}

.topbar-user {
    font-size:12px
}

.sidebar {
    grid-row:2;
    background:#fff;
    border-right:1px solid var(--border);
    overflow:auto;
    padding:14px 10px
}

.sidebar-logo {
    text-align:center;
    padding:4px 0 14px;
    border-bottom:1px solid var(--border);
    margin-bottom:10px
}

.sidebar-logo img {
    width:58px;
    height:58px
}

.sidebar nav {
    display:grid;
    gap:4px
}

.sidebar nav a,.sidebar nav span {
    padding:9px 10px;
    border-radius:6px;
    color:var(--text)
}

.sidebar nav a:hover {
    background:#eef4f1
}

.sidebar nav a:first-child {
    font-weight:700
}

.nav-muted {
    color:#8a929c!important;
    cursor:default
}

.main-content {
    grid-column:2;
    grid-row:2;
    overflow:auto;
    padding:18px;
    position:relative
}

.sidebar-toggle {
    display:none;
    border:1px solid var(--border);
    background:#fff;
    border-radius:6px;
    padding:5px 8px;
    margin-bottom:10px
}

.page-head {
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:14px
}

.page-head h2 {
    font-size:18px;
    margin:0 0 3px
}

.page-head p {
    margin:0
}

.panel {
    background:#fff;
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:16px;
    margin-bottom:14px
}

.panel h3 {
    font-size:15px;
    margin-top:0
}

.panel.narrow {
    max-width:650px
}

.metric-grid {
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:12px;
    margin-bottom:14px
}

.metric {
    background:#fff;
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:14px;
    display:grid;
    gap:6px
}

.metric span {
    color:var(--muted);
    font-size:12px
}

.metric strong {
    font-size:18px
}

.metric small {
    color:var(--muted)
}

.launch-grid {
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:14px
}

.launch-card {
    background:#fff;
    border:1px solid var(--border);
    border-radius:10px;
    padding:22px;
    color:var(--text);
    min-height:120px;
    display:flex;
    flex-direction:column;
    justify-content:center;
    gap:8px;
    box-shadow:var(--shadow)
}

.launch-card strong {
    font-size:19px;
    color:var(--primary)
}

.launch-card span {
    color:var(--muted);
    line-height:1.5
}

.launch-card:hover {
    border-color:#9db9b1
}

.table-wrap {
    background:#fff;
    border:1px solid var(--border);
    border-radius:8px;
    overflow:auto;
    max-height:calc(100vh - 150px)
}

table {
    border-collapse:collapse;
    width:100%;
    min-width:920px
}

th,td {
    padding:9px 10px;
    border-bottom:1px solid var(--border);
    text-align:left;
    vertical-align:top;
    white-space:nowrap
}

th {
    position:sticky;
    top:0;
    background:#f7f9fa;
    z-index:2;
    font-size:12px
}

td select {
    min-width:150px
}

.empty {
    text-align:center;
    color:var(--muted);
    padding:30px
}

.inline-form {
    display:contents
}

.secret-box {
    background:#f5f7f9;
    border:1px dashed #aeb8c4;
    padding:12px;
    border-radius:6px;
    font-family:monospace;
    margin:12px 0
}

.wrap-code {
    white-space:normal;
    word-break:break-all
}

.mt-16 {
    margin-top:16px
}

.toast-container {
    position:fixed;
    right:16px;
    bottom:16px;
    z-index:9999;
    display:grid;
    gap:8px
}

.toast {
    background:#1f2933;
    color:#fff;
    padding:10px 12px;
    border-radius:7px;
    box-shadow:var(--shadow);
    max-width:320px
}

@media(max-width:900px) {
    .metric-grid {
        grid-template-columns:repeat(2,1fr)
    }
    .launch-grid {
        grid-template-columns:1fr
    }
    .app-shell {
        grid-template-columns:1fr
    }
    .sidebar {
        position:fixed;
        left:-240px;
        top:var(--topbar);
        bottom:0;
        width:220px;
        z-index:20;
        transition:left .2s
    }
    .sidebar.open {
        left:0
    }
    .main-content {
        grid-column:1
    }
    .sidebar-toggle {
        display:inline-flex
    }
}

@media(max-width:600px) {
    html,body {
        font-size:12.5px
    }
    .auth-card {
        padding:20px
    }
    .form-grid {
        grid-template-columns:1fr
    }
    .form-grid .full {
        grid-column:auto
    }
    .metric-grid {
        grid-template-columns:1fr
    }
    .topbar {
        padding:0 10px
    }
    .brand-inline strong {
        max-width:130px;
        overflow:hidden;
        text-overflow:ellipsis;
        white-space:nowrap
    }
    .main-content {
        padding:12px
    }
    .auth-links {
        gap:12px;
        flex-direction:column
    }
}

/* Phase 4: raw materials, suppliers and purchasing */

.two-column-layout {
    display:grid;
    grid-template-columns:minmax(0,2fr) minmax(260px,1fr);
    gap:14px
}

.two-column-layout.wide-left {
    grid-template-columns:minmax(0,3fr) minmax(240px,1fr)
}

.compact-panel {
    align-self:start
}

.page-actions,.form-actions,.section-head,.filter-row {
    display:flex;
    align-items:center;
    gap:8px;
    flex-wrap:wrap
}

.page-actions {
    justify-content:flex-end
}

.form-actions {
    margin-top:2px
}

.section-head {
    justify-content:space-between;
    margin:4px 0 10px
}

.section-head h3 {
    margin:0
}

.filter-row input,.filter-row select {
    width:auto;
    min-width:190px;
    margin:0
}

.multi-filter input,.multi-filter select {
    min-width:150px
}

.helper-box {
    background:#f6f8f9;
    border:1px solid var(--border);
    border-radius:6px;
    padding:10px;
    color:var(--muted);
    line-height:1.5
}

.check-label {
    display:flex;
    grid-template-columns:auto 1fr;
    align-items:center;
    gap:8px;
    padding-top:21px
}

.check-label input {
    width:auto;
    min-height:auto
}

.badge {
    display:inline-flex;
    padding:3px 7px;
    border-radius:999px;
    font-size:11px;
    font-weight:700
}

.badge.success {
    background:#e8f6ee;
    color:#17663f
}

.badge.warning {
    background:#fff3d1;
    color:#745000
}

.badge.muted-badge,.muted-badge {
    background:#eef1f4;
    color:#58616b
}

.actions-cell {
    display:flex;
    gap:6px;
    align-items:center
}

.inline-action-form {
    display:inline-flex
}

.num {
    text-align:right;
    font-variant-numeric:tabular-nums
}

.positive {
    color:var(--success)
}

.negative {
    color:var(--danger)
}

.purchase-table-wrap {
    max-height:430px;
    margin-bottom:10px
}

.purchase-table-wrap .purchase-items-table {
    width:max-content;
    min-width:100%;
    table-layout:auto
}

.purchase-items-table th,.purchase-items-table td {
    vertical-align:middle
}

.purchase-items-table .purchase-col-material {
    width:270px;
    min-width:270px
}

.purchase-items-table .purchase-col-unit {
    width:145px;
    min-width:145px
}

.purchase-items-table .purchase-col-qty {
    width:115px;
    min-width:115px
}

.purchase-items-table .purchase-col-price {
    width:130px;
    min-width:130px
}

.purchase-items-table .purchase-col-discount {
    width:120px;
    min-width:120px
}

.purchase-items-table .purchase-col-other {
    width:120px;
    min-width:120px
}

.purchase-items-table .purchase-col-batch {
    width:130px;
    min-width:130px
}

.purchase-items-table .purchase-col-date {
    width:150px;
    min-width:150px
}

.purchase-items-table .purchase-col-total {
    width:125px;
    min-width:125px
}

.purchase-items-table .purchase-col-action {
    width:54px;
    min-width:54px;
    text-align:center
}

.purchase-table-wrap .purchase-material {
    width:250px;
    min-width:250px
}

.purchase-table-wrap .purchase-input-qty {
    width:95px;
    min-width:95px
}

.purchase-table-wrap .purchase-input-money {
    width:110px;
    min-width:110px
}

.purchase-table-wrap .purchase-input-batch {
    width:110px;
    min-width:110px
}

.purchase-table-wrap .purchase-input-date {
    width:132px;
    min-width:132px
}

.purchase-table-wrap input,.purchase-table-wrap select {
    margin:0
}

.purchase-factor {
    display:block;
    margin-top:4px;
    white-space:normal;
    line-height:1.25;
    max-width:130px
}

.purchase-unit-label {
    display:block;
    font-weight:600
}

.purchase-line-total {
    font-weight:600
}

.purchase-summary {
    display:flex;
    justify-content:flex-end;
    gap:12px;
    align-items:center;
    padding:8px 4px 14px;
    font-size:14px
}

.inner-table {
    max-height:460px
}

.supplier-payment-table-wrap {
    width:100%;
    max-width:100%
}

.supplier-payment-table-wrap .supplier-payment-table {
    width:max-content;
    min-width:100%;
    table-layout:auto
}

.supplier-payment-table th,.supplier-payment-table td {
    vertical-align:middle
}

.supplier-payment-table .sp-col-purchase {
    width:170px;
    min-width:170px
}

.supplier-payment-table .sp-col-supplier {
    width:170px;
    min-width:170px
}

.supplier-payment-table .sp-col-invoice {
    width:125px;
    min-width:125px
}

.supplier-payment-table .sp-col-date {
    width:105px;
    min-width:105px
}

.supplier-payment-table .sp-col-money {
    width:115px;
    min-width:115px
}

.supplier-payment-table .sp-col-amount {
    width:135px;
    min-width:135px
}

.supplier-payment-table .sp-col-method {
    width:105px;
    min-width:105px
}

.supplier-payment-table .sp-col-payment-date {
    width:180px;
    min-width:180px
}

.supplier-payment-table .sp-col-reference {
    width:145px;
    min-width:145px
}

.supplier-payment-table .sp-col-notes {
    width:160px;
    min-width:160px
}

.supplier-payment-table .sp-col-action {
    width:95px;
    min-width:95px;
    text-align:center
}

.supplier-payment-table input,.supplier-payment-table select {
    margin:0;
    width:100%;
    min-width:0
}

.supplier-payment-action-form {
    display:flex;
    justify-content:center;
    align-items:center;
    margin:0
}

.supplier-pay-btn {
    width:76px;
    min-width:76px;
    height:36px;
    padding:8px 14px
}

.payment-history-table-wrap {
    max-height:430px
}

.row-focus {
    background:#fff8e6
}

.detail-grid {
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:12px
}

.detail-grid div {
    display:grid;
    gap:4px
}

.detail-grid span {
    color:var(--muted);
    font-size:12px
}

.dashboard-grid {
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:14px
}

.mini-list {
    display:grid;
    gap:0
}

.mini-list>div {
    display:flex;
    justify-content:space-between;
    gap:15px;
    padding:9px 0;
    border-bottom:1px solid var(--border)
}

.mini-list>div:last-child {
    border-bottom:0
}

@media(max-width:900px) {
    .two-column-layout,.two-column-layout.wide-left,.dashboard-grid {
        grid-template-columns:1fr
    }
    .detail-grid {
        grid-template-columns:repeat(2,1fr)
    }
    .page-head {
        align-items:flex-start;
        gap:10px;
        flex-direction:column
    }
    .page-actions {
        justify-content:flex-start
    }
}

@media(max-width:600px) {
    .detail-grid {
        grid-template-columns:1fr
    }
    .filter-row input,.filter-row select {
        width:100%;
        min-width:0
    }
}

/* Phase 5: products, recipes, barcodes and automatic asset refresh */

.check-group {
    display:flex;
    gap:18px;
    align-items:center;
    flex-wrap:wrap
}

.check-group .check-label {
    padding-top:0;
    margin:0
}

.product-current-image {
    display:flex;
    align-items:center;
    gap:12px
}

.product-current-image img {
    width:72px;
    height:72px;
    object-fit:cover;
    border:1px solid var(--border);
    border-radius:8px
}

.product-thumb {
    width:46px;
    height:46px;
    object-fit:cover;
    border:1px solid var(--border);
    border-radius:6px;
    display:inline-grid;
    place-items:center
}

.product-thumb.placeholder {
    background:#f4f6f8;
    color:var(--muted)
}

.product-table-wrap {
    max-height:520px
}

.compact-list {
    display:grid;
    gap:0;
    margin-top:14px;
    border-top:1px solid var(--border)
}

.compact-list a {
    display:grid;
    gap:2px;
    padding:9px 2px;
    border-bottom:1px solid var(--border);
    color:var(--text)
}

.compact-list a:hover span {
    color:var(--primary)
}

.compact-list small {
    color:var(--muted)
}

.recipe-table-wrap {
    max-height:500px
}

.recipe-table-wrap table {
    min-width:1050px
}

.recipe-table-wrap .recipe-type {
    min-width:130px
}

.recipe-table-wrap .recipe-material {
    min-width:230px
}

.recipe-table-wrap .recipe-sub {
    min-width:250px
}

.recipe-table-wrap input[type=number] {
    min-width:115px
}

.recipe-table-wrap select[name="unit_id[]"] {
    min-width:95px
}

.barcode-table-wrap {
    max-height:560px
}

.barcode-table-wrap table {
    min-width:1050px
}

.barcode-preview-cell {
    width:260px
}

.barcode-svg {
    display:block;
    width:240px;
    max-width:100%;
    height:72px;
    background:#fff
}

.row-check {
    width:16px;
    min-height:16px
}

.barcode-bulk-form {
    padding-bottom:16px
}

.barcode-label-grid {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:12px;
    padding:18px
}

.barcode-label-card {
    border:1px solid #aaa;
    background:#fff;
    padding:10px;
    min-height:145px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    text-align:center;
    gap:3px;
    break-inside:avoid
}

.barcode-label-card>strong {
    font-size:13px
}

.barcode-label-card>span,.barcode-label-card>small {
    font-size:11px
}

.barcode-label-card .barcode-svg {
    width:100%;
    height:82px
}

.barcode-print-toolbar {
    display:flex;
    gap:8px;
    padding:12px;
    position:sticky;
    top:0;
    background:#fff;
    border-bottom:1px solid #ddd;
    z-index:5
}

.barcode-print-page {
    height:auto;
    min-height:100%;
    background:#f1f3f5
}

.phase-status-grid {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:14px
}

.phase-status-card {
    background:#fff;
    border:1px solid var(--border);
    border-radius:8px;
    padding:14px
}

.phase-status-card h3 {
    margin:0 0 6px
}

.phase-status-card p {
    margin:0 0 10px;
    color:var(--muted)
}

@media(max-width:900px) {
    .phase-status-grid {
        grid-template-columns:1fr
    }
    .barcode-label-grid {
        grid-template-columns:1fr
    }
    .check-group {
        gap:10px
    }
}

@media print {
    .barcode-print-toolbar {
        display:none!important
    }
    .barcode-print-page {
        background:#fff
    }
    .barcode-label-grid {
        padding:0;
        gap:6mm;
        grid-template-columns:repeat(2,1fr)
    }
    .barcode-label-card {
        border:1px solid #000;
        min-height:38mm;
        page-break-inside:avoid
    }
}

/* Phase 6: production planning, material reservation/issue and production output */

.badge.danger-badge,.danger-badge {
    background:#fdeceb;
    color:#8f1b14
}

.warning-text {
    color:var(--warning)
}

.production-plan-table-wrap {
    max-height:390px
}

.production-plan-table {
    width:max-content;
    min-width:100%;
    table-layout:auto
}

.production-plan-table th,.production-plan-table td {
    vertical-align:middle
}

.production-plan-table th:nth-child(1),.production-plan-table td:nth-child(1) {
    min-width:300px
}

.production-plan-table th:nth-child(2),.production-plan-table td:nth-child(2) {
    min-width:110px
}

.production-plan-table th:nth-child(3),.production-plan-table td:nth-child(3) {
    min-width:190px
}

.production-plan-table th:nth-child(4),.production-plan-table td:nth-child(4) {
    min-width:135px
}

.production-plan-table th:nth-child(5),.production-plan-table td:nth-child(5) {
    width:55px;
    min-width:55px;
    text-align:center
}

.production-plan-table .production-product {
    min-width:285px
}

.production-plan-table input[type=number] {
    min-width:115px
}

.production-unit {
    font-weight:600
}

.production-recipe {
    white-space:normal;
    line-height:1.35
}

.production-list-wrap {
    max-height:520px
}

.production-list-wrap table {
    min-width:1250px
}

.production-batch-head {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    flex-wrap:wrap
}

.production-action-row {
    display:flex;
    align-items:center;
    gap:8px;
    flex-wrap:wrap
}

.production-detail-grid {
    margin-top:14px
}

.production-products-wrap table {
    min-width:1050px
}

.production-requirements-wrap table {
    min-width:1150px
}

.production-reservation-wrap table {
    min-width:1100px
}

.production-output-entry-wrap table {
    min-width:1200px
}

.production-qty-input {
    min-width:115px
}

.production-history-grid {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:14px;
    min-width:0
}

.production-history-panel,.production-log-panel {
    min-width:0;
    max-width:100%;
    overflow:hidden
}

.production-history-wrap,.production-log-wrap {
    width:100%;
    max-width:100%;
    min-width:0;
    overflow:auto
}

.production-history-wrap {
    max-height:360px
}

.production-history-wrap table {
    width:max-content;
    min-width:680px
}

.production-log-wrap table {
    width:max-content;
    min-width:920px
}

.production-return-wrap {
    width:100%;
    max-width:100%;
    min-width:0;
    overflow:auto
}

.production-return-table {
    width:100%;
    min-width:820px;
    table-layout:fixed
}

.production-return-table th,.production-return-table td {
    vertical-align:middle
}

.production-return-table .production-return-material {
    width:17%
}

.production-return-table .production-return-batch {
    width:17%
}

.production-return-table .production-return-issued {
    width:16%
}

.production-return-table .production-return-returned {
    width:16%
}

.production-return-table .production-return-available {
    width:15%
}

.production-return-table .production-return-now {
    width:19%
}

.production-return-table th.num {
    text-align:right
}

.production-return-input {
    width:100%;
    min-width:0;
    max-width:none
}

.narrow-production-panel {
    max-width:900px
}

.danger-panel {
    border-color:#efc0bc;
    background:#fffafa
}

.cancel-production-form {
    max-width:760px
}

.cancel-production-form textarea {
    min-height:70px
}

.production-workflow {
    display:flex;
    gap:6px;
    align-items:center;
    flex-wrap:wrap;
    margin-top:12px
}

.production-workflow span {
    padding:5px 8px;
    border:1px solid var(--border);
    border-radius:999px;
    background:#f7f9fa;
    font-size:11px
}

.production-workflow span.active {
    background:#e8f6ee;
    border-color:#b8e0c9;
    color:#17663f;
    font-weight:700
}

@media(max-width:900px) {
    .production-history-grid {
        grid-template-columns:minmax(0,1fr)
    }
    .production-batch-head {
        align-items:flex-start
    }
    .production-action-row {
        width:100%
    }
}

/* Phase 7: production costing, product pricing and price history */

.costing-list-wrap {
    max-height:560px
}

.costing-list-wrap table {
    min-width:1600px
}

.costing-material-wrap {
    max-height:390px
}

.costing-material-wrap table {
    min-width:920px
}

.costing-entry-wrap {
    max-height:480px
}

.costing-entry-wrap table {
    min-width:1500px
}

.costing-allocation-wrap {
    max-height:460px
}

.costing-allocation-wrap table {
    min-width:1550px
}

.costing-metrics .metric strong {
    font-size:16px
}

.cost-entry-form .cost-calculated-preview,.pricing-form input[readonly] {
    background:#f6f8f9;
    color:var(--text)
}

.cost-void-form {
    display:flex;
    align-items:center;
    gap:6px;
    min-width:235px;
    margin:0
}

.cost-void-form input {
    width:155px;
    min-width:155px;
    margin:0
}

.cost-void-form .btn {
    white-space:nowrap
}

.voided-row {
    opacity:.65
}

.voided-row td {
    background:#fafafa
}

.voided-row strong {
    font-weight:600
}

.muted-panel {
    background:#fafbfc;
    border-style:dashed
}

.pricing-product-list-wrap {
    max-height:560px
}

.pricing-product-list-wrap table {
    min-width:1600px
}

.price-history-wrap {
    max-height:580px
}

.price-history-wrap table {
    min-width:1750px
}

.pricing-form small {
    font-weight:400;
    line-height:1.35
}

.pricing-form .use-suggested-price {
    min-width:150px
}

.cost-scope-note {
    display:block;
    margin-top:3px;
    color:var(--muted);
    font-size:11px;
    white-space:normal
}

@media(max-width:900px) {
    .cost-void-form {
        min-width:220px
    }
    .costing-metrics .metric strong {
        font-size:15px
    }
}

.pricing-override-list-wrap {
    max-height:430px
}

.pricing-override-list-wrap table {
    min-width:1450px
}

/* Phase 7 Simplified UX: guided costing and pricing */

.step-kicker {
    display:inline-block;
    margin-bottom:5px;
    padding:4px 8px;
    border-radius:999px;
    background:#e8f6ee;
    color:#17663f;
    font-size:10px;
    font-weight:700;
    letter-spacing:.08em
}

.btn-lg {
    padding:11px 18px;
    font-size:14px
}

.simple-metric-grid {
    grid-template-columns:repeat(3,minmax(0,1fr))
}

.simple-toolbar-panel {
    padding:12px 16px
}

.simple-tab-row {
    display:flex;
    gap:7px;
    flex-wrap:wrap
}

.simple-costing-list-wrap {
    max-height:560px
}

.simple-costing-list-wrap table {
    min-width:1050px
}

.simple-batch-summary {
    padding:14px 16px
}

.simple-summary-grid {
    display:grid;
    grid-template-columns:repeat(5,minmax(0,1fr));
    gap:10px
}

.simple-summary-grid>div {
    display:grid;
    gap:5px;
    padding:12px;
    border:1px solid var(--border);
    border-radius:8px;
    background:var(--surface-2)
}

.simple-summary-grid span {
    font-size:11px;
    color:var(--muted)
}

.simple-summary-grid strong {
    font-size:14px
}

.simple-summary-grid .simple-highlight {
    background:#edf8f2;
    border-color:#b8e0c9
}

.simple-summary-grid .simple-highlight strong {
    font-size:18px;
    color:#17663f
}

.simple-costing-layout {
    display:grid;
    grid-template-columns:minmax(0,1.35fr) minmax(300px,.65fr);
    gap:14px;
    align-items:start
}

.simple-entry-panel,.simple-preview-panel {
    margin-bottom:14px
}

.simple-money-grid {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px 12px
}

.simple-money-grid label {
    margin:0
}

.simple-money-grid small {
    font-weight:400;
    color:var(--muted);
    line-height:1.25
}

.simple-form-footer {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:14px;
    flex-wrap:wrap;
    margin-top:16px;
    padding-top:14px;
    border-top:1px solid var(--border)
}

.simple-save-note {
    max-width:520px;
    color:var(--muted);
    line-height:1.4
}

.simple-save-note strong {
    color:var(--text)
}

.simple-preview-panel {
    position:sticky;
    top:10px
}

.simple-preview-list {
    display:grid;
    gap:0
}

.simple-preview-list>div {
    display:flex;
    justify-content:space-between;
    gap:12px;
    padding:11px 0;
    border-bottom:1px solid var(--border)
}

.simple-preview-list>div:last-child {
    border-bottom:0
}

.simple-preview-list span {
    color:var(--muted)
}

.simple-preview-list strong {
    text-align:right
}

.simple-preview-list .preview-total {
    padding-top:14px
}

.simple-preview-list .preview-total strong {
    font-size:17px;
    color:var(--primary)
}

.simple-preview-list .pricing-preview {
    background:#f8faf9;
    margin:6px -8px 0;
    padding:12px 8px;
    border-radius:7px;
    border-bottom:0
}

.simple-result-panel {
    border-color:#b8e0c9
}

.simple-product-cost-grid {
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:12px
}

.simple-product-cost-card {
    display:grid;
    gap:10px;
    padding:14px;
    border:1px solid var(--border);
    border-radius:8px;
    background:#fff
}

.simple-product-cost-card>div:first-child {
    display:grid;
    gap:2px
}

.simple-product-cost-card small {
    color:var(--muted)
}

.simple-product-cost-card>div:not(:first-child) {
    display:flex;
    justify-content:space-between;
    gap:10px
}

.simple-product-cost-card span {
    color:var(--muted);
    font-size:11px
}

.advanced-section {
    padding:0;
    overflow:hidden
}

.advanced-section>summary {
    cursor:pointer;
    list-style:none;
    padding:14px 16px;
    background:#fafbfc
}

.advanced-section>summary::-webkit-details-marker {
    display:none
}

.advanced-section>summary:after {
    content:'+';
    float:right;
    font-size:18px;
    color:var(--muted)
}

.advanced-section[open]>summary:after {
    content:'−'
}

.advanced-section-body {
    padding:0 16px 16px
}

.advanced-block {
    padding-top:16px;
    border-top:1px solid var(--border);
    margin-top:2px
}

.easy-pricing-panel {
    max-width:1100px
}

.simple-pricing-layout {
    display:grid;
    grid-template-columns:minmax(0,1.2fr) minmax(300px,.8fr);
    gap:16px
}

.simple-pricing-inputs {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px 12px
}

.simple-pricing-inputs label {
    margin:0
}

.simple-pricing-inputs label:first-child,.simple-price-reason {
    grid-column:1/-1
}

.simple-cost-source-card {
    display:grid;
    gap:4px;
    padding:12px;
    border:1px solid #b8e0c9;
    border-radius:8px;
    background:#edf8f2
}

.simple-cost-source-card span {
    font-size:11px;
    color:#17663f
}

.simple-cost-source-card strong {
    font-size:20px
}

.simple-cost-source-card small {
    color:#17663f
}

.simple-pricing-preview {
    border:1px solid var(--border);
    border-radius:8px;
    padding:14px;
    background:var(--surface-2)
}

.simple-pricing-preview h3 {
    margin:0 0 8px
}

.simple-pricing-list-wrap {
    max-height:560px
}

.simple-pricing-list-wrap table {
    min-width:1050px
}

.simple-price-history-wrap {
    max-height:580px
}

.simple-price-history-wrap table {
    min-width:1250px
}

.simple-settings-panel {
    max-width:850px
}

.advanced-inline-settings {
    border:1px dashed var(--border);
    border-radius:7px;
    padding:11px
}

.advanced-inline-settings summary {
    cursor:pointer
}

.simple-price-reason[hidden] {
    display:none!important
}

@media(max-width:1050px) {
    .simple-costing-layout,.simple-pricing-layout {
        grid-template-columns:1fr
    }
    .simple-preview-panel {
        position:static
    }
    .simple-summary-grid {
        grid-template-columns:repeat(3,minmax(0,1fr))
    }
    .simple-product-cost-grid {
        grid-template-columns:repeat(2,minmax(0,1fr))
    }
}

@media(max-width:760px) {
    .simple-metric-grid {
        grid-template-columns:1fr
    }
    .simple-summary-grid,.simple-money-grid,.simple-pricing-inputs,.simple-product-cost-grid {
        grid-template-columns:1fr
    }
    .simple-pricing-inputs label:first-child,.simple-price-reason {
        grid-column:auto
    }
    .simple-form-footer {
        align-items:stretch;
        flex-direction:column
    }
    .simple-form-footer .btn {
        width:100%
    }
    .simple-summary-grid .simple-highlight {
        grid-column:auto
    }
}

/* Production detail responsive containment fix */

.production-history-grid>.panel, .production-history-grid>.panel .table-wrap, .production-log-panel .table-wrap, .production-return-wrap {
    box-sizing:border-box
}

/* Phase 8: finished goods, stock transfers, adjustments and physical counts */

.inventory-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.inventory-filter-panel {
    padding: 12px 16px;
}

.finished-goods-summary-wrap, .finished-goods-batch-wrap, .inventory-history-wrap, .transfer-list-wrap, .transfer-detail-wrap, .transfer-receive-wrap, .stock-count-list-wrap, .stock-count-entry-wrap {
    width: 100%;
    max-width: 100%;
}

.finished-goods-summary-wrap table {
    min-width: 1320px;
}

.finished-goods-batch-wrap table {
    min-width: 1380px;
}

.inventory-history-wrap table {
    min-width: 1500px;
}

.inventory-history-filter input, .inventory-history-filter select {
    min-width: 145px;
}

.transfer-list-wrap table {
    min-width: 1650px;
}

.transfer-edit-wrap {
    max-height: 520px;
}

.transfer-edit-table {
    width: max-content;
    min-width: 100%;
}

.transfer-edit-table th, .transfer-edit-table td {
    vertical-align: middle;
}

.transfer-edit-table th:nth-child(1), .transfer-edit-table td:nth-child(1) {
    min-width: 430px;
}

.transfer-edit-table th:nth-child(2), .transfer-edit-table td:nth-child(2) {
    min-width: 90px;
}

.transfer-edit-table th:nth-child(3), .transfer-edit-table td:nth-child(3) {
    min-width: 125px;
}

.transfer-edit-table th:nth-child(4), .transfer-edit-table td:nth-child(4) {
    min-width: 120px;
}

.transfer-edit-table th:nth-child(5), .transfer-edit-table td:nth-child(5) {
    min-width: 140px;
}

.transfer-edit-table th:nth-child(6), .transfer-edit-table td:nth-child(6) {
    width: 55px;
    min-width: 55px;
    text-align: center;
}

.transfer-batch-select {
    min-width: 410px;
}

.transfer-item-qty {
    min-width: 120px;
}

.transfer-summary-panel, .stock-count-summary-panel {
    overflow: hidden;
}

.transfer-status-line {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.transfer-action-panel {
    max-width: 960px;
}

.transfer-detail-wrap table {
    min-width: 1450px;
}

.transfer-receive-wrap table {
    min-width: 1250px;
}

.transfer-receive-wrap input {
    min-width: 130px;
}

.transfer-receive-wrap .transfer-variance-reason {
    min-width: 250px;
}

.cancel-transfer-form {
    max-width: 760px;
}

.inventory-adjustment-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.inventory-existing-adjustment-form .helper-box {
    margin-bottom: 8px;
}

.stock-count-list-wrap table {
    min-width: 1100px;
}

.stock-count-entry-wrap {
    max-height: 620px;
}

.stock-count-entry-wrap table {
    min-width: 1450px;
}

.stock-count-entry-wrap input {
    min-width: 120px;
}

.stock-count-entry-wrap td:last-child input {
    min-width: 210px;
}

@media (max-width: 1050px) {
    .inventory-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .inventory-adjustment-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .inventory-metrics {
        grid-template-columns: 1fr;
    }
}
