:root {
    --sidebar-width: 260px;
    --primary-color: #0d6efd;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f4f6f9;
}

/* Login */
.login-page {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 50%, #084298 100%);
}

.login-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto;
    background: #e7f1ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--primary-color);
}

/* Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: #1e293b;
    color: #e2e8f0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1050;
    transition: transform 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

.sidebar-master {
    background: #111827;
}

.sidebar-brand {
    padding: 1.25rem 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: #60a5fa;
}

.sidebar-empresa {
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 0.85rem;
}

.sidebar-nav {
    padding: 0.75rem 0;
}

.sidebar-section {
    padding: 0.75rem 1rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.sidebar-link.active {
    background: rgba(13, 110, 253, 0.2);
    color: #60a5fa;
    border-right: 3px solid #60a5fa;
}

.sidebar-link.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.sidebar-link i {
    font-size: 1.1rem;
    width: 1.25rem;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-navbar {
    min-height: 56px;
}

.navbar-plano {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    border: 1px solid transparent;
    max-width: min(100%, 320px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-plano:hover {
    opacity: 0.92;
    text-decoration: none;
}

.navbar-plano-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-plano-nome {
    font-weight: 700;
}

.navbar-plano-meta {
    font-weight: 500;
    opacity: 0.9;
}

.navbar-plano-ok {
    background: rgba(25, 135, 84, 0.1);
    color: #146c43;
    border-color: rgba(25, 135, 84, 0.2);
}

.navbar-plano-alert {
    background: rgba(255, 193, 7, 0.15);
    color: #997404;
    border-color: rgba(255, 193, 7, 0.35);
}

.navbar-plano-warning {
    background: rgba(220, 53, 69, 0.1);
    color: #b02a37;
    border-color: rgba(220, 53, 69, 0.25);
}

@media (max-width: 575.98px) {
    .navbar-plano {
        font-size: 0.72rem;
        padding: 0.3rem 0.5rem;
        max-width: 160px;
    }
}

.app-content {
    flex: 1;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
    pointer-events: none;
}

.sidebar-overlay.show {
    display: block;
    pointer-events: auto;
}

body.sidebar-open {
    overflow: hidden;
}

/* Cards */
.stat-card {
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.chart-card .card-header {
    padding-top: 1rem;
    padding-bottom: 0.75rem;
}

.chart-card .chart-wrap {
    position: relative;
    height: 280px;
}

.chart-card .chart-wrap-sm {
    height: 240px;
}

.chart-card .chart-empty {
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .app-main {
        margin-left: 0;
    }
}

@media (max-width: 575.98px) {
    .app-content {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .stat-card h2 {
        font-size: 1.5rem;
    }
}

input.mask-cep.is-loading {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cstyle%3E.spinner%7Banimation:rotate 1s linear infinite;transform-origin:center%7D@keyframes rotate%7Bto%7Btransform:rotate(360deg)%7D%7D%3C/style%3E%3Ccircle class='spinner' cx='12' cy='12' r='10' fill='none' stroke='%230d6efd' stroke-width='3' stroke-dasharray='31.4 31.4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 1rem;
    padding-right: 2rem;
}

.produto-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
}

.produto-foto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.produto-foto-card {
    border: 1px solid #dee2e6;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.produto-foto-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: #f8f9fa;
}

.produto-foto-card.is-principal {
    border-color: #0d6efd;
    box-shadow: 0 0 0 1px #0d6efd;
}

.produto-foto-actions {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lista-busca-resultado {
    position: relative;
    min-height: 120px;
    transition: opacity 0.15s ease;
}

.lista-busca-resultado.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

.busca-spinner {
    position: absolute;
    top: 50%;
    right: 3.25rem;
    transform: translateY(-50%);
    z-index: 2;
}

/* PDV */
.pdv-body {
    background: #eef2f7;
    min-height: 100vh;
}

.pdv-header {
    position: sticky;
    top: 0;
    z-index: 100;
}

.pdv-main {
    min-height: calc(100vh - 60px);
}

.pdv-grid {
    min-height: calc(100vh - 100px);
}

.pdv-search-card,
.pdv-cart-card {
    min-height: 520px;
}

.pdv-resultados {
    max-height: 420px;
    overflow-y: auto;
}

.pdv-produto-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    padding: 0.65rem;
    margin-bottom: 0.5rem;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.pdv-produto-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.12);
}

.pdv-produto-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 0.35rem;
    background: #f8f9fa;
}

.pdv-dropdown-resultados {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
    max-height: 220px;
    overflow-y: auto;
}

.pdv-cliente-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 0.5rem 0.75rem;
}

.pdv-cliente-item:hover {
    background: #f8f9fa;
}

#pdvCarrinhoTabela input.pdv-qtd {
    min-width: 70px;
}

.pdv-desconto-tipo-select {
    max-width: 4.25rem;
    flex: 0 0 auto;
    padding-left: 0.5rem;
    padding-right: 1.75rem;
    font-size: 0.875rem;
}

.pdv-item-desconto-group .pdv-desconto-tipo-select {
    max-width: 3.5rem;
    font-size: 0.8rem;
    padding-right: 1.5rem;
}

.pdv-item-desconto-group .pdv-desconto-input {
    min-width: 0;
    font-size: 0.8rem;
}

.relatorio-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.relatorio-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1) !important;
}

@media print {
    .app-sidebar,
    .app-navbar,
    .sidebar-overlay,
    .no-print,
    .pagination {
        display: none !important;
    }

    .app-main {
        margin: 0 !important;
        width: 100% !important;
    }

    .app-content {
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }

    body {
        background: #fff !important;
    }
}

/* Leitor QR — câmera (Contas a Receber) */
.qr-reader-wrap {
    width: 100%;
    min-height: 280px;
    overflow: hidden;
    border-radius: 8px;
    background: #111;
}

.qr-reader-wrap video {
    border-radius: 8px;
}

.qr-reader-wrap #qr-shaded-region {
    border-radius: 8px;
}

.loja-destaque-admin-img-wrap {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    overflow: hidden;
}

.loja-destaque-admin-img-wrap.loja-destaque-admin-preview {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.loja-destaque-admin-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

@media (max-width: 575.98px) {
    .qr-reader-wrap {
        min-height: min(70vw, 320px);
    }
}
