/* MachShip Consignment Modal */
.ms-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ms-modal {
    background: #fff;
    border-radius: 12px;
    width: 95vw;
    max-width: none;
    height: 95vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.ms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.ms-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.ms-header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.ms-minimize {
    background: none;
    border: none;
    font-size: 1.35rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 0 0.35rem;
    line-height: 1;
}
.ms-minimize:hover { color: #374151; }

.ms-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}
.ms-close:hover { color: #374151; }

/* Two-column layout when invoices present */
.ms-layout {
    flex: 1;
    overflow: hidden;
}
.ms-layout--split {
    display: flex;
    gap: 0;
}
.ms-layout--split .ms-body {
    flex: 0 0 55%;
    min-width: 0;
    border-right: 1px solid #e5e7eb;
}

.ms-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

/* Xero Invoice Panel (right side) */
.ms-invoice-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #f9fafb;
}
.ms-invoice-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 0.75rem;
    background: #fff;
    flex-shrink: 0;
}
.ms-invoice-tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}
.ms-invoice-tab:hover { color: #374151; }
.ms-invoice-tab--active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}
.ms-invoice-tab--solo { cursor: default; }
.ms-invoice-tab__amount {
    font-weight: 400;
    color: #9ca3af;
    font-size: 0.72rem;
}
.ms-invoice-toolbar {
    display: flex;
    justify-content: flex-start;
    padding: 0.35rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}
.ms-invoice-toolbar__btn {
    font-size: 0.6875rem;
    font-weight: 600;
    text-decoration: none;
    padding: 0.3rem 0.625rem;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.ms-invoice-toolbar__btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}
.ms-invoice-toolbar__group {
    display: flex;
    width: 100%;
}
.ms-invoice-toolbar__btn--packing {
    width: 100%;
    text-align: center;
    border-color: #86efac;
    color: #166534;
    background: #f0fdf4;
}
.ms-invoice-toolbar__btn--packing:hover {
    background: #dcfce7;
    border-color: #22c55e;
}
.ms-invoice-frame-wrap {
    flex: 1;
    min-height: 0;
}
.ms-invoice-frame {
    width: 100%;
    height: 100%;
    border: none;
}

/* Address block */
.ms-address-block {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.ms-address-2col {
    display: flex;
    gap: 1rem;
}

.ms-address-left {
    flex: 1;
    min-width: 0;
}

.ms-address-right {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 0.3rem;
    border-left: 1px solid #e5e7eb;
    padding-left: 1rem;
}

.ms-address-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.2rem 0;
}

.ms-address-label {
    font-weight: 600;
    color: #6b7280;
    min-width: 2.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.ms-courier-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #111827;
    white-space: nowrap;
}

.ms-budget-pill {
    background: #d1fae5;
    color: #065f46;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    white-space: nowrap;
    text-align: center;
}

/* Address selector (multiple delivery addresses) */
.ms-address-select {
    flex: 1;
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #fff;
    color: #111827;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    padding-right: 1.5rem;
}
.ms-address-select:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

/* Warnings */
.ms-warnings {
    margin-bottom: 0.75rem;
}

.ms-warning-item {
    font-size: 0.8rem;
    color: #92400e;
    padding: 0.15rem 0;
}
.ms-warning-item::before {
    content: '\26A0\FE0F ';
}

.ms-warning-banner {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    color: #92400e;
    margin-bottom: 0.75rem;
}

.ms-map-btn {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: #2563eb;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
    margin-left: 0.4rem;
    white-space: nowrap;
    flex-shrink: 0;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.ms-map-btn:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

.ms-instructions-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.ms-instructions-row--split > .ms-dispatch-notice {
    flex: 1;
    min-width: 0;
}
.ms-instructions-row:not(.ms-instructions-row--split) > .ms-dispatch-notice {
    flex: 1;
}
.ms-dispatch-notice {
    background: #eff6ff;
    border: 1px solid #93c5fd;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0;
}
.ms-dispatch-notice--delivery {
    background: #fefce8;
    border-color: #fde047;
}
.ms-dispatch-notice--delivery .ms-dispatch-notice__label {
    color: #854d0e;
}
.ms-dispatch-notice--delivery .ms-dispatch-notice__text {
    color: #713f12;
}
.ms-dispatch-notice__label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #1e40af;
    margin-bottom: 0.2rem;
}
.ms-dispatch-notice__text {
    font-size: 0.8rem;
    color: #1e3a5f;
    white-space: pre-line;
}

.ms-error-banner {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    color: #991b1b;
    margin-bottom: 0.75rem;
}

/* Section title */
.ms-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

/* Item row — single line: name (50%) + fields (50%) */
.ms-item-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}
.ms-item-row:last-child { border-bottom: none; }

.ms-item-name-col {
    flex: 0 0 40%;
    position: relative;
    overflow: visible;
}

.ms-item-fields-col {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 50px 55px 55px 55px 60px auto auto;
    gap: 0.3rem;
    align-items: end;
}

.ms-remove-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.1rem;
    line-height: 1;
    align-self: center;
    margin-bottom: 0.15rem;
}
.ms-remove-btn:hover { color: #dc2626; }

.ms-duplicate-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.15rem;
    align-self: center;
    margin-bottom: 0.15rem;
    border-radius: 3px;
    transition: color 0.1s, background 0.1s;
}
.ms-duplicate-btn:hover { color: #2563eb; background: #eff6ff; }

/* Labels */
.ms-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
}

/* Search wrapper */
.ms-search-wrapper {
    position: relative;
    margin-bottom: 0.5rem;
}

