.bom-page {
    max-width: 100%;
    padding: 6px 0 28px;
}
.bom-heading,
.bom-toolbar,
.bom-controls,
.bom-actions,
.bom-dialog-head {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
}
.bom-heading {
    margin-bottom: 24px;
}
.bom-heading h1 {
    font-size: 26px;
    margin: 6px 0;
}
.bom-heading p,
.bom-note {
    color: var(--text-secondary, #64748b);
}
.bom-eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.6px;
    color:var(--color-primary-700) !important;
}
.bom-toolbar {
    padding: 18px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    background: var(--bg-card, #fff);
    flex-wrap: wrap;
}
.bom-toolbar label {
    display: grid;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    min-width: 300px;
}
.bom-toolbar select {
    min-width: 330px;
}
.bom-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
}
.bom-actions button {
    white-space: nowrap;
}
#bom-message {
    margin: 12px 0;
    font-size: 13px;
    min-height: 20px;
}
.bom-error {
    color: #dc2626 !important;
}
.bom-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 12px;
    margin: 20px 0;
}
.bom-summary > div {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.bom-summary span {
    color: var(--text-secondary, #64748b);
    font-size: 13px;
    font-weight: 500;
}
.bom-summary strong {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
}
.bom-summary > div.bom-summary-total {
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    border-color: var(--color-primary-200, #BFDBFE);
}
.bom-summary > div.bom-summary-total span {
    color: var(--color-primary-700);
    font-weight: 600;
}
.bom-summary > div.bom-summary-total strong {
    color: var(--color-primary-500);
    font-size: 20px;
    white-space: nowrap;
}
.bom-controls {
    margin: 20px 0 10px;
    flex-wrap: wrap;
}
.bom-controls > input {
    max-width: 310px;
}
.bom-controls > select {
    max-width: 190px;
}
.bom-controls .bom-actions {
    margin-left: auto;
}
.bom-role-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--color-primary-50);
    color: var(--color-primary-500);
    border: 1px solid var(--color-primary-200);
    border-radius: 8px;
    font-size: 12.5px;
}
.bom-note {
    font-size: 12px;
    margin: 10px 0;
    line-height: 1.6;
}
.bom-inline-total {
    color: var(--color-primary-500);
}
.bom-table-wrap {
    overflow: auto;
    max-height: 64vh;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: var(--bg-card, #fff);
    box-shadow: 0 1px 3px rgba(22, 27, 84, 0.04);
}
.bom-table {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    width: max-content;
    min-width: 100%;
    font-size: 12.5px;
}
.bom-table th {
    position: sticky;
    top: 0;
    background: var(--color-primary-100);
    color: var(--color-primary-800);
    z-index: 2;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.25px;
    text-align: left;
    white-space: nowrap;
    padding: 0;
    border-bottom: 2px solid #cbd5e1;
    border-right: 1px solid #cbd5e1;
    user-select: none;
}
.bom-th-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 10px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
.bom-th-wrap > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bom-th-action {
    text-align: center !important;
    padding: 12px 6px !important;
}
.bom-col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 7px;
    height: 100%;
    cursor: col-resize;
    z-index: 4;
    border-right: 2px solid transparent;
    transition: background-color 0.15s, border-color 0.15s;
}
.bom-col-resizer:hover,
.bom-col-resizer.is-resizing {
    background-color: rgba(37, 99, 235, 0.14);
    border-right-color: var(--primary, #2563EB);
}
.bom-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #cbd5e1;
    border-right: 1px solid #cbd5e1;
    vertical-align: middle;
    background: #ffffff;
    box-sizing: border-box;
    overflow: hidden;
}
.bom-table tbody tr:nth-child(even) td {
    background: #f8fafc;
}
.bom-table tbody tr:hover td {
    background: var(--color-primary-50);
}
.bom-table td:first-child {
    background: var(--color-primary-50) !important;
    position: sticky;
    left: 0;
    z-index: 1;
    text-align: center;
    color: #5b5370;
    font-weight: 600;
}
.bom-table th:first-child {
    left: 0;
    z-index: 3;
    text-align: center;
}
.bom-table input,
.bom-table select,
.bom-table textarea {
    font: inherit;
    color: inherit;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    padding: 6px 8px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}
.bom-table textarea {
    resize: vertical;
    line-height: 1.45;
    min-height: 36px;
}
.bom-table textarea:focus,
.bom-table input:focus,
.bom-table select:focus {
    outline: 2px solid var(--primary, #2563EB);
    background: #fff;
}
.bom-num-cell {
    text-align: right;
}
.bom-num-input {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.bom-money-input {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary, #0F172A);
}
.bom-table input[type=date] {
    font-variant-numeric: tabular-nums;
}
.bom-table select {
    border-color: #cbd5e1;
    background: #ffffff;
    font-weight: 600;
}
.bom-table .purchasing {
    color: #9a6700;
    background: #fffbeb;
    border-color: #fde68a;
}
.bom-table .received {
    color: #047857;
    background: #ecfdf5;
    border-color: #a7f3d0;
}
.bom-table .cancelled {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}
.bom-table [disabled] {
    opacity: 1;
    cursor: default;
}
.bom-cell-action {
    text-align: center;
    padding: 4px !important;
}
.bom-del-row-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background-color 150ms cubic-bezier(0.22, 1, 0.36, 1), border-color 150ms cubic-bezier(0.22, 1, 0.36, 1), color 150ms cubic-bezier(0.22, 1, 0.36, 1);
}
.bom-del-row-btn:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}
.bom-tfoot-row td {
    position: sticky;
    bottom: 0;
    background: var(--color-primary-50, #EFF6FF) !important;
    border-top: 2px solid var(--primary, #2563EB);
    border-bottom: 1px solid #cbd5e1;
    border-right: 1px solid #cbd5e1;
    padding: 10px 8px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary, #0F172A);
    z-index: 2;
}
.bom-tfoot-row td:first-child {
    z-index: 3;
    background: var(--color-primary-100) !important;
    color: var(--color-primary-700);
}
.bom-total-label {
    color: var(--color-primary-700);
    letter-spacing: 0.3px;
}
.bom-total-value {
    color: var(--color-primary-500) !important;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
    background: var(--color-primary-100) !important;
}
.bom-total-sub {
    color: #334155;
    font-variant-numeric: tabular-nums;
}
.bom-total-unit {
    color: var(--color-primary-700);
    font-size: 12px;
    text-align: right;
    padding-right: 12px !important;
}
.bom-empty {
    padding: 45px !important;
    text-align: center !important;
}
.bom-sources {
    padding: 15px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    margin-top: 18px;
    font-size: 13px;
}
.bom-sources summary {
    cursor: pointer;
    font-weight: 600;
}
.bom-sources p {
    padding-top: 10px;
}
.bom-dialog {
    width: min(900px, 94vw);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    border: 1px solid var(--border-color, #E2E8F0);
    border-radius: var(--radius-modal, 12px);
    padding: 20px 24px;
    margin: auto;
    background: var(--surface, #FFFFFF);
    color: var(--text-primary, #0F172A);
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
}
.bom-dialog::backdrop {
    background: #161b5466;
}
.bom-dialog h2 {
    font-size: 20px;
}
.bom-dialog p {
    line-height: 1.6;
    margin: 14px 0;
    font-size: 13px;
}
.bom-dialog label {
    display: grid;
    gap: 7px;
    margin: 16px 0;
}
.bom-dialog [role=alert] {
    color: #b91c1c;
}
.bom-dialog input[type=file] {
    padding: 14px 0;
}
.bom-preview-table {
    overflow: auto;
    max-height: 250px;
    border: 1px solid #cbd5e1;
}
.bom-preview-table table {
    border-collapse: collapse;
    font-size: 12px;
}
.bom-preview-table th,
.bom-preview-table td {
    min-width: 100px;
    max-width: 280px;
    padding: 10px;
    border: 1px solid #cbd5e1;
    overflow-wrap: anywhere;
}
.bom-preview-table th {
    background: var(--color-primary-50);
}
@media (max-width: 900px) {
    .bom-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    .bom-summary > div.bom-summary-total {
        grid-column: span 2;
    }
}
@media (max-width: 700px) {
    .bom-heading {
        align-items: flex-start;
    }
    .bom-toolbar label,
    .bom-toolbar select {
        min-width: 0;
        width: 100%;
    }
    .bom-controls .bom-actions {
        margin-left: 0;
    }
    .bom-toolbar .bom-actions {
        justify-content: flex-start;
    }
    .bom-table-wrap {
        max-height: 65vh;
    }
}

#bom-group-tools{min-width:280px;max-width:530px;flex:1}#bom-group-tools label{display:block}.bom-row-number select{display:block;min-width:130px;margin-top:6px;font-size:11px}

#bom-group-tools{display:flex;align-items:flex-end;gap:10px;max-width:none;flex-wrap:wrap}
#bom-group-tools>label{flex:1;min-width:200px}
#bom-group-tools>div{margin-top:0!important;flex-shrink:0;align-items:center;min-height:42px}
#bom-group-tools>div .btn{white-space:nowrap}

.bom-toolbar{align-items:flex-end}
.bom-toolbar #bom-group-tools label{margin:0}
.bom-toolbar #bom-group{height:44px;margin:0;box-sizing:border-box}
.bom-toolbar>.bom-actions{align-items:center;margin:0}
.bom-toolbar>.bom-actions>.btn{height:44px;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box}

.bom-table thead th{text-transform:none;font-weight:600}

#bom-group-tools>label{display:flex;align-items:center;gap:22px;white-space:nowrap}
#bom-group-tools #bom-group{flex:1;min-width:160px;width:auto}
.bom-toolbar #bom-group-tools{align-items:center}
@media(max-width:540px){#bom-group-tools>label{gap:12px;white-space:normal}}

#bom-group-tools>label{flex:0 1 600px}
#bom-group-tools #bom-group{flex:0 1 440px;width:440px;max-width:100%}
@media(max-width:700px){#bom-group-tools>label{flex:1}#bom-group-tools #bom-group{flex:1;width:auto}}

.bom-import-error:not(:empty) { margin: 12px 0; padding: 12px 16px; border: 1px solid #fecaca; border-radius: 10px; background: #fef2f2; color: #991b1b; }
.bom-import-error p { margin: 6px 0; }
.bom-import-error ul { margin: 0; padding-left: 20px; }
