/* =========================================================
   PAGE
========================================================= */

.so-page{
    padding:14px;
    background:#f6f7f9;
    min-height:100vh;
}

/* =========================================================
   HEADER
========================================================= */

.so-header{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:12px;
    margin-bottom:8px;
    flex-wrap:wrap;
}

.so-header-left{
    display:flex;
    align-items:center;
    gap:12px;
}

.so-icon{
    width:42px;
    height:42px;
    border-radius:10px;
    background:#0f766e;
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:18px;
    box-shadow:none;
}

.so-title{
    margin:0;
    font-size:18px;
    font-weight:700;
    color:#111827;
}

.so-subtitle{
    color:#6b7280;
    font-size:11px;
}

.so-header-actions{
    display:flex;
    gap:8px;
    align-items:center;
    flex-wrap:wrap;
}

.so-btn{
    border-radius:6px;
    padding:7px 11px;
    font-weight:600;
    font-size:12px;
}

.so-columns-menu{
    min-width:260px;
    padding:10px;
}

.so-columns-title{
    font-size:12px;
    font-weight:700;
    color:#334155;
    padding:4px 6px 8px;
    border-bottom:1px solid #e5e7eb;
    margin-bottom:6px;
}

.so-columns-list{
    display:grid;
    gap:4px;
    max-height:360px;
    overflow:auto;
}

.so-column-option{
    display:grid;
    grid-template-columns:18px 18px 1fr;
    align-items:center;
    gap:7px;
    padding:6px;
    border-radius:6px;
    cursor:grab;
    font-size:12px;
    color:#111827;
}

.so-column-option:hover{
    background:#f1f5f9;
}

.so-column-option i{
    color:#94a3b8;
}

.so-wh-stock-option{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    width:100%;
}

.so-wh-stock-option strong{
    color:#047857;
    font-size:12px;
    white-space:nowrap;
}

/* =========================================================
   STATUS
========================================================= */

.so-status-badge{
    background:#e5e7eb;
    color:#111827;
    padding:7px 12px;
    border-radius:6px;
    font-weight:700;
    font-size:12px;
}

/* =========================================================
   CARD
========================================================= */

.so-card{
    background:#fff;
    border-radius:8px;
    border:1px solid #e5e7eb;
    overflow:hidden;
    box-shadow:none;
}


.so-card-header{
    padding:8px 10px;
    border-bottom:1px solid #e5e7eb;
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:10px;
    font-weight:700;
    background:#fff;
    min-height: auto;
}

.so-line-help{
    flex:1;
    color:#64748b;
    font-size:12px;
    font-weight:500;
    text-align:center;
}

.so-scan-tools{
    display:flex;
    align-items:center;
    gap:6px;
    flex-wrap:wrap;
}

.so-barcode-entry{
    width:300px;
    max-width:100%;
}

.so-barcode-entry .input-group-text{
    background:#eef8f7;
    color:#0f766e;
    border-color:#d8e7ed;
}

.so-scan-camera{
    background:#0f172a;
    border-radius:8px;
    min-height:280px;
    overflow:hidden;
    position:relative;
}

.so-scan-camera video{
    display:block;
    width:100%;
    height:320px;
    object-fit:cover;
}

.so-scan-modal textarea{
    direction:ltr;
    text-align:left;
    font-family:Consolas, monospace;
}

.so-scan-toast{
    position:fixed;
    z-index:1080;
    inset-inline-end:18px;
    bottom:18px;
    background:#0f172a;
    color:#fff;
    border-radius:8px;
    padding:10px 14px;
    box-shadow:0 14px 34px rgba(15,23,42,.25);
    font-size:13px;
}

.so-workflow-card .card-body{
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}




.so-card-body{
    padding: 10px;
}

.so-card .row.g-3{
    --bs-gutter-y: 8px;
    --bs-gutter-x: 10px;
}

.so-card .form-control,
.so-card .form-select{
    min-height: 34px;
    height: 34px;
    padding: 4px 10px;
    font-size: 13px;
}

#notes{
    min-height: 54px !important;
    resize: vertical;
}

.so-card .form-label{
    margin-bottom: 3px;
    font-size: 12px;
    font-weight: 600;
}

.select2-container--default .select2-selection--single {
    min-height: 34px;
    height: 34px;
    padding: 4px 10px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 24px;
}

