.catalog-hero {
    align-items: center;
    background: linear-gradient(135deg, #ffffff 0%, var(--accent-soft) 100%);
    border: 1px solid var(--border-focus);
    border-radius: 18px;
    padding: 22px;
    box-shadow: var(--shadow-card);
}

.services-hero {
    background: linear-gradient(135deg, #ffffff 0%, var(--warning-soft) 100%);
    border-color: rgba(245, 158, 11, 0.28);
}

.catalog-hero .page-header-info h2 {
    font-size: 2rem;
    margin-bottom: 4px;
}

.catalog-hero-action {
    height: 46px;
    border-radius: 12px;
    box-shadow: 0 18px 30px -18px rgba(37, 99, 235, 0.85);
}

.catalog-toolbar {
    display: flex;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 22px;
}

.catalog-search {
    flex: 2;
    position: relative;
    min-width: 260px;
}

.catalog-search i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 1.15rem;
    z-index: 1;
}

.catalog-search .form-control {
    height: 52px;
    padding-left: 46px;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.catalog-select {
    min-width: 220px;
}

.catalog-select .form-control {
    height: 52px;
    border-radius: 14px;
}

.catalog-toolbar-stats {
    display: flex;
    gap: 10px;
}

.catalog-stat {
    min-width: 108px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: var(--shadow-sm);
}

.catalog-stat span {
    display: block;
    color: var(--text-tertiary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.catalog-stat strong {
    color: var(--primary);
    font-size: 1.25rem;
    line-height: 1.1;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.catalog-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow-card);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.catalog-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent);
}

.service-card::before {
    background: var(--warning);
}

.catalog-card.is-inactive {
    opacity: 0.72;
    background: #f8fafc;
}

.catalog-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-focus);
    box-shadow: 0 28px 60px -42px rgba(15, 23, 42, 0.65);
}

.catalog-card-header {
    display: flex;
    gap: 14px;
    margin-bottom: 16px;
    min-width: 0;
}

.product-media {
    width: 62px;
    height: 62px;
    border-radius: 14px;
    border: 1px solid var(--border-light);
    background: var(--bg-gray);
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.55rem;
    flex-shrink: 0;
    overflow: hidden;
}

.product-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-placeholder-icon {
    display: none;
}

