* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --lad-orange-500: #f24405;
    --lad-orange-400: #f25c05;
    --lad-orange-300: #f27405;
    --lad-blue-900: #190e88;
    --lad-yellow-400: #ffde59;
    --lad-white: #f3f4f4;
    --lad-white-pure: #ffffff;
    --lad-gray-100: #e8e9e9;
    --lad-gray-300: #cccccc;
    --lad-gray-600: #6b6b6b;
    --lad-dark: #1a1a2e;
    --lad-success: #2ecc71;
    --lad-error: #f24405;
}

html, body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--lad-white);
    color: var(--lad-dark);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.font-mono {
    font-family: 'Roboto Mono', monospace;
}

.hidden {
    display: none !important;
}

/* ===========================
   Telas base
   =========================== */
.tela {
    min-height: 100vh;
}

.tela-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tela-estado {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===========================
   Tela 1: Loading
   =========================== */
.loading-container {
    text-align: center;
    padding: 2rem;
}

.loading-logo {
    width: 200px;
    height: auto;
    object-fit: contain;
    margin: 0 auto 2.5rem;
    display: block;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(242, 68, 5, 0.2);
    border-top-color: var(--lad-orange-500);
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    animation: spin 0.8s linear infinite;
    position: relative;
}

.spinner::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--lad-orange-500);
    border-radius: 50%;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--lad-blue-900);
    font-size: 16px;
    font-weight: 500;
}

/* ===========================
   Tela 2: Conta / Recibo
   =========================== */
#tela-conta {
    position: relative;
    padding-bottom: 80px;
}

/* Header azul */
.conta-header {
    background-color: var(--lad-blue-900);
    color: #fff;
    padding: 48px 24px 24px;
    border-radius: 0 0 24px 24px;
    position: relative;
    z-index: 10;
}

.conta-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.conta-header-label {
    font-size: 12px;
    font-weight: 300;
    opacity: 0.9;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.conta-header-nome {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 4px;
}

.mesa-badge {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(8px);
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.conta-header-data {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    font-size: 12px;
    opacity: 0.8;
}

.conta-header-data-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-sm {
    font-size: 16px !important;
}

/* Corpo do recibo */
.conta-body {
    padding: 0 16px;
    margin-top: -16px;
    position: relative;
    z-index: 20;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.receipt-card {
    background-color: var(--lad-white-pure);
    border-radius: 12px 12px 0 0;
    padding: 32px 20px 8px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
}

.receipt-bottom-edge {
    height: 12px;
    background-image:
        linear-gradient(135deg, var(--lad-white-pure) 50%, transparent 50%),
        linear-gradient(45deg, var(--lad-white-pure) 50%, transparent 50%);
    background-position: top left, top left;
    background-size: 16px 16px;
    background-repeat: repeat-x;
    transform: rotate(180deg);
    margin-top: -1px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.03));
}

/* Extrato header */
.receipt-extrato-header {
    text-align: center;
    border-bottom: 1px dashed var(--lad-gray-100);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.receipt-extrato-label {
    font-size: 11px;
    color: var(--lad-gray-600);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.receipt-extrato-numero {
    font-size: 18px;
    font-weight: 700;
    color: var(--lad-dark);
}

/* Lista de itens */
.lista-itens {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.item {
    display: flex;
    flex-direction: column;
}

.item-nome {
    font-size: 15px;
    font-weight: 700;
    color: var(--lad-dark);
    margin-bottom: 4px;
}

.item-detalhe {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    color: var(--lad-gray-600);
}

.item-total {
    color: var(--lad-dark);
    font-weight: 500;
}

/* Separador tracejado */
.separador-dashed {
    border-top: 1px dashed var(--lad-gray-100);
    margin: 16px 0;
}

/* Totais */
.totais {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
    color: var(--lad-gray-600);
    margin-bottom: 16px;
}

.total-row {
    display: flex;
    justify-content: space-between;
}

.total-row .valor {
    color: var(--lad-dark);
}

.desconto-row {
    color: var(--lad-error);
}

.desconto-row .valor {
    color: var(--lad-error) !important;
}

/* Total final */
.total-final-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    padding-bottom: 24px;
    border-top: 1px solid var(--lad-gray-100);
}

.total-final-label {
    font-size: 18px;
    font-weight: 700;
    color: var(--lad-dark);
}

.total-final-valor {
    font-size: 26px;
    font-weight: 700;
    color: var(--lad-orange-500);
}

/* Rodape da conta */
.conta-footer {
    text-align: center;
    padding: 32px 16px 24px;
    max-width: 480px;
    margin: 0 auto;
}

.conta-footer-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
}

.conta-footer-text {
    font-size: 12px;
    color: var(--lad-gray-600);
    margin-bottom: 4px;
}

.conta-footer-empresa {
    font-size: 11px;
    color: var(--lad-gray-300);
}

/* FAB Atualizar */
.fab-atualizar {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--lad-white-pure);
    color: var(--lad-orange-500);
    border-radius: 50%;
    border: 1px solid var(--lad-gray-100);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 50;
    -webkit-tap-highlight-color: transparent;
}

.fab-atualizar:active {
    transform: scale(0.95);
    background: var(--lad-orange-500);
    color: #fff;
}

.fab-icon {
    font-size: 28px;
}

.fab-atualizar.loading .fab-icon {
    animation: spin 0.8s linear infinite;
}

/* ===========================
   Telas de Estado (3, 4, 5)
   =========================== */
.estado-header {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 32px 24px 0;
}

.estado-header-bar {
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--lad-gray-100);
}

