body {
    font-family: Arial, sans-serif;
    margin: 0;
    /* display: flex; */ /* Removido para permitir layout de bloco normal */
    height: auto; /* Altura automática para conteúdo dinâmico */
    background-color: #f0f2f5;
    overflow-y: auto; /* Permite scroll vertical */
}

/* Main PDV Screen */
.main-pdv-screen {
    display: flex;
    flex-direction: column; /* Empilha os painéis */
    width: 100%;
    height: auto;
}

/* Finalize Order Screen (Initial State: Hidden) */
.finalize-order-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #f0f2f5; /* Fundo similar ao do corpo */
    display: none; /* Oculta por padrão */
    flex-direction: column;
    z-index: 1000; /* Garante que fique acima de tudo */
}

.finalize-header {
    background-color: #4CAF50; /* Verde do cabeçalho da imagem */
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2em;
    font-weight: bold;
}

.finalize-title-container {
    display: flex;
    flex-direction: column;
}

.finalize-header .finalize-title {
    font-size: 1.1em; /* Título diminuído */
    margin: 0;
}

.total-value-header {
    font-size: 0.9em;
    font-weight: normal;
    opacity: 0.9;
}

.finalize-header .header-buttons {
    display: flex;
    align-items: center;
}

.finalize-header .header-buttons button {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    margin-left: 10px;
    transition: background-color 0.3s ease;
}
.finalize-header .header-buttons button:hover {
    background-color: rgba(255, 255, 255, 0.4);
}
.finalize-header .header-buttons .back-button {
    background-color: #6a1b9a; /* Roxo para o botão voltar */
    padding: 8px 15px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.finalize-header .header-buttons .back-button:hover {
    background-color: #7b29ad;
}

.finalize-header .header-buttons .finalize-button {
    font-size: 1.3em;
    padding: 15px 30px;
    font-weight: bold;
    background-color: #0d47a1; /* Azul Escuro */
}

.finalize-header .header-buttons .finalize-button:hover {
    background-color: #0b3a82; /* Azul Escuro (Hover) */
}

.finalize-content {
    display: flex;
    flex-direction: column; /* Empilha painéis da finalização */
    flex-grow: 1;
    padding: 10px 5px; /* Reduz padding lateral */
    gap: 10px; /* Reduz gap */
}

.finalize-items-panel,
.finalize-payment-panel,
.finalize-details-panel {
    flex: none; /* Desativa flex-grow */
    width: 100%; /* Ocupa toda a largura */
    box-sizing: border-box; /* Garante que padding não estoure a largura */
    margin-bottom: 10px;
    height: auto; /* Altura automática */
    padding: 10px; /* Adiciona padding interno */
    border-radius: 8px; /* Bordas arredondadas */
    background-color: #fff; /* Fundo branco padrão */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* Sombra sutil */
}
.finalize-items-panel .panel-title {
    background-color: #fcf8e3; /* Cor de fundo */
    color: #4a4a4a;
    font-size: 1.2em;
    font-weight: bold;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid #f5c6cb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.toggle-items-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
}
#collapsible-items-content {
    display: none;
}
#collapsible-items-content.visible {
    display: block;
}
.items-table-header {
    display: grid;
    grid-template-columns: 2fr 0.5fr 0.8fr;
    font-weight: bold;
    padding-bottom: 5px;
    border-bottom: 1px solid #ddd;
}
.finalize-item-list {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 15px;
}
.finalize-item-row {
    display: grid;
    grid-template-columns: 2fr 0.5fr 0.8fr;
    padding: 8px 0;
    border-bottom: 1px dotted #e0e0e0;
}
.finalize-item-row:last-child {
    border-bottom: none;
}
.finalize-summary {
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
}
.summary-table {
    width: 100%;
    margin-bottom: 10px;
    background-color: #fcf8e3;
    padding: 10px;
    border-radius: 8px;
}
.summary-table td {
    padding: 8px;
    font-size: 1.1em;
}
.summary-table td:last-child {
    text-align: right;
    font-weight: bold;
}

.summary-table .total-label,
.summary-table .total-value {
    font-size: 1.4em;
    color: #0d47a1;
}