.so-customer-picker {
    gap: 6px;
}

.so-customer-picker{
    display:grid;
    grid-template-columns:minmax(0, 1fr) 42px;
    align-items:stretch;
    gap:8px;
}

.so-customer-picker .select2-container{
    width:100% !important;
}

.so-add-customer-btn{
    width:42px;
    min-height:38px;
    padding:0;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border-radius:6px;
}

.so-field-hint{
    margin-top:4px;
    color:#6b7280;
    font-size:11px;
    line-height:1.4;
}

.so-customer-balance{
    margin-top:6px;
    padding:8px 10px;
    border:1px solid #dbeafe;
    border-radius:8px;
    background:#eff6ff;
    display:flex;
    justify-content:space-between;
    align-items:center;
    font-size:12px;
}

.so-customer-balance strong{
    font-size:15px;
    color:#1d4ed8;
}

.so-warehouse-select-wrap #fulfillment_warehouse_id + .select2 .select2-selection--single{
    min-height:40px;
    border:1px solid #cbd5e1;
    background:#f8fafc;
}

.so-warehouse-select-wrap #fulfillment_warehouse_id + .select2 .select2-selection__rendered{
    line-height:38px;
    font-weight:600;
    color:#0f172a;
}

.so-warehouse-select-wrap #fulfillment_warehouse_id + .select2 .select2-selection__arrow{
    height:38px;
}

.so-card-meta{
    color:#6b7280;
    font-size:13px;
}

/* =========================================================
   FORM
========================================================= */

.form-label{
    font-weight:600;
    margin-bottom:6px;
    color:#374151;
}

.form-control,
.form-select{
    border-radius:6px;
    border:1px solid #dbe2ea;
    min-height:38px;
    box-shadow:none !important;
}

.form-control:focus,
.form-select:focus{
    border-color:#0f766e;
}

/* =========================================================
   WORKFLOW
========================================================= */

.so-workflow-card{
    border:none;
    border-radius:8px;
    overflow:hidden;
    box-shadow:
        0 4px 12px rgba(0,0,0,.04),
        0 1px 3px rgba(0,0,0,.06);
}

.workflow-wrap{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    width:100%;
}

.wf-step{
    display:flex;
    align-items:center;
    gap:10px;
    flex:1;
    position:relative;
    min-height: 52px;
}

.wf-icon{
    width:38px;
    height:38px;
    border-radius:8px;
    background:#e6f4f1;
    color:#0f766e;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:17px;
}

.wf-title{
    font-weight:700;
    color:#111827;
    font-size: 13px;
}

.wf-sub{
    font-size:11px;
    color:#6b7280;
}

.wf-line{
    height:2px;
    flex:1;
    background:#dbe2ea;
    max-width:80px;
}

.wf-step.active .wf-icon{
    background:#0f766e;
    color:#fff;
}

.so-cycle-panel{
    display:grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
    gap:12px;
    margin-bottom:12px;
}

.so-cycle-metrics,
.so-cycle-links{
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius:8px;
    padding:10px;
}

.so-cycle-metrics{
    display:grid;
    grid-template-columns:repeat(5, minmax(0, 1fr));
    gap:8px;
}

.so-cycle-metrics div,
.so-cycle-links > div{
    min-width:0;
}

.so-cycle-metrics span,
.so-cycle-links span{
    display:block;
    color:#64748b;
    font-size:11px;
    font-weight:700;
    margin-bottom:4px;
}

.so-cycle-metrics strong{
    display:block;
    color:#111827;
    font-size:16px;
    line-height:1.2;
}

.so-cycle-links{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px;
}

.so-cycle-docs{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
}

.so-cycle-docs a,
.so-cycle-docs em{
    display:inline-flex;
    align-items:center;
    min-height:26px;
    padding:0 8px;
    border-radius:999px;
    border:1px solid #d1d5db;
    color:#374151;
    background:#f9fafb;
    font-size:12px;
    font-style:normal;
    text-decoration:none;
}

@media (max-width: 992px){
    .so-cycle-panel{
        grid-template-columns:1fr;
    }

    .so-cycle-metrics{
        grid-template-columns:repeat(2, minmax(0, 1fr));
    }
}

/* =========================================================
   TABLE
========================================================= */

