/* Item master visual system. All selectors are scoped to item master screens. */
.cg-items-page {
    --cg-item-border: #dce5ed;
    --cg-item-muted: #64788b;
    --cg-item-ink: #183b56;
    --cg-item-soft: #f5f9fc;
    color: var(--cg-item-ink);
}

.cg-items-page .cg-items-page-head,
.cg-master-items .cg-master-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 0 0 18px;
}

.cg-items-page .cg-items-page-head h2,
.cg-master-items .cg-master-page-head h2 {
    margin: 0;
    color: var(--cg-item-ink, #183b56);
    font-size: clamp(1.45rem, 2vw, 1.85rem);
    font-weight: 700;
    letter-spacing: -.025em;
}

.cg-items-page .cg-items-page-head p,
.cg-master-items .cg-master-page-head small {
    display: block;
    margin: 5px 0 0;
    color: var(--cg-item-muted, #64788b);
    font-size: .9rem;
}

.cg-items-eyebrow {
    margin-bottom: 5px;
    color: #648096;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .075em;
    text-transform: uppercase;
}

.cg-items-page-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.cg-items-page .card,
.cg-master-items .card {
    border: 1px solid var(--cg-item-border, #dce5ed);
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(22, 53, 77, .055);
}

.cg-master-items .cg-items-filter-card .card-body {
    padding: 18px;
}

.cg-master-items .cg-items-filter-card .form-label {
    margin-bottom: 6px;
    color: #294a63;
    font-size: .8rem;
    font-weight: 650;
}

.cg-master-items .cg-items-filter-card .form-control,
.cg-master-items .cg-items-filter-card .form-select {
    min-height: 43px;
    border-color: #d7e1e9;
    border-radius: 10px;
}

.cg-master-items .cg-items-results-card {
    overflow: hidden;
}

.cg-items-results-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid #e4ebf0;
    background: #fff;
}

.cg-items-results-heading h3 {
    margin: 0;
    color: #24465f;
    font-size: 1rem;
    font-weight: 700;
}

.cg-items-results-heading p {
    margin: 4px 0 0;
    color: var(--cg-item-muted, #64788b);
    font-size: .8rem;
}

.cg-items-results-count {
    flex: 0 0 auto;
    padding: 5px 10px;
    border: 1px solid #dce8ef;
    border-radius: 999px;
    background: #f5f9fc;
    color: #42627a;
    font-size: .75rem;
    font-weight: 700;
}

.cg-master-items .cg-items-table {
    min-width: 1120px;
}

.cg-master-items .cg-items-table thead th {
    padding: 13px 12px;
    border-bottom: 1px solid #dce6ed;
    background: #f3f8fb;
    color: #456176;
    font-size: .7rem;
    font-weight: 750;
    letter-spacing: .045em;
    text-transform: uppercase;
    white-space: nowrap;
}

.cg-master-items .cg-items-table tbody td {
    padding: 13px 12px;
    border-color: #e8eef2;
    color: #40596e;
    font-size: .84rem;
    vertical-align: middle;
}

.cg-master-items .cg-items-table tbody tr:hover {
    background: #f8fbfd;
}

.cg-master-items .cg-item-code {
    color: #60788c;
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cg-master-items .cg-item-name {
    color: #1d3f59;
    font-weight: 700;
}

.cg-master-items .cg-item-price-cell {
    color: #24465f;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.cg-master-items .cg-items-table td .btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
}

.cg-master-items .cg-items-results-card > .card-footer {
    padding: 12px 16px;
    border-top: 1px solid #e5edf2;
    background: #fbfdfe;
}

/* Create and edit */
.cg-items-form-page .cg-items-form-card {
    overflow: hidden;
}

.cg-items-form-page .cg-items-form-card > .card-header {
    padding: 17px 22px;
    border-bottom: 1px solid #e3ebf1;
    background: #f8fbfd;
}

.cg-items-card-heading {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cg-items-card-heading__icon,
.cg-item-form-section__icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid #d7e7f1;
    border-radius: 11px;
    background: #edf6fb;
    color: #27658b;
    font-size: 1.05rem;
}

.cg-items-card-heading h3 {
    margin: 0;
    color: #21445e;
    font-size: 1rem;
    font-weight: 700;
}

.cg-items-card-heading p {
    margin: 3px 0 0;
    color: var(--cg-item-muted);
    font-size: .8rem;
}

.cg-items-form-page .cg-items-form-card > .card-body {
    padding: 22px;
}

.cg-item-code-field {
    max-width: 420px;
    margin-bottom: 22px;
    padding: 14px 16px;
    border: 1px solid #e1e9ef;
    border-radius: 11px;
    background: #f8fbfd;
}

.cg-item-code-field .form-control {
    background: #eef3f6;
    color: #526b7e;
    font-variant-numeric: tabular-nums;
}

.cg-item-form-section {
    padding: 20px 0;
    border-top: 1px solid #e8eef2;
}

.cg-item-form-section:first-child {
    padding-top: 0;
    border-top: 0;
}

.cg-item-form-section:last-child {
    padding-bottom: 0;
}

.cg-item-form-section__heading {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 17px;
}

.cg-item-form-section__heading h3 {
    margin: 0;
    color: #24465f;
    font-size: .98rem;
    font-weight: 700;
}

.cg-item-form-section__heading p {
    margin: 3px 0 0;
    color: var(--cg-item-muted);
    font-size: .8rem;
}

.cg-items-form-page .form-label {
    margin-bottom: 6px;
    color: #294a63;
    font-size: .82rem;
    font-weight: 650;
}

.cg-items-form-page .form-control,
.cg-items-form-page .form-select {
    min-height: 44px;
    border-color: #d6e1e9;
    border-radius: 10px;
}

.cg-items-form-page textarea.form-control {
    min-height: 96px;
}

.cg-items-form-page .form-control:focus,
.cg-items-form-page .form-select:focus {
    border-color: #77a9c7;
    box-shadow: 0 0 0 .2rem rgba(46, 120, 164, .12);
}

.cg-items-form-page .form-text {
    color: #718395;
    font-size: .76rem;
    line-height: 1.45;
}

.cg-items-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid #e8eef2;
}

/* Item details */
.cg-item-detail-card {
    overflow: hidden;
}

.cg-item-detail-card > .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px;
    border-bottom: 1px solid #e3ebf1;
    background: linear-gradient(135deg, #f7fbfd 0%, #eef6fa 100%);
}

.cg-item-detail-identity {
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 0;
}

.cg-item-detail-icon {
    width: 52px;
    height: 52px;
    display: inline-flex;
    flex: 0 0 52px;
    align-items: center;
    justify-content: center;
    border: 1px solid #d7e7f1;
    border-radius: 15px;
    background: #fff;
    color: #27658b;
    font-size: 1.35rem;
}

.cg-item-detail-identity h3 {
    margin: 0;
    overflow-wrap: anywhere;
    color: #1d405a;
    font-size: 1.3rem;
    font-weight: 750;
}

.cg-item-detail-meta {
    margin-top: 4px;
    color: #627b8f;
    font-size: .84rem;
}

.cg-item-meta-separator {
    padding: 0 5px;
}

.cg-item-detail-status {
    flex: 0 0 auto;
}

.cg-item-detail-card > .card-body {
    padding: 22px;
}

.cg-item-detail-section {
    padding: 0 0 21px;
    margin-bottom: 21px;
    border-bottom: 1px solid #e8eef2;
}

.cg-item-detail-section h4 {
    margin: 0 0 15px;
    color: #294b64;
    font-size: .92rem;
    font-weight: 750;
}

.cg-item-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px 22px;
}

.cg-item-detail-grid--pricing {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cg-item-detail-field {
    min-width: 0;
}

.cg-item-detail-field > span {
    display: block;
    margin-bottom: 5px;
    color: #718497;
    font-size: .76rem;
    font-weight: 600;
}

.cg-item-detail-field > strong {
    display: block;
    overflow-wrap: anywhere;
    color: #263f54;
    font-size: .9rem;
    font-weight: 650;
}

.cg-item-detail-field .cg-item-price {
    color: #1d4f70;
    font-size: 1.02rem;
    font-variant-numeric: tabular-nums;
}

.cg-item-detail-section--last {
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: 0;
}

.cg-item-description {
    margin: 0;
    color: #526b7e;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Alternate UOM setup */
.cg-uom-item-name {
    margin-top: 8px;
    color: #284b65;
    font-size: .92rem;
    font-weight: 650;
}

.cg-uom-context-card {
    margin-bottom: 16px;
}

.cg-uom-context-card .card-body {
    padding: 16px 18px;
}

.cg-uom-context-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.cg-uom-context-grid > div > span {
    display: block;
    margin-bottom: 5px;
    color: #718497;
    font-size: .75rem;
    font-weight: 600;
}

.cg-uom-context-grid strong {
    color: #294b64;
    font-size: .86rem;
    font-weight: 650;
}

.cg-uom-explainer {
    display: flex;
    gap: 12px;
    padding: 15px 17px;
    margin-bottom: 20px;
    border: 1px solid #d7e8f2;
    border-radius: 12px;
    background: #f2f8fc;
    color: #3d5d73;
    font-size: .84rem;
    line-height: 1.5;
}

.cg-uom-explainer__icon {
    color: #28749c;
    font-size: 1.1rem;
}

.cg-uom-explainer p {
    margin: 4px 0 0;
}

.cg-uom-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 12px;
}

.cg-uom-section-head h3 {
    margin: 0;
    color: #24465f;
    font-size: 1.02rem;
    font-weight: 750;
}

.cg-uom-section-head p {
    margin: 4px 0 0;
    color: #718497;
    font-size: .8rem;
}

.cg-uom-mapping-card {
    border-radius: 13px;
}

.cg-uom-mapping-card > .card-body {
    padding: 18px;
}

.cg-uom-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 17px;
}

.cg-uom-row-head > div {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #294b64;
}

.cg-uom-row-number {
    width: 27px;
    height: 27px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #edf5fa;
    color: #2c6688;
    font-size: .78rem;
    font-weight: 750;
}

.cg-alternate-uom-page .form-label {
    color: #294a63;
    font-size: .8rem;
    font-weight: 650;
}

.cg-alternate-uom-page .form-control,
.cg-alternate-uom-page .form-select,
.cg-alternate-uom-page .input-group-text {
    min-height: 43px;
    border-color: #d6e1e9;
    border-radius: 9px;
}

.cg-alternate-uom-page .input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.cg-alternate-uom-page .input-group-text {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    background: #f4f8fa;
    color: #536d80;
    font-size: .8rem;
    font-weight: 650;
}

.cg-alternate-uom-page .form-text {
    color: #728598;
    font-size: .74rem;
    line-height: 1.4;
}

.cg-uom-conversion-preview {
    padding: 13px 15px;
    margin-top: 17px;
    border: 1px solid #d9e9df;
    border-radius: 11px;
    background: #f5faf7;
}

.cg-uom-preview-heading {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 7px;
    color: #416b54;
    font-size: .75rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .045em;
}

.cg-uom-preview-content {
    color: #536d60;
    font-size: .82rem;
}

.cg-uom-preview-main {
    color: #215c3b;
    font-size: 1.13rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.cg-uom-preview-main span {
    padding: 0 5px;
    color: #759281;
    font-weight: 500;
}

.cg-uom-preview-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 5px;
    color: #496a57;
    font-size: .78rem;
    font-variant-numeric: tabular-nums;
}

.cg-uom-preview-note {
    margin-top: 7px;
    color: #708579;
    font-size: .73rem;
    line-height: 1.45;
}

.cg-uom-permissions {
    padding-top: 15px;
    margin-top: 17px;
    border-top: 1px solid #e7edf1;
}

.cg-uom-permissions-heading {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 12px;
}

.cg-uom-permissions-heading strong {
    color: #294b64;
    font-size: .85rem;
}

.cg-uom-permissions-heading span {
    color: #718497;
    font-size: .76rem;
}

.cg-uom-permission,
.cg-uom-default-permission {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    color: #38566c;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}

.cg-uom-default-permission {
    min-height: 28px;
    padding-left: 25px;
    color: #718497;
    font-size: .73rem;
    font-weight: 500;
}

.cg-uom-permission .form-check-input,
.cg-uom-default-permission .form-check-input {
    flex: 0 0 auto;
    margin: 0;
}

.cg-alternate-uom-page [hidden] {
    display: none !important;
}

@media (max-width: 767.98px) {
    .cg-items-page .cg-items-page-head,
    .cg-master-items .cg-master-page-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .cg-master-items .cg-items-table { min-width: 0; }

    .cg-items-page-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .cg-items-page-actions .btn {
        flex: 1 1 auto;
    }

    .cg-items-form-page .cg-items-form-card > .card-body,
    .cg-item-detail-card > .card-body {
        padding: 16px;
    }

    .cg-items-form-page .cg-items-form-card > .card-header,
    .cg-item-detail-card > .card-header {
        padding: 16px;
    }

    .cg-item-detail-grid,
    .cg-item-detail-grid--pricing,
    .cg-uom-context-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 15px;
    }

    .cg-item-detail-identity h3 {
        font-size: 1.08rem;
    }

    .cg-uom-section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .cg-uom-section-head .btn {
        width: 100%;
    }

    .cg-uom-mapping-card > .card-body {
        padding: 14px;
    }
}

@media (max-width: 479.98px) {
    .cg-item-detail-grid,
    .cg-item-detail-grid--pricing,
    .cg-uom-context-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .cg-item-detail-card > .card-header {
        align-items: flex-start;
    }

    .cg-items-results-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .cg-items-form-actions .btn {
        flex: 1 1 auto;
    }
}