.finalize-payment-panel {
    padding-bottom: 0; /* Remove padding inferior para tirar espaço extra */
}
.finalize-payment-panel .payment-method-title {
    background-color: white;
    color: #4a4a4a;
    font-size: 1.2em;
    font-weight: bold;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.finalize-payment-panel .payment-methods {
    margin-bottom: 10px; /* Adiciona espaço após os botões */
}

.payment-methods {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Duas colunas para formas de pagamento */
    gap: 8px;
}

.payment-methods button {
    display: block;
    width: 100%;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    padding: 10px;
    margin-bottom: 5px;
    cursor: pointer;
    font-size: 1em;
    text-align: left;
    border-radius: 3px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.payment-methods button:hover {
    background-color: #e0e0e0;
}
.payment-methods button.selected {
    background-color: #6a1b9a; /* Roxo para selecionado */
    color: white;
    border-color: #6a1b9a;
}

.finalize-details-panel {
    flex: 1.5; /* Mais estreito */
    background-color: white;
    padding: 15px;
    display: flex;
    flex-direction: column;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.finalize-details-panel .panel-title {
    font-size: 1em;
    font-weight: bold;
    padding: 8px 0;
    margin-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.panel-section-top, .panel-section-middle, .panel-section-bottom {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #eee;
}
.panel-section-bottom {
    border-bottom: none;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Alinha os botões ao final */
}

.parcels-section, .observation-section, .discount-section, .received-section, .change-section {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 1.1em;
}
.parcels-section span, .observation-section span, .discount-section span, .received-section span, .change-section span {
    font-weight: bold;
    margin-right: 10px;
}

.parcel-options {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.quit-button {
    background-color: #e7e7e7;
    border: 1px solid #ccc;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
}
.obs-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 1em;
}

.discount-section input[type="number"] {
    width: 60px;
    text-align: center;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 3px;
    margin-right: 5px;
}
.discount-value {
    margin-left: auto; /* Empurra o valor para a direita */
    font-weight: bold;
    color: #f44336; /* Vermelho para desconto */
}

.received-section input[type="number"] {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 1.2em;
    font-weight: bold;
    text-align: right;
    color: #4CAF50;
}
.change-section {
    justify-content: space-between;
    font-size: 1.5em;
    color: #2196f3; /* Azul para troco */
}
#change-value {
    font-weight: bold;
}

.client-info {
    margin-top: 0;
    margin-bottom: 10px;
}
.client-info .input-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 48%; /* Para duas colunas */
}
.client-info .input-group.full-width {
    width: 100%;
    flex: none; /* Desativa o flex para ocupar 100% */
}
.client-info .input-label {
    font-size: 0.9em;
    color: #555;
    margin-bottom: 3px;
    font-weight: bold;
}
.client-info input {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 1.3em;
}

.action-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 15px;
    margin-top: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    color: white;
    transition: background-color 0.3s ease;
}
.action-button span {
    margin-right: 8px;
}
.nfc-e-button {
    background-color: #03a9f4; /* Azul claro */
}
.nfc-e-button:hover {
    background-color: #039be5;
}
.finalize-button {
    background-color: #4caf50;
    color: white;
}
.finalize-button:hover {
    background-color: #45a049;
}


/* --- Existing PDV Screen Styles (keep as is or adjust slightly) --- */

/* Painel Esquerdo - Produtos */
.left-panel {
    width: 100%; /* Ocupa toda a largura */
    background-color: #ffffff;
    border-right: none; /* Remove borda lateral */
    display: flex;
    flex-direction: column;
    padding: 0 15px 15px 15px; /* Ajusta padding */
    box-sizing: border-box;
    min-height: 50vh;
}

.panel-title-container {
    padding: 15px 0;
    margin: 0 -15px 15px -15px; /* Ajusta margem para cobrir o padding */
    background-color: #6a1b9a;
    text-align: center;
}

.panel-title {
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    margin: 0;
}

.product-search {
    display: flex;
    margin-bottom: 15px;
}

.product-search input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px 0 0 5px;
    font-size: 1em;
}

.product-search button {
    background-color: #6a1b9a; /* Cor similar ao da imagem */
    color: white;
    border: none;
    padding: 10px 15px;
    margin-left: 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

.product-search button.search {
    background-color: #6a1b9a;
}

.product-search button.search:hover {
    background-color: #7b29ad;
}


.product-search button.f8 {
    background-color: #4CAF50; /* Verde */
}
.product-search button.f8:hover {
    background-color: #45a049;
}

.product-search button.clear {
    display: none; /* Esconde o botão de limpar busca no mobile */
}
.product-search button.clear:hover {
    background-color: #d32f2f;
}

.product-list {
    flex-grow: 1;
    overflow-y: visible; /* Remove scroll interno, deixa a página rolar */
    padding-right: 0;
}

.product-item {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
}

.product-item .product-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Alinha topo para nomes longos */
    margin-bottom: 10px;
}