.so-table-wrap{
    overflow:auto;
}

.so-lines-table{
    min-width:1180px;
    table-layout:fixed;
    margin:0;
    border-collapse:separate;
    border-spacing:0;
}

.so-lines-table thead th{
    position:sticky;
    top:0;
    background:#f3f4f6;
    z-index:5;
    font-size:12px;
    white-space:nowrap;
    border-bottom:1px solid #d1d5db;
    color:#374151;
    padding:9px 8px;
    font-weight:700;
}

.so-lines-table tbody td{
    vertical-align:middle;
    white-space:nowrap;
    padding:7px 8px;
    border-bottom:1px solid #edf0f3;
}

.so-lines-table tbody tr:hover td{
    background:#fafafa;
}

.so-lines-table input,
.so-lines-table select{
    min-width:76px;
    width:100%;
    border-radius:5px;
    min-height:34px;
    font-size:12px;
}

.so-lines-table .select2-container{
    width:100% !important;
}

.so-lines-table th:nth-child(1),
.so-lines-table td:nth-child(1),
.so-lines-table th:nth-child(18),
.so-lines-table td:nth-child(18),
.so-lines-table th:nth-child(19),
.so-lines-table td:nth-child(19){
    width:48px;
}

.so-lines-table th:nth-child(2),
.so-lines-table td:nth-child(2){
    min-width:260px;
}

.so-lines-table th:nth-child(3),
.so-lines-table td:nth-child(3){
    min-width:190px;
}

.so-lines-table th:nth-child(6),
.so-lines-table td:nth-child(6),
.so-lines-table th:nth-child(7),
.so-lines-table td:nth-child(7),
.so-lines-table th:nth-child(8),
.so-lines-table td:nth-child(8),
.so-lines-table th:nth-child(9),
.so-lines-table td:nth-child(9),
.so-lines-table th:nth-child(11),
.so-lines-table td:nth-child(11),
.so-lines-table th:nth-child(12),
.so-lines-table td:nth-child(12){
    width:86px;
}

.so-lines-table th:nth-child(13),
.so-lines-table td:nth-child(13),
.so-lines-table th:nth-child(16),
.so-lines-table td:nth-child(16){
    width:118px;
}

.so-row-duplicate td{
    background:#fff7ed !important;
    box-shadow:inset 0 0 0 1px #fb923c;
}

.line_net{
    color:#111827;
    font-weight:700;
}

.so-gift-line td{
    background:#f0fdf4;
}

.so-gift-badge{
    display:inline-flex;
    margin-inline-start:6px;
    padding:2px 7px;
    border-radius:999px;
    background:#dcfce7;
    color:#166534;
    font-size:11px;
    font-weight:900;
}

