:root {
    --bg: #f3efe6;
    --bg-2: #e7f0eb;
    --ink: #1c1915;
    --muted: #5e584e;
    --line: #e0d8cb;
    --card: #fffcf7;
    --green: #14614d;
    --green-2: #0e3d32;
    --green-soft: #e5f3ee;
    --amber: #9a3412;
    --amber-btn: #c2410c;
    --danger: #9f1239;
    --ok: #166534;
    --shadow: 0 10px 30px rgba(28, 25, 21, 0.08);
    --radius: 18px;
    --tap: 48px;
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    color: var(--ink);
    background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(900px 280px at 100% -40px, rgba(20, 97, 77, 0.08), transparent 50%),
        var(--bg);
    font-size: 16px;
    line-height: 1.45;
}
body.pagina-pdv {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--green); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

.skip {
    position: absolute;
    left: 12px;
    top: -40px;
    background: white;
    padding: 8px 12px;
    z-index: 80;
}
.skip:focus { top: 12px; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    background: var(--green-2);
    color: #f7f3ea;
}
.marca {
    display: flex;
    gap: 10px;
    align-items: center;
    color: inherit;
    text-decoration: none;
}
.marca strong { display: block; font-size: 1.05rem; }
.marca small { display: block; opacity: 0.8; }
.marca-selo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #f4efe4;
    color: var(--green-2);
    font-weight: 800;
}
.topbar-usuario { display: flex; gap: 10px; align-items: center; }
.quem { margin: 0; text-align: right; }
.quem span { display: block; font-size: 0.82rem; opacity: 0.8; }
.topbar .btn-ghost { color: #f7f3ea; border-color: rgba(247, 243, 234, 0.35); }

.menu {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 12px 10px;
    background: var(--green);
}
.menu a {
    color: #f7f3ea;
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 999px;
    white-space: nowrap;
    font-weight: 700;
    min-height: 44px;
}
.menu a.is-active { background: #fffcf7; color: var(--green-2); }

.pagina { width: min(1100px, calc(100% - 24px)); margin: 18px auto 32px; }
.pagina-estreita { width: min(420px, calc(100% - 24px)); }
.rodape { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 8px 16px 24px; }

.page-head, .cart-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.page-head p { color: var(--muted); margin: 0; }

.card, .auth-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 14px;
}
.auth-card { margin: 0; }
.tela-auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background:
        radial-gradient(circle at 15% 10%, #1f7a62, transparent 36%),
        var(--green-2);
}
.auth-main { width: min(440px, 100%); }
.auth-escola { color: var(--green); font-weight: 700; margin-bottom: 6px; }
.auth-sub { color: var(--muted); }
.auth-card h1 { font-size: 2rem; }

.stats, .grade-duas, .form-grid, .pay-grid, .produto-grade {
    display: grid;
    gap: 12px;
}
.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 14px; }
.grade-duas { grid-template-columns: 1fr; }
.form-grid { grid-template-columns: 1fr; }
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
}
.stat span, .stat em { display: block; color: var(--muted); font-style: normal; }
.stat strong { display: block; font-size: 1.45rem; margin-top: 4px; font-variant-numeric: tabular-nums; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.filtros, .acoes, .atalhos-nota, .qtd, .topbar-usuario {
    display: flex;
    gap: 8px;
    align-items: end;
    flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field span, .check span { font-weight: 700; }
.field-largo { grid-column: 1 / -1; }
.field-busca { flex: 1; }
.help, .bloco-suave { color: var(--muted); font-size: 0.92rem; }
.bloco-suave { display: block; }
input, select, textarea {
    width: 100%;
    min-height: var(--tap);
    border: 1px solid #cfc6b8;
    background: white;
    border-radius: 12px;
    padding: 10px 12px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
    outline: 3px solid #c2410c;
    outline-offset: 2px;
}
.check { display: flex; gap: 8px; align-items: center; min-height: 44px; }
.check input { width: 22px; height: 22px; min-height: 22px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 10px 16px;
    border-radius: 14px;
    border: 2px solid transparent;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
    background: #efe8dc;
    color: var(--ink);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--green); color: white; }
.btn-accent { background: var(--amber-btn); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; border-color: #cfc6b8; }
.btn-sm { min-height: 40px; padding: 6px 10px; border-radius: 10px; }
.btn-lg { min-height: 56px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-pay { background: white; border-color: #cfc6b8; min-height: 64px; font-size: 1.05rem; }
.btn-pay.is-active { background: var(--green); color: white; border-color: var(--green); }

.alert {
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 12px;
    border: 1px solid transparent;
}
.alert-ok { background: #e9f7ee; color: #14532d; }
.alert-aviso { background: #fff6e8; color: #9a3412; }
.alert-erro { background: #fff1f2; color: #9f1239; }

.field-descricao { flex: 1 1 320px; }
.acesso-lista { display: grid; gap: 8px; }
.acesso-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    font-weight: 700;
}
.acesso-item input { width: 20px; height: 20px; }
.troca-turma { display: flex; gap: 8px; align-items: center; }
.troca-turma select { min-width: 11rem; min-height: 40px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.82rem; letter-spacing: 0.02em; color: var(--muted); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot th { color: var(--ink); }
.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.78rem;
    font-weight: 800;
}
.badge-ok { background: #dcfce7; color: var(--ok); }
.badge-aviso { background: #ffedd5; color: var(--amber); }
.badge-erro { background: #ffe4e6; color: var(--danger); }
.badge-muted { background: #eeeae3; color: var(--muted); }
.dif-zero { color: var(--ok); font-weight: 800; }
.dif-alerta { color: var(--danger); font-weight: 800; }
.riscado { text-decoration: line-through; color: var(--muted); }
.vazio { color: var(--muted); padding: 8px 0; }
.estoque-grande { font-size: 1.8rem; }
.erro-box { text-align: center; padding: 28px 16px; }
.erro-codigo { font-size: 2rem; color: var(--muted); margin: 0; }

.lista-valores, .lista-vendas { list-style: none; margin: 0; padding: 0; }
.lista-valores li, .lista-vendas li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.lista-vendas small { display: block; color: var(--muted); }

.pdv { display: block; }
.pdv-ferramentas {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.pdv-ferramentas .pilulas { grid-column: 1 / -1; }
.pilulas { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.pilula {
    border: 0;
    background: #efe8dc;
    color: var(--ink);
    border-radius: 999px;
    min-height: 42px;
    padding: 8px 14px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}
.pilula.is-active { background: var(--green-2); color: white; }
.produto-grade { grid-template-columns: 1fr 1fr; }
.produto-btn {
    position: relative;
    min-height: 0;
    height: auto;
    text-align: center;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 8px 18px rgba(28, 25, 21, 0.06);
    padding: 10px 8px 8px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    cursor: pointer;
}
.produto-btn:hover:not(:disabled) { border-color: #b7d4c8; box-shadow: 0 10px 22px rgba(20, 97, 77, 0.12); }
.produto-miolo {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 0;
    width: 100%;
    gap: 6px;
}
.produto-foto-caixa {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(180deg, #f7f3ec, #efe8dc);
    display: grid;
    place-items: center;
}
.produto-foto-caixa.sem-foto {
    color: var(--green-2);
    font-size: 1.6rem;
    font-weight: 800;
}
.produto-foto {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.produto-preview {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--line);
}
.mini-foto {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 8px;
    vertical-align: middle;
    margin-right: 8px;
}
.produto-btn.no-carrinho { border-color: var(--green); box-shadow: 0 0 0 2px rgba(20, 97, 77, 0.16); }
.qtd-no-produto {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--amber-btn);
    color: white;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(28, 25, 21, 0.18);
}
.produto-btn strong {
    font-size: 0.92rem;
    line-height: 1.2;
    min-height: 2.4em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.produto-preco { font-size: 1.15rem; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }
.produto-btn small { color: var(--muted); font-size: 0.75rem; }
.produto-btn.estoque-baixo { border-color: #fdba74; }
.produto-btn.esgotado { background: #f6f3ee; color: var(--muted); cursor: not-allowed; box-shadow: none; }
.produto-btn.esgotado .produto-preco { color: var(--muted); }
.produto-btn.esgotado .produto-foto { filter: grayscale(1); opacity: 0.6; }

.cart-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
body.pagina-pdv .btn-pay { min-height: 44px; padding: 8px 10px; }
body.pagina-pdv .pay-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
body.pagina-pdv #limpar { min-height: 36px; }
body.pagina-pdv .cart-panel { padding: 8px 10px; }
body.pagina-pdv .cart-lista { flex: 1 1 auto; min-height: 48px; }
body.pagina-pdv .cart-pagamento {
    flex: 0 0 auto;
}
body.pagina-pdv .cart-acoes { display: flex; flex-direction: column; gap: 6px; }
body.pagina-pdv .cart-total { margin: 4px 0; font-size: 1.15rem; }
body.pagina-pdv .cobranca-direta { padding: 6px 10px; }
body.pagina-pdv .cobranca-direta strong { font-size: 1.55rem; }
body.pagina-pdv .troco-caixa { padding: 6px 10px; }
body.pagina-pdv .troco-caixa strong { font-size: 1.35rem; }
body.pagina-pdv .cart-pagamento .field { gap: 2px; }
body.pagina-pdv .cart-pagamento input { min-height: 40px; padding: 6px 10px; }
.aluno-venda {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 4px 8px;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--line);
}
.aluno-venda .field { gap: 2px; }
.aluno-venda .field-aluno { grid-column: 1 / -1; }
.aluno-venda .field > span { font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.aluno-venda select { min-height: 32px; padding: 2px 8px; font-size: 0.88rem; }
@media (min-width: 860px) {
    body.pagina-pdv .cart-panel.com-itens .cart-head { display: none; }
}
body.pagina-pdv .cart-panel.com-itens .aluno-venda { gap: 4px; padding-bottom: 4px; margin-bottom: 4px; }
body.pagina-pdv .cart-panel.com-itens .aluno-venda .field > span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
body.pagina-pdv .cart-panel.com-itens .cart-linha { padding: 5px 0; }
.field-turma, .field-aluno { flex: 1 1 220px; }
.aluno-escolhido { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.aluno-escolhido strong, .aluno-escolhido small { display: block; }
.lista-escolha {
    max-height: 132px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}
.lista-escolha button { text-align: left; justify-content: flex-start; min-height: 36px; }
.cart-lista { flex: 1 1 auto; min-height: 0; overflow: auto; }
.cart-pagamento { flex: 0 0 auto; }
.cart-linha { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cart-linha > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.cart-linha strong { line-height: 1.2; }
.cart-linha small, .cart-total, .cobranca-direta strong, .troco-caixa strong { font-variant-numeric: tabular-nums; }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.25rem; margin: 8px 0; }
.resumo-pagamento { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.cobranca-direta {
    background: var(--green-soft);
    border-radius: 14px;
    padding: 10px 12px;
    text-align: center;
}
.cobranca-direta span { display: block; color: var(--muted); font-weight: 700; }
.cobranca-direta strong { display: block; font-size: 1.8rem; color: var(--green-2); }
.troco-caixa {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #e9f7ee;
    border-radius: 14px;
    padding: 8px 12px;
}
.troco-caixa strong { font-size: 1.6rem; color: var(--ok); }
.troco-caixa.falta { background: #fff1f2; }
.troco-caixa.falta strong { color: var(--danger); }
.resto-pagamento { margin-top: 8px; }
.resto-pagamento .help { margin: 0 0 6px; }
.resto-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.resto-grid .btn-pay { min-height: 42px; padding: 6px 4px; font-size: 0.92rem; }
.cart-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(243, 239, 230, 0.96);
    border-top: 1px solid var(--line);
    z-index: 20;
}
.qtd span { min-width: 24px; text-align: center; font-weight: 800; }

.recibo-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(20, 16, 12, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}
.recibo, .recibo-pagina {
    width: min(380px, 100%);
    background: white;
    color: black;
    border-radius: 16px;
    padding: 18px 16px;
}
.recibo-resumo { width: min(440px, 100%); text-align: center; }
.recibo-resumo h2 { margin: 0 0 8px; }
.recibo-meta, .recibo-totais {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
}
.recibo-meta { color: #333; }
.recibo-totais { margin-top: 8px; }
.recibo-totais strong { font-size: 1.35rem; }
.recibo-resumo table { text-align: left; }
.recibo-acoes {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}
.recibo-acoes .btn { min-width: 220px; }
.recibo-escola { font-weight: 800; }
.recibo table { margin: 8px 0; width: 100%; }
.recibo td:last-child, .recibo-pagina td:last-child { text-align: right; white-space: nowrap; }
.recibo-nota { color: #444; font-size: 0.85rem; }
.bloco-caixa { padding-top: 8px; border-top: 1px solid var(--line); margin-top: 8px; }
details { margin-top: 6px; }
summary { cursor: pointer; font-weight: 700; min-height: 36px; }
.toast-wrap {
    position: fixed;
    right: 12px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 70;
    width: min(360px, calc(100% - 24px));
}
.toast {
    background: var(--green-2);
    color: white;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
}
.toast-erro { background: var(--danger); }
.toast-aviso { background: var(--amber); }

@media (min-width: 800px) {
    .grade-duas, .form-grid { grid-template-columns: 1fr 1fr; }
    .pagina { margin-top: 24px; }
}
body.pagina-pdv .topbar { padding: 6px 12px; }
body.pagina-pdv .marca-selo { width: 32px; height: 32px; }
body.pagina-pdv .menu { padding: 4px 8px 6px; }
body.pagina-pdv .menu a { min-height: 36px; padding: 6px 12px; }
body.pagina-pdv .rodape { display: none; }
body.pagina-pdv .pagina {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 8px;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body.pagina-pdv .alert { margin-bottom: 6px; padding: 8px 10px; }
.pdv-produtos { min-height: 0; display: flex; flex-direction: column; }
.pdv-caixa { margin: 0; color: var(--muted); white-space: nowrap; }
body.pagina-pdv .produto-grade {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    align-content: start;
    align-items: start;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    grid-auto-rows: max-content;
    gap: 10px;
}
body.pagina-pdv .produto-btn {
    min-height: auto;
    height: auto;
    align-self: start;
    overflow: hidden;
}
body.pagina-pdv .produto-miolo {
    flex: none;
    width: 100%;
}
body.pagina-pdv .produto-foto-caixa {
    position: relative;
    width: 100%;
    height: 96px;
    aspect-ratio: auto;
    flex: 0 0 96px;
}
body.pagina-pdv .produto-foto {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: center;
}
body.pagina-pdv .produto-btn strong {
    width: 100%;
    min-height: 2.4em;
}
body.pagina-pdv .cart-head { margin-bottom: 6px; }
body.pagina-pdv .cart-head h2 { font-size: 1rem; margin: 0; }
body.pagina-pdv .pilula { min-height: 36px; padding: 6px 12px; }
body.pagina-pdv .pdv-ferramentas input { min-height: 40px; padding: 8px 12px; }
body.pagina-pdv .menu { overflow-x: auto; }
body.pagina-pdv .pdv {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 8px;
    align-items: stretch;
}
body.pagina-pdv .cart-bar,
body.pagina-pdv #fechar-carrinho { display: none; }
@media (max-width: 859px) {
    body.pagina-pdv .pdv { grid-template-columns: 1fr; }
    body.pagina-pdv .cart-panel { display: none; }
    body.pagina-pdv .cart-bar {
        display: block;
        position: static;
        flex: 0 0 auto;
        padding: 8px 0 0;
        background: transparent;
        border: 0;
    }
    body.carrinho-aberto .cart-panel {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 40;
        border-radius: 0;
        overflow: hidden;
    }
    body.carrinho-aberto #fechar-carrinho { display: inline-flex; }
    body.carrinho-aberto .cart-bar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}
@media print {
    .no-print, .topbar, .menu, .rodape, .cart-bar, .toast-wrap { display: none !important; }
    body { background: white; }
    .pagina { width: auto; margin: 0; }
    .card, .stat { box-shadow: none; }
    body.imprimindo-recibo * { visibility: hidden; }
    body.imprimindo-recibo #recibo,
    body.imprimindo-recibo #recibo * { visibility: visible; }
    body.imprimindo-recibo #recibo {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white;
        display: block !important;
    }
}