.product-item .product-name {
    font-weight: bold;
    font-size: 1.1em;
    color: #333;
    flex: 1; /* Permite que o nome ocupe espaço */
}

.product-item .product-price {
    font-size: 1.2em;
    color: #28a745; /* Verde para preços */
    font-weight: bold;
    margin-left: 15px; /* Espaço entre nome e preço */
    white-space: nowrap; /* Evita quebra de linha no preço */
}

.product-item .quantity-control {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Alinha os controles à direita */
}

.quantity-control button {
    background-color: #007bff; /* Azul */
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}
.quantity-control button:hover {
    background-color: #0056b3;
}

.quantity-control input {
    width: 40px; /* Reduzi um pouco */
    text-align: center;
    border: 1px solid #ccc;
    margin: 0 5px;
    padding: 5px;
    border-radius: 3px;
    font-size: 1em;
}

.product-item .add-button {
    background-color: #6a1b9a; /* Cor similar ao da imagem */
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    margin-left: 10px; /* Espaço entre quantidade e botão */
    transition: background-color 0.3s ease;
}

.product-item .add-button:hover {
    background-color: #7b29ad;
}

.loading-message {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 1.2em;
}

/* Painel Direito - Carrinho */
.right-panel {
    flex: none; /* Desativa flex-grow */
    width: 100%; /* Ocupa toda a largura */
    background-color: #fff;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    min-height: 40vh;
}

.cart-header {
    background-color: #007bff; /* Azul similar ao da imagem */
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2em;
    font-weight: bold;
}