.product-media.no-image,
.product-media.image-error {
    background: linear-gradient(145deg, #eff6ff, #eef2ff);
    border-color: #dbeafe;
    color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.product-media.no-image .product-placeholder-icon,
.product-media.image-error .product-placeholder-icon {
    display: block;
    font-size: 1.75rem;
}

.service-media {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.24);
}

.catalog-title-wrap {
    flex: 1;
    min-width: 0;
}

.catalog-code {
    color: var(--text-tertiary);
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.catalog-title {
    color: var(--primary);
    font-size: 1rem;
    font-weight: 850;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.catalog-badges {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.catalog-badge {
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: var(--bg-gray);
    color: var(--text-secondary);
    padding: 5px 9px;
    font-size: 0.74rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.catalog-badge.active {
    background: var(--success-soft);
    color: var(--success);
    border-color: rgba(22, 163, 74, 0.22);
}

.catalog-badge.inactive,
.catalog-badge.out {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.22);
}

.catalog-badge.low {
    background: var(--warning-soft);
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.28);
}

.catalog-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.catalog-info {
    min-width: 0;
    background: var(--bg-gray);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 10px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 7px;
}

.catalog-info span {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.catalog-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 14px;
    border-top: 1px solid var(--border-light);
    padding-top: 14px;
}

.catalog-price-label {
    color: var(--text-tertiary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.catalog-price {
    color: var(--accent);
    font-size: 1.35rem;
    font-weight: 850;
    line-height: 1.05;
}

.service-card .catalog-price {
    color: var(--warning);
}

.catalog-cost {
    color: var(--text-tertiary);
    font-size: 0.78rem;
    margin-top: 5px;
}

.catalog-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.catalog-actions .btn {
    padding: 9px 12px;
    font-size: 0.86rem;
}

.catalog-icon-action {
    width: 38px;
    min-width: 38px;
    padding: 0;
}

.catalog-list {
    min-width: 0;
}

.products-table-shell {
    overflow: hidden;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    box-shadow: var(--shadow-card);
}

.services-table-shell {
    overflow: hidden;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    box-shadow: var(--shadow-card);
}

.products-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.services-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.products-table th {
    padding: 12px 10px;
    background: var(--bg-gray);
    color: var(--text-tertiary);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-light);
}

.services-table th {
    padding: 12px 10px;
    background: var(--bg-gray);
    color: var(--text-tertiary);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-light);
}

.services-table th:nth-child(1) { width: 8%; }
.services-table th:nth-child(2) { width: 28%; }
.services-table th:nth-child(3) { width: 14%; }
.services-table th:nth-child(4) { width: 14%; }
.services-table th:nth-child(5) { width: 12%; }
.services-table th:nth-child(6) { width: 24%; }

.products-table th:nth-child(1) { width: 5%; }
.products-table th:nth-child(2) { width: 7%; }
.products-table th:nth-child(3) { width: 15%; }
.products-table th:nth-child(4) { width: 11%; }
.products-table th:nth-child(5) { width: 5%; }
.products-table th:nth-child(6) { width: 9%; }
.products-table th:nth-child(7) { width: 8%; }
.products-table th:nth-child(8) { width: 8%; }
.products-table th:nth-child(9) { width: 8%; }
.products-table th:nth-child(10) { width: 7%; }
.products-table th:nth-child(11) { width: 17%; }

.product-row {
    transition: background 0.18s ease;
}

.product-row:hover {
    background: #f8fafc;
}

.product-row + .product-row {
    border-top: 1px solid var(--border-light);
}

.product-row.is-inactive {
    opacity: 0.72;
    background: #f8fafc;
}

.service-row {
    transition: background 0.18s ease;
}

.service-row:hover {
    background: #f8fafc;
}

.service-row + .service-row {
    border-top: 1px solid var(--border-light);
}

.product-cell {
    padding: 9px 10px;
    color: var(--text-secondary);
    font-size: 0.76rem;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.service-cell {
    padding: 9px 10px;
    color: var(--text-secondary);
    font-size: 0.76rem;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.service-icon-cell,
.service-actions-cell {
    overflow: visible;
}

.product-image-cell,
.product-actions-cell {
    overflow: visible;
}

.product-media-sm {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 1.05rem;
}

.product-media-sm.no-image .product-placeholder-icon,
.product-media-sm.image-error .product-placeholder-icon {
    font-size: 1.15rem;
}

.product-name-link {
    display: block;
    max-width: 100%;
    border: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font: inherit;
    font-weight: 850;
    padding: 0;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-name-stack {
    min-width: 0;
}

.product-name-link:hover,
.product-details-link:hover {
    color: var(--accent);
}

.product-details-link {
    display: block;
    border: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 750;
    padding: 2px 0 0;
    text-align: left;
}

.product-price-cell {
    color: var(--accent);
    font-weight: 850;
}

.product-table-actions {
    flex-wrap: nowrap;
    gap: 5px;
}

.product-table-actions .btn {
    min-height: 32px;
    border-radius: 9px;
    padding: 7px 8px;
    font-size: 0.7rem;
}

.product-table-actions .catalog-icon-action {
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
}

.product-action-budget {
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
    flex: 0 0 auto;
}

.product-table-actions .btn-primary {
    background: var(--accent);
}

.product-table-actions .btn-primary:hover {
    background: var(--accent-hover);
}

.product-details-modal {
    max-width: 840px;
}

.product-detail-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-light);
}

.product-detail-media {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--bg-gray);
    color: var(--accent);
    font-size: 1.8rem;
}

.product-detail-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-detail-head h4 {
    margin: 0 0 5px;
    color: var(--primary);
    font-size: 1rem;
}

.product-detail-head span {
    color: var(--text-tertiary);
    font-size: 0.78rem;
    font-weight: 750;
}

.product-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.product-detail-item {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-gray);
}

.product-detail-item.span-2 {
    grid-column: span 2;
}

.product-detail-item span {
    display: block;
    margin-bottom: 5px;
    color: var(--text-tertiary);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.product-detail-item strong {
    display: block;
    color: var(--primary);
    font-size: 0.86rem;
    overflow-wrap: anywhere;
}

.product-detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

@media (max-width: 768px) {
    #produtos,
    #servicos {
        padding-bottom: 86px;
    }

    .catalog-hero {
        padding: 18px;
    }

    .catalog-hero-action {
        position: fixed;
        right: 18px;
        bottom: calc(100px + env(safe-area-inset-bottom, 0px));
        z-index: 1260;
        width: 52px;
        min-width: 52px;
        height: 52px;
        min-height: 52px;
        overflow: hidden;
        padding: 0;
        border: 0;
        border-radius: 16px;
        color: #fff;
        font-size: 0;
        background: linear-gradient(135deg, #2563eb, #0ea5e9);
        box-shadow: 0 22px 45px -22px rgba(37, 99, 235, .85), 0 1px 0 rgba(255, 255, 255, .34) inset;
        transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
    }

    .services-hero .catalog-hero-action {
        background: linear-gradient(135deg, #16a34a, #22c55e);
        box-shadow: 0 22px 45px -22px rgba(22, 163, 74, .85), 0 1px 0 rgba(255, 255, 255, .34) inset;
    }

    .catalog-hero-action::before {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(135deg, rgba(255, 255, 255, .26), rgba(255, 255, 255, 0) 58%);
        pointer-events: none;
    }

    .catalog-hero-action:active {
        transform: translateY(1px) scale(.96);
        box-shadow: 0 14px 28px -20px rgba(37, 99, 235, .9), 0 1px 0 rgba(255, 255, 255, .24) inset;
        filter: saturate(1.08);
    }

    .services-hero .catalog-hero-action:active {
        box-shadow: 0 14px 28px -20px rgba(22, 163, 74, .9), 0 1px 0 rgba(255, 255, 255, .24) inset;
    }

    .catalog-hero-action i {
        position: relative;
        z-index: 1;
        margin: 0;
        color: #fff;
        font-size: 1.32rem;
        line-height: 1;
    }

    .catalog-toolbar {
        flex-direction: column;
    }

    .catalog-select {
        min-width: 0;
    }

    .catalog-toolbar-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .catalog-grid {
        grid-template-columns: 1fr;
    }

    .products-table-shell,
    .services-table-shell {
        overflow: hidden;
        border: 1px solid var(--border-light);
        border-radius: 14px;
        background: var(--bg-white);
        box-shadow: var(--shadow-sm);
    }

    .products-table,
    .products-table tbody,
    .products-table tr,
    .products-table td {
        display: block;
        width: 100%;
    }

    .services-table,
    .services-table tbody,
    .services-table tr,
    .services-table td {
        display: block;
        width: 100%;
    }

    .products-table thead {
        display: none;
    }

    .services-table thead {
        display: none;
    }

    .product-row,
    .service-row {
        display: grid !important;
        grid-template-columns: 42px minmax(0, 1fr) auto;
        gap: 3px 10px;
        margin-bottom: 0;
        padding: 12px;
        background: var(--bg-white);
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .service-row + .service-row {
        border-top: 1px solid var(--border-light);
    }

    .product-row + .product-row {
        border-top: 1px solid var(--border-light);
    }

    .product-cell {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 6px;
        min-width: 0;
        padding: 0;
        white-space: normal;
        border: 0;
        color: var(--text-secondary);
        font-size: 0.78rem;
        overflow-wrap: anywhere;
        width: auto;
        max-width: 100%;
    }

    .service-cell {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 6px;
        min-width: 0;
        padding: 0;
        white-space: normal;
        border: 0;
        color: var(--text-secondary);
        font-size: 0.78rem;
        overflow-wrap: anywhere;
        width: auto;
        max-width: 100%;
    }

    .product-cell::before {
        content: attr(data-label);
        color: var(--text-tertiary);
        font-size: 0.66rem;
        font-weight: 850;
        letter-spacing: 0.02em;
        text-transform: uppercase;
        flex: 0 0 auto;
    }

    .service-cell::before {
        content: attr(data-label);
        color: var(--text-tertiary);
        font-size: 0.66rem;
        font-weight: 850;
        letter-spacing: 0.02em;
        text-transform: uppercase;
        flex: 0 0 auto;
    }

    .product-image-cell::before,
    .product-actions-cell::before {
        display: none;
    }

    .service-icon-cell::before,
    .service-actions-cell::before {
        display: none;
    }

    .product-image-cell {
        grid-column: 1;
        grid-row: 1 / span 6;
        align-self: start;
        padding: 0;
        border-bottom: 0;
    }

    .service-icon-cell {
        grid-column: 1;
        grid-row: 1 / span 3;
        align-self: start;
        padding: 0;
        border-bottom: 0;
    }

    .product-name-cell,
    .service-name-cell {
        grid-column: 2;
        grid-row: 1;
        padding: 0 0 3px;
    }

    .product-name-cell::before,
    .service-name-cell::before {
        display: none;
    }

    .product-name-link {
        max-width: 100%;
        font-size: .86rem;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .product-details-link {
        margin-top: 2px;
        font-size: .68rem;
    }

    .product-media-sm {
        width: 36px;
        height: 36px;
        border-radius: 12px;
        font-size: .95rem;
    }

    .product-cell[data-label="Código"],
    .product-cell[data-label="Categoria"],
    .product-cell[data-label="Estoque"],
    .product-cell[data-label="Venda"],
    .product-cell[data-label="Status"],
    .service-cell[data-label="Unidade"],
    .service-cell[data-label="Valor"],
    .service-cell[data-label="Status"] {
        grid-column: 2;
    }

    .product-cell[data-label="Código"] { grid-row: 2; }
    .product-cell[data-label="Categoria"] { grid-row: 3; }
    .product-cell[data-label="Estoque"] { grid-row: 4; }
    .product-cell[data-label="Venda"] { grid-row: 5; }
    .product-cell[data-label="Status"] { grid-row: 6; }
    .service-cell[data-label="Unidade"] { grid-row: 2; }
    .service-cell[data-label="Valor"] { grid-row: 3; }
    .service-cell[data-label="Status"] { grid-row: 4; }

    .product-cell[data-label="Unidade"],
    .product-cell[data-label="Custo"],
    .product-cell[data-label="Margem"] {
        display: none;
    }

    .product-cell[data-label="Status"],
    .service-cell[data-label="Status"] {
        align-items: flex-start;
    }

    .product-actions-cell {
        grid-column: 3;
        grid-row: 1 / span 6;
        align-self: center;
        padding: 0;
        border-top: 0;
        margin-top: 0;
        width: auto;
    }

    .service-actions-cell {
        grid-column: 3;
        grid-row: 1 / span 4;
        align-self: center;
        padding: 0;
        border-top: 0;
        margin-top: 0;
        width: auto;
    }

    .product-table-actions {
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .catalog-info-grid {
        grid-template-columns: 1fr;
    }

    .catalog-bottom {
        align-items: stretch;
        flex-direction: column;
    }

    .catalog-actions {
        display: grid;
        grid-template-columns: 1fr 38px 38px;
        justify-content: stretch;
    }

    .product-table-actions {
        display: flex;
    }

    .product-action-budget,
    .product-table-actions .catalog-icon-action {
        width: 34px;
        height: 34px;
        min-width: 34px;
        padding: 0;
        border-radius: 10px;
    }

    .product-action-budget {
        flex: 0 0 34px;
    }

    .product-detail-grid {
        grid-template-columns: 1fr;
    }

    .product-detail-item.span-2 {
        grid-column: span 1;
    }

    .product-detail-actions {
        flex-direction: column;
    }
}
