:root {
    --bg: #f5f3ef;
    --card: #ffffff;
    --primary: #c0392b;
    --primary-dark: #96271b;
    --text: #2b2b2b;
    --muted: #7a7a7a;
    --border: #e5e1da;
    --ok: #27ae60;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 520px;
    margin: 0 auto;
    padding: 20px 16px 96px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}

/* Foco acessível (teclado) */
:focus-visible {
    outline: 3px solid rgba(192, 57, 43, 0.45);
    outline-offset: 2px;
}

header.topo {
    text-align: center;
    padding: 24px 16px 8px;
}

header.topo h1 {
    margin: 0;
    font-size: 1.5rem;
}

header.topo p {
    margin: 4px 0 0;
    color: var(--muted);
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.produto {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.produto .info h3 {
    margin: 0 0 2px;
    font-size: 1.05rem;
}

.produto .info p {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.preco {
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    background: #fff;
}

.btn {
    display: inline-block;
    width: 100%;
    text-align: center;
    padding: 14px 16px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn.secondary {
    background: #efeae3;
    color: var(--text);
}

.btn.small {
    width: auto;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.btn.ok {
    background: var(--ok);
}

.linha {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.linha:last-child {
    border-bottom: none;
}

.total {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 12px;
}

.erro {
    background: #fdecea;
    color: #b71c1c;
    border: 1px solid #f5c6cb;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 12px;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #eef;
    color: #3355cc;
}

.rodape-fixo {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
}

.rodape-fixo .container {
    padding: 0;
    max-width: 520px;
}

.muted {
    color: var(--muted);
}

.center {
    text-align: center;
}

.mt {
    margin-top: 16px;
}

.qtd-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qtd-controls form {
    margin: 0;
}

/* ----- Admin ----- */
.container.wide {
    max-width: 900px;
}

.barra-admin {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.barra-admin a {
    width: auto;
    flex: 0 0 auto;
}

.sucesso {
    background: #eafaf1;
    color: #1e7e46;
    border: 1px solid #b7e4c7;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 12px;
}

table.tabela {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

table.tabela th,
table.tabela td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}

table.tabela th {
    background: #faf8f5;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

table.tabela tr:last-child td {
    border-bottom: none;
}

.acoes {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.acoes form {
    margin: 0;
}

.pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.pill.on {
    background: #eafaf1;
    color: #1e7e46;
}

.pill.off {
    background: #fdecea;
    color: #b71c1c;
}

.form-row {
    margin-bottom: 14px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-row input {
    width: auto;
}

.opcoes-consumo {
    display: flex;
    gap: 8px;
}

.opcoes-consumo .opcao {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    font-weight: 500;
    cursor: pointer;
}

.opcoes-consumo .opcao input {
    width: auto;
}

.badge.pill-mesa {
    background: #fff3cd;
    color: #8a6d00;
}

.cards-resumo {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.card.resumo {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card.resumo strong {
    font-size: 1.4rem;
}

.card.resumo.positivo strong {
    color: var(--ok);
}

.card.resumo.negativo strong {
    color: var(--primary);
}

.titulo-categoria {
    font-size: 1.1rem;
    margin: 20px 0 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--border);
    color: var(--primary-dark);
}

.dica-categoria {
    font-size: 0.85rem;
    margin: 4px 0 14px;
}

.categoria-bloco {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 10px;
    overflow: hidden;
}

.categoria-bloco > summary {
    list-style: none;
    cursor: pointer;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.categoria-bloco > summary::-webkit-details-marker {
    display: none;
}

.categoria-bloco > summary::after {
    content: "▸";
    color: var(--muted);
    font-weight: 400;
    transition: transform 0.15s ease;
}

.categoria-bloco[open] > summary::after {
    transform: rotate(90deg);
}

.categoria-bloco > summary .qtd-itens {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.9rem;
    margin-left: auto;
    margin-right: 10px;
}

.categoria-itens {
    padding: 0 12px 12px;
}

.categoria-itens .produto {
    box-shadow: none;
    border-color: var(--border);
}

/* ----- Toast ----- */
.toast-container {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(84px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    pointer-events: none;
    padding: 0 12px;
}

.toast {
    max-width: 460px;
    width: fit-content;
    background: #2b2b2b;
    color: #fff;
    padding: 12px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-ok {
    background: #1e7e46;
}

.toast-erro {
    background: #b71c1c;
}

.toast-info {
    background: #2b2b2b;
}

/* ----- Stepper de quantidade ----- */
.stepper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #efeae3;
    border-radius: 999px;
    padding: 4px;
}

.step-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-btn:hover {
    background: var(--primary-dark);
}

.step-btn:disabled {
    background: #c9c2b8;
    cursor: default;
}

.step-qtd {
    min-width: 26px;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
}

.stepper.vazio .step-btn.menos {
    background: #c9c2b8;
}

/* ----- Tabelas responsivas ----- */
.tabela-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
}

.tabela-scroll table.tabela {
    min-width: 560px;
}

/* ----- Kanban da cozinha ----- */
.kanban {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    align-items: start;
}

.coluna-kanban {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
}

.coluna-kanban h2 {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    margin: 4px 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.coluna-kanban .col-count {
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 0.8rem;
}

.coluna-kanban .card {
    margin-bottom: 10px;
}

.coluna-kanban .vazio-col {
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 12px 0;
}

@keyframes flashNovo {
    0% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.6); }
    100% { box-shadow: 0 0 0 14px rgba(39, 174, 96, 0); }
}

.card.novo-destaque {
    animation: flashNovo 1s ease-out 2;
    border-color: var(--ok);
}

small.muted {
    display: block;
    margin-top: 4px;
    font-size: 0.78rem;
}

/* Trava de seguranca: nada deve provocar rolagem horizontal */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* ===== Admin mobile-first ===== */

/* Navegacao inferior fixa (estilo app) */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    display: flex;
    background: #fff;
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.05);
}

.bottom-nav a {
    flex: 1;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 8px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-height: 56px;
    justify-content: center;
}

.bottom-nav a .bn-ico {
    font-size: 1.3rem;
    line-height: 1;
}

.bottom-nav a.ativo {
    color: var(--primary);
}

/* paginas com bottom-nav precisam de espaco extra embaixo */
.tem-bottomnav {
    padding-bottom: 88px;
}

/* Cabecalho de secao do admin (titulo + acao) */
.admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.admin-head h2 {
    margin: 0;
    font-size: 1.15rem;
}

/* Lista em cartoes (1 coluna no celular, grade no desktop) */
.lista-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 640px) {
    .lista-cards {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

.item-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
}

.item-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.item-card-top strong {
    font-size: 1.05rem;
}

.item-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.item-card .descr {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.item-card .interno {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    color: var(--muted);
    font-size: 0.8rem;
}

.item-card-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}

/* faz o botao dentro de <form> preencher a coluna da grade */
.item-card-actions form {
    margin: 0;
    display: contents;
}

.item-card-actions .btn {
    width: 100%;
    padding: 12px 6px;
    font-size: 0.85rem;
    min-height: 44px;
}

/* Feed de auditoria (lista mobile-first) */
.feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.feed-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
}

.feed-item .feed-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.feed-item .feed-quando {
    color: var(--muted);
    font-size: 0.78rem;
}

.feed-item .feed-detalhe {
    margin-top: 6px;
    font-size: 0.9rem;
}

/* botoes com area de toque confortavel no admin */
@media (max-width: 640px) {
    .btn.small {
        padding: 11px 14px;
        min-height: 44px;
    }
}

/* ----- Tabelas viram cartoes no celular (sem rolagem lateral) ----- */
@media (max-width: 640px) {
    .tabela-scroll {
        overflow: visible;
    }

    table.tabela {
        min-width: 0;
        border: none;
        background: transparent;
    }

    table.tabela thead {
        /* esconde o cabecalho: cada celula ja mostra o seu rotulo */
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    table.tabela tr {
        display: block;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 6px 14px;
        margin-bottom: 10px;
    }

    table.tabela td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 1px solid var(--border);
        text-align: right;
    }

    table.tabela tr td:last-child {
        border-bottom: none;
    }

    table.tabela td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
        text-align: left;
        white-space: nowrap;
    }

    /* celula sem rotulo/valor: nao ocupa espaco */
    table.tabela td:empty {
        display: none;
    }

    /* celula de acoes ocupa a linha inteira, botoes a direita */
    table.tabela td .acoes {
        justify-content: flex-end;
        flex-wrap: wrap;
    }
}