.cart-header-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-header .setup-button {
    background: none;
    border: 2px solid white;
    color: white;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 1.2em;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.cart-header .setup-button:hover {
    background-color: white;
    color: #007bff;
}

.cart-header .evasor-button {
    background-color: #f44336; /* Vermelho */
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
}
.cart-header .evasor-button:hover {
    background-color: #d32f2f;
}

.cart-content {
    flex-grow: 1;
    display: flex;
    /* align-items: flex-start; */ /* Centraliza o 'Caixa Livre' */
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #d0d0d0; /* Cinza claro para o texto grande */
    font-size: 2em; /* Reduz um pouco o 'Caixa Livre' */
    text-align: center;
    overflow-y: auto; /* Para permitir scroll nos itens do carrinho */
    padding: 10px;
    padding-bottom: 120px; /* Espaço para o rodapé flutuante */
}

.cart-content .cart-icon {
    font-size: 2em; /* Tamanho do ícone do carrinho */
    margin-bottom: 10px;
}

.cart-items {
    width: 100%;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 10px;
    border-bottom: 1px solid #eee;
    background-color: #fff; /* Cor padrão (branco) */
}

.cart-item:nth-child(odd) {
    background-color: #F5F5DC; /* Cor bege para itens ímpares */
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.cart-item .item-details {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.cart-item .item-name {
    font-weight: bold;
    font-size: 1em; 
    color: #000;
    margin-bottom: 4px;
}

.cart-item .item-qty-price {
    white-space: nowrap;
    color: #555;
    font-size: 0.9em;
}

.cart-item .item-total {
    font-weight: bold;
    color: #0d47a1;
    font-size: 1.1em;
    margin-top: 4px;
}

.cart-item .remove-item {
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    font-size: 0.8em;
    cursor: pointer;
    margin-left: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
}
.cart-item .remove-item:hover {
    background-color: #d32f2f;
}


.cart-footer {
    background-color: #28a745; /* Verde similar ao da imagem */
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2em; /* Ajusta a fonte */
    font-weight: bold;
    position: fixed;   /* FIXO na tela */
    bottom: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box; /* Garante que o padding não aumente a largura */
    z-index: 999;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
}

.cart-footer .total-label {
    display: none; /* Oculta o texto "Total:" */
}

.cart-footer .total-value {
    font-size: 1.3em;
}

.cart-footer .f2-button {
    background-color: #6a1b9a; /* Cor similar ao da imagem */
    color: white;
    border: none;
    border-radius: 50%; /* Botão redondo */
    width: 55px;
    height: 55px;
    cursor: pointer;
    font-size: 1.8em; /* Ýcone maior */
    margin-left: 10px; /* Espaço para o botão */
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sync-button-container {
    margin-bottom: 20px;
    text-align: center;
}

.sync-data-button {
    background-color: #ff9800; /* Laranja para destaque */
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background-color 0.3s ease;
    width: 100%; /* Ocupa a largura total */
}

.sync-data-button:hover {
    background-color: #fb8c00;
}

/* Mensagens de feedback (Movido para o final do body no HTML) */
.feedback-message {
    position: fixed;
    bottom: 90px; /* Aumentado para não sobrepor os rodapés flutuantes */
    left: 10px;   /* Alinhado à esquerda com uma pequena margem */
    transform: none; /* Remove a centralização */
    background-color: #fcf8e3; /* Fundo amarelo claro */
    color: #8a6d3b; /* Cor do texto para contraste */
    border: 1px solid #faebcc; /* Borda sutil */
    padding: 10px 20px;
    border-radius: 5px;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    z-index: 1000;
    min-width: 250px;
    text-align: left; /* Alinha o texto à esquerda */
}

.feedback-message.show {
    opacity: 1;
}

.feedback-message.success {
    background-color: #ebedb9;
}

.feedback-message.error {
    background-color: #040150;
}

.feedback-message.error {
    background-color: #dc3545;
}

.feedback-message.info {
    background-color: #17a2b8;
}

.login-error-message {
    color: #dc3545;
    margin-bottom: 10px;
    font-weight: bold;
}

/* LÓGICA DE EXIBIÇÃO E BOTÕES MOBILE */
.show-cart-mobile {
    display: inline-flex; /* Torna o botão do carrinho visível */
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    font-size: 2.0em; /* Ýcone grande */
}

.back-button-mobile {
    display: inline-flex; /* Torna o botão de voltar visível */
     align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 12px;
    background-color: #6a1b9a; /* Cor do botão de setup */
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.9em;
}

/* Por padrão, o painel do carrinho (direito) é oculto */
.main-pdv-screen .right-panel {
    display: none;
}
.main-pdv-screen .left-panel {
    display: flex; /* Garante que o painel de produtos seja flex */
}

/* Quando a classe .cart-view é adicionada, inverte a visualização */
.main-pdv-screen.cart-view .right-panel {
    display: flex; /* Garante que o painel do carrinho seja flex */
}
.main-pdv-screen.cart-view .left-panel {
    display: none;
}

/* --- Finalize Footer --- */
.finalize-footer {
    position: fixed; /* Fixo para sempre ficar na base */
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    background-color: #f0f2f5;
    border-top: 1px solid #ddd;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.05);
    display: flex;
    justify-content: center; /* Centraliza o botão */
    box-sizing: border-box;
    z-index: 1001; /* Garante que fique acima do conteúdo */
}

.finalize-footer .finalize-button {
    background-color: #6a1b9a; /* Cor roxa */
    padding: 15px;
    font-size: 1.2em;
    width: 100%; /* Ocupa toda a largura */
}
.finalize-footer .finalize-button:hover {
    background-color: #7b29ad;
}

.form-row, .form-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Layout de 2 colunas */
    gap: 10px;
    margin-bottom: 10px; /* Adiciona espaço entre as grades */
}
.form-row {
    grid-template-columns: 1fr; /* Garante que form-row seja sempre coluna única */
}

.form-group.select-group,
.form-group.checkbox-group {
    background-color: #e3f2fd; /* Azul claro */
}

.form-group.vertical-group:nth-child(1) {
    background-color: #e8f5e9; /* Verde claro */
}
.form-group.vertical-group:nth-child(2) {
    background-color: #fff3e0; /* Laranja claro */
}
.form-group.vertical-group:nth-child(3) {
    background-color: #fce4ec; /* Rosa claro */
}
.form-group.vertical-group:nth-child(4) {
    background-color: #fffde7; /* Amarelo Pastel */
}

.form-group {
    padding: 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.form-group.checkbox-group {
    flex-direction: row;
    align-items: center;
}

.full-width-group {
    grid-column: 1 / -1; /* Ocupa as 2 colunas */
}

.payment-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Remove o estilo de "quadrado" do Quitar quando ele está no cabeçalho */
.payment-actions .form-group.checkbox-group {
    padding: 0;
    background-color: transparent;
    box-shadow: none;
}

.form-row-grid .form-group {
    min-height: 80px; /* Garante que todos os quadrados tenham a mesma altura */
}