.ms-input-full {
    width: 100%;
}

.ms-search-dropdown {
    background: #fff;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.ms-search-result {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    flex-direction: column;
}
.ms-search-result:last-child { border-bottom: none; }
.ms-search-result:hover { background: #fffbeb; }

.ms-search-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #111827;
}

.ms-search-meta {
    font-size: 0.75rem;
    color: #6b7280;
}

/* Item fields row */
.ms-item-fields {
    display: grid;
    grid-template-columns: 1fr 60px 80px 65px 65px 65px;
    gap: 0.4rem;
}

.ms-field {}

.ms-input {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 0.8rem;
    background: #fff;
    color: #111827;
}
.ms-input:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 1px #f59e0b;
}

select.ms-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.35rem center;
    background-size: 0.85rem;
    padding-right: 1.5rem;
}

/* Add item button */
.ms-add-btn {
    background: none;
    border: none;
    color: #f59e0b;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.35rem 0;
    margin-bottom: 0.5rem;
}
.ms-add-btn:hover { color: #d97706; }

/* Footer */
.ms-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    margin-top: 0.75rem;
}

.ms-btn {
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}

.ms-btn-primary {
    background: #f59e0b;
    color: #fff;
}
.ms-btn-primary:hover { background: #d97706; }
.ms-btn-primary:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}

.ms-btn-secondary {
    background: #f3f4f6;
    color: #374151;
}
.ms-btn-secondary:hover { background: #e5e7eb; }

/* Loading */
.ms-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 0;
    color: #6b7280;
}

.ms-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #e5e7eb;
    border-top-color: #f59e0b;
    border-radius: 50%;
    animation: ms-spin 0.7s linear infinite;
    margin-bottom: 0.75rem;
}

@keyframes ms-spin {
    to { transform: rotate(360deg); }
}

/* Items summary on quotes step */
.ms-items-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 1rem;
}

.ms-item-pill {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    color: #374151;
}

.ms-back-link {
    background: none;
    border: none;
    color: #f59e0b;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

/* Quotes table */
.ms-quotes-table {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.ms-quotes-header {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
}

.ms-quotes-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.1s;
}
.ms-quotes-row:last-child { border-bottom: none; }
.ms-quotes-row:hover { background: #fffbeb; }

.ms-quotes-row--selected {
    background: #fef3c7 !important;
    border-left: 3px solid #f59e0b;
}

.ms-qcol-carrier { flex: 1; font-weight: 500; }
.ms-qcol-service { flex: 1.2; color: #6b7280; }
.ms-qcol-buy { flex: 0 0 90px; font-weight: 600; color: #dc2626; display: flex; align-items: center; gap: 0.3rem; }
.ms-qcol-sell { flex: 0 0 110px; font-weight: 600; color: #059669; }
.ms-qcol-eta { flex: 0 0 90px; color: #6b7280; font-size: 0.8rem; }
.ms-qcol-days { flex: 0 0 45px; text-align: center; color: #6b7280; }

/* Budget tick — green circle with checkmark next to buy price */
.ms-budget-tick {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #d1fae5;
    color: #059669;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

/* Carrier optional services panel */
.ms-carrier-options {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.75rem;
}
.ms-carrier-options__title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
    margin-bottom: 0.4rem;
}
.ms-carrier-options__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1.2rem;
}
.ms-carrier-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: #374151;
    white-space: nowrap;
}
.ms-carrier-option__checkbox {
    width: 15px;
    height: 15px;
    accent-color: #2563eb;
    cursor: pointer;
}
.ms-carrier-option__label {
    user-select: none;
}
.ms-carrier-option__req {
    color: #ef4444;
    font-weight: 700;
}

/* Full-width create button between items summary and quotes */
.ms-btn-create {
    width: 100%;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.ms-btn-create:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Success */
.ms-success {
    text-align: center;
    padding: 1.5rem 0;
}

.ms-success-icon {
    width: 3rem;
    height: 3rem;
    background: #d1fae5;
    color: #059669;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 auto 1rem;
}

.ms-success-details {
    text-align: left;
    max-width: 320px;
    margin: 0 auto;
}

.ms-success-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.85rem;
}
.ms-success-row:last-child { border-bottom: none; }

.ms-success-label {
    color: #6b7280;
    font-weight: 500;
}

.ms-success-value {
    color: #111827;
    font-weight: 600;
}

/* Reprint Labels */
.ms-reprint-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
    text-align: left;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}
.ms-reprint-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}
.ms-reprint-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.ms-reprint-select {
    flex: 1;
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #111827;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    padding-right: 1.5rem;
}
.ms-reprint-success {
    font-size: 0.8125rem;
    color: #16a34a;
    margin-top: 0.375rem;
}
.ms-reprint-error {
    font-size: 0.8125rem;
    color: #dc2626;
    margin-top: 0.375rem;
}

/* Minimized bar — fixed bottom-right like email compose */
.ms-minimized-bar {
    position: fixed;
    bottom: 0;
    right: 1.5rem;
    width: 320px;
    background: #1f2937;
    color: #fff;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    z-index: 9998;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
}

.ms-minimized-bar__content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    font-weight: 500;
}
.ms-minimized-bar__content:hover { opacity: 0.85; }
.ms-minimized-bar__content svg { flex-shrink: 0; color: #f59e0b; }
.ms-minimized-bar__content span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ms-minimized-bar__actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.ms-minimized-bar__actions button {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 1.1rem;
    line-height: 1;
}
.ms-minimized-bar__actions button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}