.estado-header-white {
    background: var(--lad-white-pure);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    height: 72px;
    align-items: center;
}

.estado-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.estado-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 24px;
    margin-top: -40px;
}

.estado-main-bg {
    background: var(--lad-white);
}

.estado-titulo {
    font-size: 24px;
    font-weight: 700;
    color: var(--lad-blue-900);
    margin-bottom: 12px;
}

.estado-subtitulo {
    font-size: 16px;
    color: var(--lad-gray-600);
    max-width: 280px;
    line-height: 1.5;
}

.estado-footer {
    width: 100%;
    padding: 24px 24px 32px;
}

/* Icone mesa vazia (tela 3) */
.estado-icone-circle {
    width: 128px;
    height: 128px;
    background: var(--lad-white-pure);
    border: 1px solid var(--lad-gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.estado-icone-symbol {
    font-size: 64px;
    color: var(--lad-gray-300);
}

/* Icone relogio (tela 4) */
.estado-icone-circle-white {
    width: 120px;
    height: 120px;
    background: var(--lad-white-pure);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

.estado-icone-clock {
    font-size: 48px;
    color: var(--lad-orange-500);
}

/* Icone wifi off (tela 5) */
.estado-icone-wifi {
    position: relative;
    width: 128px;
    height: 128px;
    background: #fff3e0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
}

.estado-icone-wifi-icon {
    font-size: 64px;
    color: var(--lad-error);
}

.estado-icone-wifi-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: var(--lad-error);
    border-radius: 50%;
    border: 4px solid var(--lad-white);
    display: flex;
    align-items: center;
    justify-content: center;
}

.estado-icone-wifi-badge-icon {
    font-size: 14px;
    color: #fff;
    font-weight: bold;
}

/* LAD FOOD logo inline (tela 4) */
.lad-logo-inline {
    display: flex;
    align-items: center;
    gap: 4px;
}

.lad-logo-badge {
    background: var(--lad-blue-900);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
}

.lad-logo-food {
    font-size: 18px;
    font-weight: 700;
    color: var(--lad-orange-500);
}

.mesa-badge-sm {
    background: var(--lad-blue-900);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
}

/* ===========================
   Botoes
   =========================== */
.btn-primary {
    width: 100%;
    height: 56px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #f24405 0%, #f27405 100%);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(242, 68, 5, 0.2);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
    transform: scale(0.98);
    background: var(--lad-orange-400);
}

.btn-icon {
    font-size: 20px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--lad-gray-600);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    margin-top: 16px;
    display: block;
    width: 100%;
    text-align: center;
}

/* ===========================
   Animacoes
   =========================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.receipt-card {
    animation: fadeIn 0.3s ease;
}

/* ===========================
   Responsividade
   =========================== */
@media (min-width: 481px) {
    .conta-header {
        max-width: 480px;
        margin: 0 auto;
        border-radius: 0 0 24px 24px;
    }

    #tela-conta {
        background: var(--lad-white);
    }
}

@media (max-width: 359px) {
    .conta-header-nome {
        font-size: 18px;
    }

    .receipt-extrato-numero {
        font-size: 16px;
    }

    .item-nome {
        font-size: 14px;
    }

    .item-detalhe {
        font-size: 12px;
    }

    .total-final-valor {
        font-size: 22px;
    }

    .total-final-label {
        font-size: 16px;
    }
}

/* =============================================
   Dialog: Digitar Token da Comanda
   ============================================= */

.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 5, 40, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
    animation: fadeIn 0.2s ease;
}

.dialog-overlay.hidden {
    display: none;
}

.dialog-box {
    background: #fff;
    border-radius: 1.25rem;
    padding: 2rem 1.5rem 1.75rem;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 20px 60px rgba(10, 5, 40, 0.25);
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dialog-icon-circle {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #190e88, #3d2bc7);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.dialog-icon-symbol {
    font-size: 1.6rem;
    color: #fff;
    font-variation-settings: 'FILL' 1;
}

.dialog-titulo {
    font-size: 1.2rem;
    font-weight: 700;
    color: #0d0a2e;
    margin: 0;
    text-align: center;
}

.dialog-subtitulo {
    font-size: 0.875rem;
    color: #64607e;
    text-align: center;
    margin: 0 0 0.75rem;
    line-height: 1.5;
}

.dialog-input-group {
    position: relative;
    width: 100%;
    margin-bottom: 0.25rem;
}

.dialog-input-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: #190e88;
    font-size: 1.1rem;
    font-variation-settings: 'FILL' 0;
    pointer-events: none;
}

.dialog-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.9rem 1rem 0.9rem 2.75rem;
    border: 2px solid #e0dff5;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-family: 'Roboto Mono', monospace;
    font-weight: 500;
    color: #0d0a2e;
    background: #f7f6fd;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    letter-spacing: 0.05em;
}

.dialog-input:focus {
    border-color: #190e88;
    box-shadow: 0 0 0 3px rgba(25, 14, 136, 0.12);
    background: #fff;
}

.dialog-input::placeholder {
    color: #b0aec8;
    font-weight: 400;
    letter-spacing: 0;
}

.dialog-erro {
    font-size: 0.8rem;
    color: #d32f2f;
    margin: 0;
    align-self: flex-start;
    padding-left: 0.25rem;
}

.dialog-btn {
    width: 100%;
    margin-top: 0.75rem;
}