.so-gift-toggle{
    width:34px;
    height:30px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border:1px solid #dbe4ee;
    border-radius:8px;
    background:#ffffff;
    color:#64748b;
    cursor:pointer;
    transition:background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.so-gift-toggle.active,
.so-gift-toggle[aria-pressed="true"]{
    background:#ecfdf5;
    border-color:#34d399;
    color:#047857;
    box-shadow:0 0 0 3px rgba(16,185,129,.12);
}

.so-gift-toggle:disabled{
    opacity:.45;
    cursor:not-allowed;
    background:#f8fafc;
}

.so-readonly .so-lines-table input:disabled,
.so-readonly .so-lines-table select:disabled,
.so-readonly .so-card input:disabled,
.so-readonly .so-card select:disabled,
.so-readonly .so-card textarea:disabled{
    background:#f9fafb;
    color:#374151;
    border-color:#e5e7eb;
    opacity:1;
}

.so-readonly .select2-container--default.select2-container--disabled .select2-selection--single{
    background:#f9fafb;
    border-color:#e5e7eb;
    cursor:not-allowed;
}

/* =========================================================
   MINI CARDS
========================================================= */

.so-mini-card{
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius:8px;
    padding:14px;
    height:100%;
    box-shadow:none;
}

.so-mini-card.dark{
    background:#111827;
    color:#fff;
}

.so-mini-title{
    font-size:12px;
    color:#6b7280;
    margin-bottom:10px;
}

.so-mini-card.dark .so-mini-title{
    color:#d1d5db;
}

.so-mini-value{
    font-size:22px;
    font-weight:800;
}

/* =========================================================
   STATUS COLORS
========================================================= */

.badge-draft{
    background:#e5e7eb;
    color:#111827;
}

.badge-partial{
    background:#fef3c7;
    color:#92400e;
}

.badge-full{
    background:#dcfce7;
    color:#166534;
}

/* =========================================================
   MODAL
========================================================= */

.modal-content{
    border:none;
    border-radius:8px;
}

.modal-header{
    border-bottom:1px solid #eef2f7;
}

.modal-footer{
    border-top:1px solid #eef2f7;
}

.so-duplicate-modal .modal-dialog{
    max-width:520px;
}

.so-duplicate-modal .modal-content{
    overflow:hidden;
    box-shadow:0 24px 64px rgba(15,23,42,.22);
}

.so-duplicate-modal .modal-header{
    align-items:flex-start;
    padding:20px 22px;
}

.so-duplicate-heading{
    display:flex;
    align-items:center;
    gap:12px;
}

.so-duplicate-heading .modal-title{
    margin:0;
    color:#0f172a;
    font-size:18px;
    font-weight:800;
}

.so-duplicate-heading p{
    margin:4px 0 0;
    color:#64748b;
    font-size:13px;
}

.so-duplicate-icon{
    width:42px;
    height:42px;
    display:inline-flex;
    flex:0 0 42px;
    align-items:center;
    justify-content:center;
    border-radius:8px;
    background:#eff6ff;
    color:#2563eb;
    font-size:19px;
}

.so-duplicate-modal .modal-body{
    padding:20px 22px;
}

.so-duplicate-item{
    display:flex;
    flex-direction:column;
    gap:4px;
    padding:13px 14px;
    margin-bottom:12px;
    border-inline-start:3px solid #2563eb;
    background:#f8fafc;
}

.so-duplicate-item span,
.so-duplicate-facts span{
    color:#64748b;
    font-size:12px;
}

.so-duplicate-item strong{
    color:#0f172a;
    font-size:15px;
}

.so-duplicate-facts{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:10px;
    margin-bottom:18px;
}

.so-duplicate-facts > div{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    padding:10px 12px;
    border:1px solid #e2e8f0;
    border-radius:8px;
}

.so-duplicate-facts strong{
    color:#0f172a;
    font-size:14px;
}

.so-duplicate-modal #duplicateItemNewQty{
    direction:ltr;
    text-align:start;
    font-weight:700;
}

.so-duplicate-result{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin-top:10px;
    padding:10px 12px;
    border-radius:8px;
    background:#eff6ff;
    color:#1e3a8a;
    font-size:12px;
}

.so-duplicate-result strong{
    direction:ltr;
    color:#1d4ed8;
    font-size:16px;
}

.so-duplicate-modal .modal-footer{
    padding:14px 22px;
    flex-wrap:nowrap;
}

@media (max-width:575.98px){
    .so-duplicate-modal .modal-dialog{
        margin:12px;
    }

    .so-duplicate-facts{
        grid-template-columns:1fr;
    }

    .so-duplicate-modal .modal-footer{
        display:grid;
        grid-template-columns:1fr;
    }

    .so-duplicate-modal .modal-footer .btn{
        width:100%;
        margin:0;
    }
}

.table-order-lines {
    table-layout: fixed;
    width: 100%;
}

.table-order-lines td,
.table-order-lines th {
    vertical-align: middle;
    white-space: nowrap;
}
.line_net{
    min-width:120px;
}

.so-lines-table td:has(.item) {
    min-width: 340px;
}

.erp-item-option-main {
    font-weight: 700;
    color: #111827;
    line-height: 1.25;
}

.erp-item-option-meta {
    margin-top: 2px;
    font-size: 11px;
    color: #64748b;
}

.select2-container--default .select2-results__option--highlighted .erp-item-option-main,
.select2-container--default .select2-results__option--highlighted .erp-item-option-meta {
    color: #fff;
}

.so-cancel-modal .modal-header{
    align-items:flex-start;
    border-bottom:1px solid #e5e7eb;
}

.so-cancel-modal .modal-title{
    color:#991b1b;
    font-weight:800;
}

.so-cancel-modal textarea{
    resize:vertical;
    min-height:120px;
}

.dropdown-item.disabled{
    pointer-events:none;
    opacity:.5;
}
