:root {
  --bg: #f2f5fb; --card: #ffffff; --txt: #0f1b33; --muted: #5b6b86; --borda: #dde4f0; --suave: #eef3fc;
  --pri: #1d5fd1; --pri-esc: #1648a3; --pri-txt: #ffffff; --pri-suave: #e3edff;
  --topo-1: #0b1f4a; --topo-2: #1d5fd1;
  --livre: #1f8a4c; --livre-suave: #e4f5ea;
  --ocupada: #d08300; --ocupada-suave: #fff4dd;
  --conta: #6d3fd6; --conta-suave: #efe8ff;
  --alerta: #d22d3b; --alerta-suave: #fde6e8;
  --sombra: 0 1px 2px rgba(15, 27, 51, .06), 0 4px 14px rgba(15, 27, 51, .06);
  --raio: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--txt); -webkit-tap-highlight-color: transparent; }

/* Topo */
header.topo { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: linear-gradient(110deg, var(--topo-1), var(--topo-2)); color: #fff; box-shadow: 0 2px 10px rgba(11, 31, 74, .25); }
header.topo h1 { font-size: 18px; font-weight: 700; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
header.topo h1 small { display: block; font-size: 12px; font-weight: 500; opacity: .75; }
header.topo button, header.topo .btn { background: rgba(255, 255, 255, .12); color: #fff; border: 1px solid rgba(255, 255, 255, .25); min-height: 40px; padding: 8px 12px; }
header.topo button:hover { background: rgba(255, 255, 255, .22); }
header.topo button.ativa { background: #fff; color: var(--pri-esc); border-color: #fff; }
header.topo select { width: auto; min-width: 0; max-width: 42vw; background: rgba(255, 255, 255, .95); }
header.topo > button, header.topo > .btn { flex: none; white-space: nowrap; }
@media (max-width: 480px) {
  header.topo { gap: 6px; padding: 8px 10px; }
  header.topo button, header.topo .btn { padding: 6px 9px; }
}
main { padding: 16px; max-width: 1240px; margin: 0 auto; }

/* Controles */
button, .btn { font: inherit; font-weight: 500; border: 1px solid var(--borda); background: var(--card); color: var(--txt); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s, transform .05s; }
button:hover { border-color: #c3cfe4; }
button:active { transform: scale(.98); }
button.pri, .btn.pri { background: var(--pri); color: var(--pri-txt); border-color: var(--pri); }
button.pri:hover { background: var(--pri-esc); }
button.sec { background: var(--pri-suave); color: var(--pri-esc); border-color: transparent; }
button.perigo { color: var(--alerta); border-color: #f2b8be; background: var(--card); }
button.whats, a.whats { background: #e7f8ee; color: #128c4b; border-color: transparent; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea { font: inherit; padding: 11px 12px; border: 1px solid var(--borda); border-radius: 10px; width: 100%; background: #fff; color: var(--txt); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pri); outline-offset: 0; border-color: var(--pri); }
label { display: block; font-size: 14px; color: var(--muted); font-weight: 500; }
label input, label select { margin-top: 4px; color: var(--txt); }
.campos { display: grid; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px; box-shadow: var(--sombra); }
.muted { color: var(--muted); font-size: 14px; }
.linha { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.linha > .cresce { flex: 1; min-width: 0; }
.grade { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.oculto { display: none !important; }
h2 { font-size: 17px; margin: 22px 0 10px; letter-spacing: -.01em; }
.titulo-secao { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 18px 0 10px; }
.titulo-secao h2 { margin: 0; }

/* Cliente da comanda */
.cliente { display: flex; align-items: center; gap: 10px 12px; padding: 12px; border-radius: 12px; background: var(--suave); margin-bottom: 12px; flex-wrap: wrap; }
.cliente .muted { white-space: nowrap; }
.cliente .acoes { display: flex; gap: 8px; margin-left: auto; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--pri); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.cliente .cresce { flex: 1; min-width: 150px; }
.cliente .mesa-tag { display: inline-block; margin-bottom: 4px; padding: 2px 10px; border-radius: 99px; background: var(--pri); color: #fff; font-weight: 800; font-size: 15px; }
.cliente .cresce > .muted { display: block; }
.cliente b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Mesas */
.mesa { position: relative; text-align: left; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 2px;
  padding: 12px 12px 12px 16px; min-height: 112px; box-shadow: var(--sombra); overflow: hidden; border-color: transparent; }
.mesa::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--livre)); }
.mesa .topo-mesa { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.mesa .num { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.mesa .estado { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--cs, var(--livre-suave)); color: var(--c, var(--livre)); white-space: nowrap; }
.mesa .nome { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mesa .valor { font-weight: 700; }
.mesa.livre { --c: var(--livre); --cs: var(--livre-suave); }
.mesa.ocupada { --c: var(--ocupada); --cs: var(--ocupada-suave); }
.mesa.conta { --c: var(--conta); --cs: var(--conta-suave); }
.mesa.abertura { --c: var(--alerta); --cs: var(--alerta-suave); border-color: var(--alerta); animation: pulsar 1.6s ease-in-out infinite; }
.mesa .selos { display: flex; gap: 4px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
@keyframes pulsar { 50% { box-shadow: 0 0 0 5px rgba(210, 45, 59, .18); } }
.selo { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; color: #fff; background: var(--alerta); white-space: nowrap; }
.selo.azul { background: var(--pri); } .selo.verde { background: var(--livre); } .selo.laranja { background: var(--ocupada); } .selo.roxo { background: var(--conta); }
.legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.legenda span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--c); }

/* Itens */
.itens { list-style: none; margin: 0; padding: 0; }
.itens li { display: flex; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--borda); flex-wrap: wrap; }
.itens li:last-child { border-bottom: 0; }
.itens li .cresce { flex: 1; min-width: 150px; }
.st { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--suave); color: var(--muted); white-space: nowrap; }
.st.pendente { background: var(--alerta-suave); color: var(--alerta); } .st.novo, .st.pedido { background: var(--pri-suave); color: var(--pri-esc); }
.st.preparo { background: var(--ocupada-suave); color: #8a5700; } .st.pronto { background: var(--livre-suave); color: #176b3a; }
.st.cancelado { text-decoration: line-through; }
.riscado { text-decoration: line-through; color: var(--muted); }
.totais { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--borda); }
.totais .grande { font-size: 21px; font-weight: 800; color: var(--pri-esc); }

/* Cardápio */
.abas { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
/* Com mouse (computador) as categorias quebram linha em vez de ficarem escondidas para o lado */
@media (hover: hover) and (pointer: fine) { .abas { flex-wrap: wrap; overflow-x: visible; } }
.abas button { white-space: nowrap; border-radius: 99px; min-height: 40px; padding: 8px 16px; }
.abas button.ativa { background: var(--pri); color: #fff; border-color: var(--pri); }
.produto { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--borda); flex-wrap: wrap; }
.produto .cresce { min-width: 0; }
.produto > .obs { flex-basis: 100%; }
.produto:last-child { border-bottom: 0; }
.produto .cresce { flex: 1; }
.produto .preco { color: var(--pri-esc); font-weight: 700; }
.qtd { display: flex; align-items: center; gap: 6px; }
.qtd button { width: 44px; padding: 0; font-size: 22px; border-radius: 50%; }
.qtd button[data-mais] { background: var(--pri); color: #fff; border-color: var(--pri); }
.qtd b { min-width: 22px; text-align: center; }
.barra-fixa { position: sticky; bottom: 0; background: var(--card); padding: 12px 16px; margin: 12px -16px 0; border-top: 1px solid var(--borda); box-shadow: 0 -4px 14px rgba(15, 27, 51, .06); }
.busca { margin: 0 0 12px; }
.busca input { font-size: 16px; padding: 12px 14px; border-radius: 12px; background: var(--card); }
.cardapio .busca { margin: 0 0 10px; }

/* Modal / PIN */
.modal { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(11, 31, 74, .55); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; backdrop-filter: blur(2px); }
.modal > .card { width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.pin-display { font-size: 34px; letter-spacing: 14px; text-align: center; min-height: 52px; color: var(--pri-esc); }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.teclado button { font-size: 24px; min-height: 62px; font-weight: 600; }
.aviso { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--alerta-suave); color: var(--alerta); margin-bottom: 10px; font-weight: 600; border: 1px solid #f6c3c8; }
.aviso .cresce { flex: 1; min-width: 0; }
.aviso.azul { background: var(--pri-suave); color: var(--pri-esc); border-color: #c3d6fb; }
.aviso.verde { background: var(--livre-suave); color: var(--livre); border-color: transparent; }
/* Alerta piscando enquanto ninguém atende */
.aviso.piscar { animation: piscar 1s steps(1) infinite; }
.aviso.azul.piscar { animation-name: piscar-azul; }
@keyframes piscar { 50% { background: var(--alerta); color: #fff; border-color: var(--alerta); } }
@keyframes piscar-azul { 50% { background: var(--pri); color: #fff; border-color: var(--pri); } }
.aviso.piscar button { animation: none; }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.kpis .card b { display: block; font-size: 22px; }

/* Menu lateral */
.gaveta { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 25; background: rgba(11, 31, 74, .45); }
.gaveta nav { position: absolute; left: 0; top: 0; bottom: 0; width: 300px; max-width: 85vw; border-radius: 0 var(--raio) var(--raio) 0; display: flex; flex-direction: column; gap: 4px; overflow: auto; }
.gaveta nav a { padding: 12px 14px; border-radius: 10px; color: var(--txt); text-decoration: none; font-weight: 500; }
.gaveta nav a:hover { background: var(--suave); }
.gaveta nav a.ativa { background: var(--pri-suave); color: var(--pri-esc); font-weight: 700; }

/* Painel principal do gerente */
.painel-geral { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .painel-geral { grid-template-columns: 2fr 1fr; } }
.preparo-mesa { padding: 8px 0; border-bottom: 1px solid var(--borda); }
.preparo-mesa:last-child { border-bottom: 0; }
.preparo-mesa .itens li { padding: 4px 0; border: 0; }
.atrasado { color: var(--alerta); font-weight: 700; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--topo-1); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 30; max-width: 90vw; box-shadow: var(--sombra); }

/* KDS */
.kds { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.ticket { border-top: 6px solid var(--livre); }
.ticket.atencao { border-top-color: var(--ocupada); }
.ticket.atrasado { border-top-color: var(--alerta); }
.ticket .cab { display: flex; justify-content: space-between; font-weight: 800; font-size: 20px; margin-bottom: 8px; }
.ticket .item { padding: 8px 0; border-bottom: 1px dashed var(--borda); }
.ticket .item .nome { font-size: 18px; font-weight: 600; }
.ticket .obs { color: var(--alerta); font-weight: 600; }

/* Página do cliente */
.hero { text-align: center; padding: 28px 16px; }
.hero .icone { font-size: 46px; }
.hero h2 { font-size: 22px; margin: 8px 0 4px; }

/* Login */
.modal.dialogo > .card { max-width: 400px; text-align: center; padding: 26px 22px 20px; animation: d-entra .22s ease-out; }
.modal.dialogo h2 { font-size: 21px; margin: 6px 0 6px; }
.modal.dialogo p { margin: 0 0 6px; white-space: pre-line; }
.modal.dialogo.saindo { opacity: 0; transition: opacity .15s; }
.d-icone { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center;
  border: 4px solid currentColor; font-size: 40px; font-weight: 800; animation: d-icone .45s ease-out; }
.d-icone.sucesso { color: var(--livre); background: var(--livre-suave); }
.d-icone.pergunta { color: var(--pri); background: var(--pri-suave); }
.d-icone.aviso { color: var(--ocupada); background: var(--ocupada-suave); }
.d-icone.erro { color: var(--alerta); background: var(--alerta-suave); }
.d-campo { margin: 10px 0 4px; text-align: center; font-size: 18px; }
.d-botoes { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.d-botoes button { flex: 1; max-width: 170px; font-weight: 600; }
button.perigo-cheio { background: var(--alerta); color: #fff; border-color: var(--alerta); }
@keyframes d-entra { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes d-icone { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
.modal.fixo { background: linear-gradient(135deg, var(--topo-1), var(--topo-2)); }
.modal.fixo > .card { max-width: 400px; padding: 24px; }
.login-cab { text-align: center; margin-bottom: 16px; }
.login-cab .logo { font-size: 40px; width: 72px; height: 72px; border-radius: 50%; background: var(--pri-suave); display: grid; place-items: center; margin: 0 auto 8px; }
.login-cab h2 { margin: 4px 0; }
.login-cab p { margin: 0; }
.versao { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 0; }
.instalar-dica { text-align: center; font-size: 13px; margin: 0; }
.link-equipe { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.link-equipe img { width: 132px; height: 132px; image-rendering: pixelated; }
.link-equipe code { word-break: break-all; }
.link-equipe > div { flex: 1; min-width: 220px; }
.opcional { font-weight: 400; color: var(--muted); }

/* Fotos do cardápio */
.produto .foto { flex: none; width: 60px; height: 60px; border-radius: 10px; background: var(--suave) center/cover no-repeat; border: 0; padding: 0; min-height: 0; cursor: zoom-in; }
.vitrine .produto { align-items: flex-start; }
.vitrine .produto .foto { width: 96px; height: 96px; border-radius: 12px; }
.vitrine .produto .sem-foto { display: grid; place-items: center; font-size: 30px; cursor: default; opacity: .6; }
.vitrine .produto .qtd { align-self: center; }

/* Interruptor (liga/desliga) */
.chave { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: var(--txt); font-size: 15px; font-weight: 500; }
.chave input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chave .trilho { width: 46px; height: 26px; border-radius: 99px; background: #c4cddd; position: relative; transition: background .15s; flex: none; }
.chave .trilho::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.chave input:checked + .trilho { background: var(--pri); }
.chave input:checked + .trilho::after { transform: translateX(20px); }
.chave input:focus-visible + .trilho { outline: 2px solid var(--pri); outline-offset: 2px; }

/* Tabelas e listas de cadastro */
.tabela { width: 100%; border-collapse: collapse; }
.tabela th, .tabela td { padding: 10px 8px; border-bottom: 1px solid var(--borda); text-align: left; vertical-align: middle; }
.tabela th { font-size: 13px; color: var(--muted); font-weight: 600; }
.tabela tr.inativo td { opacity: .5; }
.tabela .acoes-linha { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.tabela .acoes-linha button { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.rolagem { overflow-x: auto; }
.miniatura { width: 48px; height: 48px; border-radius: 8px; background: var(--suave) center/cover no-repeat; display: grid; place-items: center; font-size: 20px; }
.grade-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.ajuda { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.preview-foto { width: 100%; aspect-ratio: 4/3; border-radius: 12px; background: var(--suave) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--borda); }
.status-imp { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.status-imp.impresso { background: var(--livre-suave); color: var(--livre); }
.status-imp.erro { background: var(--alerta-suave); color: var(--alerta); }
.status-imp.pendente { background: var(--ocupada-suave); color: #8a5700; }
#som { font-size: 18px; padding: 6px 10px; }

/* Tema escuro (o app aplica data-tema="escuro" ou "claro"; sem escolha segue o sistema) */
:root[data-tema="escuro"] { --bg: #0b1222; --card: #131c31; --txt: #e8eefc; --muted: #93a3c2; --borda: #26324d; --suave: #1a2540;
    --pri: #3d7cf0; --pri-esc: #8db4ff; --pri-suave: #1b2c52; --topo-1: #050b19; --topo-2: #1a4aa8;
    --livre-suave: #133325; --ocupada-suave: #3a2a0c; --conta-suave: #2a1f4a; --alerta-suave: #3d1519;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3); }
[data-tema="escuro"] input, [data-tema="escuro"] select, [data-tema="escuro"] textarea { background: #0f1729; }
[data-tema="escuro"] header.topo select { background: #e8eefc; color: #0b1222; }
[data-tema="escuro"] button:hover { border-color: #3a4a6d; }
[data-tema="escuro"] .st.preparo { color: #ffc861; } [data-tema="escuro"] .st.pronto { color: #8fe0ae; }
[data-tema="escuro"] .aviso { border-color: #5a2228; } [data-tema="escuro"] .aviso.azul { border-color: #2a4170; }
[data-tema="escuro"] button.whats, [data-tema="escuro"] a.whats { background: #12331f; color: #7fe0a6; }
[data-tema="escuro"] button.pri:hover { background: #2f6be0; }
[data-tema="escuro"] .chave .trilho { background: #3a4a6d; }

@media print { header.topo, .nao-imprimir { display: none !important; } body { background: #fff; } }
.logo-preview { width: 110px; height: 80px; flex: none; border-radius: 10px; background: #fff center/contain no-repeat; display: grid; place-items: center; color: #888; border: 1px dashed var(--borda); font-size: 13px; }
#ativar-som { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30; box-shadow: 0 6px 24px rgba(0, 0, 0, .3); max-width: calc(100% - 32px); }
.aviso.laranja { background: var(--ocupada-suave); color: var(--ocupada); border-color: transparent; }
.aviso.laranja.piscar { animation-name: piscar-laranja; }
@keyframes piscar-laranja { 50% { background: var(--ocupada); color: #fff; border-color: var(--ocupada); } }
.aviso.verde.piscar { animation-name: piscar-verde; }
@keyframes piscar-verde { 50% { background: var(--livre); color: #fff; border-color: var(--livre); } }
.ticket.aguardando { animation: ticket-piscar 1s steps(1) infinite; }
@keyframes ticket-piscar { 50% { box-shadow: 0 0 0 4px var(--ocupada); } }
.horario-dias { display: grid; gap: 6px; }
.horario-dia { align-items: center; flex-wrap: wrap; }
.horario-dia .chave { min-width: 130px; }
.horario-dia input[type=time] { width: auto; min-width: 0; }
header.topo .relogio { flex: none; white-space: nowrap; font-size: 15px; opacity: .9; text-align: right; line-height: 1.15; }
header.topo .relogio b { font-size: 18px; margin-left: 4px; }
@media (max-width: 700px) { header.topo .relogio .data { display: none; } header.topo .relogio b { font-size: 15px; margin: 0; } }
@media (max-width: 380px) { header.topo .relogio { display: none; } }
.tamanhos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
