: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: #60a5fa;
}

/* 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: auto;
}

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

.pdv-catalog-card .catalogo-tab-content {
    max-height: calc(100vh - 320px);
    overflow-y: auto;
}

.pdv-body .catalogo-produto-btn {
    height: 100%;
}

.pdv-resultados {
    max-height: 220px;
    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;
}

/* Restaurante — mesas, garçom, KDS */
.mesas-grid .mesa-card {
    display: block;
    border-radius: 12px;
    border: 2px solid transparent;
    text-decoration: none;
    color: inherit;
    min-height: 110px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mesa-card-btn { cursor: pointer; }

.mesa-icon-livre { color: #198754; }
.mesa-icon-ocupada { color: #dc3545; }
.mesa-icon-conta { color: #ffc107; }
.mesa-icon-reservada { color: #0dcaf0; }

.mesa-status-icon { font-size: 2.5rem; line-height: 1; display: block; margin-bottom: 0.25rem; }

.mesa-numero {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
}

.mesa-card-admin {
    background: #fff;
    transition: box-shadow 0.15s ease;
}

.mesa-card-admin:hover { box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,.08) !important; }

.mesa-legenda span { white-space: nowrap; }

.catalogo-tabs { scrollbar-width: thin; }

.catalogo-produto-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    background: #f8f9fa;
}

.catalogo-produto-btn {
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.catalogo-produto-btn:active {
    transform: scale(0.98);
}

.catalogo-modal-img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    flex-shrink: 0;
}

.catalogo-qty-control {
    max-width: 200px;
}

.catalogo-qty-control .form-control {
    font-weight: 600;
    font-size: 1.1rem;
}

.catalogo-qty-control .btn {
    min-width: 44px;
}

.cliente-mesa-body .catalogo-produto-btn,
.garcom-body .catalogo-produto-btn {
    min-height: 120px;
}

.mesa-cliente-bloqueado {
    opacity: 0.45;
    pointer-events: none;
    user-select: none;
}

.catalogo-app[data-carrinho="1"] .catalogo-tab-content {
    padding-bottom: 5.5rem;
}

.catalogo-carrinho {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 56px;
    z-index: 1040;
    background: #fff;
    border-top: 2px solid var(--bs-primary);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
}

body:not(.garcom-body) .catalogo-carrinho {
    bottom: 0;
    position: sticky;
    z-index: 10;
    margin-top: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
}

.catalogo-carrinho-toggle {
    color: inherit;
    padding: 0.65rem 1rem;
    font-weight: 600;
}

.catalogo-carrinho-body {
    padding: 0 1rem 0.75rem;
    max-height: 40vh;
    overflow-y: auto;
}

.catalogo-carrinho.is-collapsed .catalogo-carrinho-body {
    display: none;
}

.catalogo-carrinho.is-collapsed .catalogo-carrinho-chevron {
    transform: rotate(180deg);
}

.catalogo-carrinho-lista li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.875rem;
}

.catalogo-carrinho-lista li:last-child {
    border-bottom: none;
}

.catalogo-carrinho-item-meta {
    color: #6c757d;
    font-size: 0.75rem;
}

.catalogo-carrinho-remove {
    color: #dc3545;
    padding: 0;
    line-height: 1;
}

.pdv-modo-links .btn { min-width: 100px; }

.garcom-body { padding-bottom: 70px; }
.garcom-main { min-height: calc(100vh - 120px); }

.garcom-bottom-nav {
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    z-index: 1030;
}

.garcom-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.7rem;
    color: #6c757d;
    text-decoration: none;
    padding: 0.25rem 1rem;
}

.garcom-bottom-nav a.active,
.garcom-bottom-nav a:hover {
    color: var(--bs-primary);
}

.garcom-bottom-nav i { font-size: 1.25rem; }

.kds-body { min-height: 100vh; }
.kds-card { background: #212529; border-color: #495057 !important; }
.kds-card.status-pendente { border-left: 4px solid #ffc107 !important; }
.kds-card.status-preparando { border-left: 4px solid #fd7e14 !important; }
.kds-card.status-pronto { border-left: 4px solid #198754 !important; }

.pdv-modo-links .btn { min-width: 100px; }

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

.delivery-timeline-list {
    position: relative;
    padding-left: 0;
}

.delivery-timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
    position: relative;
    color: #adb5bd;
}

.delivery-timeline-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 0.95rem;
    top: 2rem;
    bottom: -0.25rem;
    width: 2px;
    background: #dee2e6;
}

.delivery-timeline-item.is-done:not(:last-child)::before {
    background: #198754;
}

.delivery-timeline-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #e9ecef;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 1;
}

.delivery-timeline-item.is-done .delivery-timeline-icon {
    background: #d1e7dd;
    color: #198754;
}

.delivery-timeline-item.is-active .delivery-timeline-icon {
    background: #0d6efd;
    color: #fff;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}

.delivery-timeline-item.is-active .delivery-timeline-label {
    font-weight: 600;
    color: #212529;
}

.delivery-timeline-item.is-done .delivery-timeline-label {
    color: #198754;
}

.delivery-timeline.is-rejeitado .delivery-timeline-item {
    opacity: 0.5;
}

.navbar-notificacoes-lista {
    max-height: 360px;
    overflow-y: auto;
}

.navbar-notificacao-item {
    display: block;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid #f1f3f5;
    text-decoration: none;
    color: inherit;
}

.navbar-notificacao-item:hover {
    background: #f8f9fa;
}

.navbar-notificacao-item.is-lida {
    opacity: 0.65;
}

.navbar-notificacao-item:not(.is-lida) {
    background: #fff8e6;
}

