:root {
  --bg: #f2f7fb;
  --surface: #ffffff;
  --surface-2: #e8f2f9;
  --ink: #0f2a3d;
  --ink-2: #3b566b;
  --ink-3: #6a8196;
  --line: #d6e4ee;
  --accent: #0077b6;
  --accent-ink: #ffffff;
  --accent-soft: #dff0fa;
  --topo-1: #005f94;
  --topo-2: #0083c4;
  --bar: #0d9fd7;
  --ok: #217a45;
  --ok-soft: #e1f3e7;
  --warn: #9a5700;
  --warn-soft: #fff1d6;
  --err: #b3261e;
  --err-soft: #fde7e5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 50, 90, .06), 0 4px 14px rgba(0, 50, 90, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1620; --surface: #11212d; --surface-2: #192c3a; --ink: #e7f2f9; --ink-2: #a8c1d2; --ink-3: #7690a4;
    --line: #233a4b; --accent: #4cc0f0; --accent-ink: #032033; --accent-soft: #0f3550; --topo-1: #08324d; --topo-2: #0a4a70;
    --bar: #3fb4e8; --ok: #6cc28f; --ok-soft: #133022; --warn: #f0b04f; --warn-soft: #3a2a10; --err: #f2867e; --err-soft: #3d1b18;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1620; --surface: #11212d; --surface-2: #192c3a; --ink: #e7f2f9; --ink-2: #a8c1d2; --ink-3: #7690a4;
  --line: #233a4b; --accent: #4cc0f0; --accent-ink: #032033; --accent-soft: #0f3550; --topo-1: #08324d; --topo-2: #0a4a70;
  --bar: #3fb4e8; --ok: #6cc28f; --ok-soft: #133022; --warn: #f0b04f; --warn-soft: #3a2a10; --err: #f2867e; --err-soft: #3d1b18;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 4px 0 14px; }
h2 { font-size: 1.05rem; margin: 22px 0 10px; color: var(--ink-2); }
small, .muted { color: var(--ink-3); }

/* topo */
.topo {
  position: sticky; top: 0; z-index: 10; color: #fff;
  background: linear-gradient(100deg, var(--topo-1), var(--topo-2));
  display: flex; align-items: center; justify-content: space-between; padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top));
}
.topo .marca { font-weight: 800; color: #fff; display: flex; gap: 10px; align-items: center; letter-spacing: .02em; }
.topo .marca img { width: 36px; height: 36px; border-radius: 50%; border: 2px solid rgba(255,255,255,.85); }
.topo .user { font-size: .85rem; color: rgba(255,255,255,.9); }

main { max-width: 760px; margin: 0 auto; padding: 16px; }

/* menu inferior */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 9px;
  color: var(--ink-3); font-size: .72rem; position: relative;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.ativo { color: var(--accent); }
.nav a.venda span.circ {
  background: var(--accent); color: var(--accent-ink); width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; margin-top: -18px; box-shadow: var(--shadow);
}
.badge {
  position: absolute; top: 4px; right: calc(50% - 20px); background: var(--err); color: #fff;
  border-radius: 10px; font-size: .68rem; min-width: 18px; padding: 0 5px; text-align: center; line-height: 18px;
}

/* cartoes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat .rot { font-size: .8rem; color: var(--ink-3); }
.stat .val { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .8rem; color: var(--ink-2); }
.alerta { border-left: 4px solid var(--warn); background: var(--warn-soft); }
.alerta-ok { border-left: 4px solid var(--ok); background: var(--ok-soft); }

/* listas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lista li:last-child { border-bottom: 0; }
.lista .tit { font-weight: 600; }
.lista .dir { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
a.linha { display: flex; color: inherit; }

/* tabela */
.tabela-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: .78rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* formularios */
label { display: block; font-size: .88rem; color: var(--ink-2); margin: 12px 0 5px; font-weight: 600; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input.invalido { border-color: var(--err); background: var(--err-soft); }
.dica { font-size: .8rem; color: var(--ink-3); margin-top: 4px; min-height: 1em; }
.dica.ok { color: var(--ok); }
.dica.erro { color: var(--err); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  padding: 13px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer; min-height: 48px; text-align: center;
}
.btn.prim { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.perigo { color: var(--err); border-color: var(--err); }
.btn.peq { padding: 7px 12px; min-height: 36px; font-size: .88rem; }
.btn.bloco { width: 100%; margin-top: 16px; }
.acoes { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 14px; }
.acoes .btn { flex: 1 1 140px; }

/* chips de escolha (radio estilizado) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips input { position: absolute; opacity: 0; width: 0; height: 0; }
.chips label {
  margin: 0; padding: 11px 15px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface);
  color: var(--ink); font-weight: 600; cursor: pointer; min-height: 44px; display: flex; align-items: center;
}
.chips input:checked + label { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* flash */
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 500; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.erro { background: var(--err-soft); color: var(--err); }

/* tags */
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); }
.tag.pago { background: var(--ok-soft); color: var(--ok); }
.tag.pendente { background: var(--warn-soft); color: var(--warn); }
.tag.cancelada { background: var(--err-soft); color: var(--err); }
.tag.pronto { background: var(--warn-soft); color: var(--warn); }

/* busca autocomplete */
.sugestoes { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.sugestoes li { padding: 11px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.sugestoes li:last-child { border-bottom: 0; }
.sugestoes li:hover, .sugestoes li:focus { background: var(--surface-2); }

/* carrinho */
.item-carrinho { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.total-venda { display: flex; justify-content: space-between; font-size: 1.3rem; font-weight: 700; padding: 12px 0 2px; }
.passo { display: flex; gap: 8px; align-items: center; margin: 18px 0 8px; font-weight: 700; }
.passo b { background: var(--accent); color: var(--accent-ink); border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; font-size: .85rem; }

/* barras (serie unica) */
.barras { display: grid; gap: 7px; }
.barra-lin { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 8px; font-size: .86rem; }
.barra-lin .rot { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-lin .trilho { height: 14px; position: relative; }
.barra-lin .fill { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.barra-lin .v { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.barra-lin:hover .fill { filter: brightness(1.1); }

.menu-mais a { display: flex; justify-content: space-between; padding: 15px 4px; border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 500; }
.filtro { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.filtro label { margin-top: 0; }
.vazio { text-align: center; color: var(--ink-3); padding: 18px 0; }
.login-box { max-width: 380px; margin: 9vh auto 0; }
.login-box .logo { text-align: center; margin-bottom: 14px; }
.login-box .logo img { width: 150px; height: 150px; border-radius: 26px; box-shadow: var(--shadow); border: 3px solid var(--surface); }

@media (min-width: 700px) {
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 380px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .barra-lin { grid-template-columns: 74px 1fr auto; }
}

/* evita estouro horizontal: filhos de grid podem encolher; tabelas lado a lado empilham no celular */
.grid2 > *, .grid3 > *, .filtro > * { min-width: 0; }
input[type="date"] { min-width: 0; }
.duo { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 700px) { .duo { grid-template-columns: 1fr 1fr; } }

/* ---------- pagina publica (Faca seu pedido) ---------- */
body.publico { padding-bottom: 24px; }
body.publico.com-barra { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.hero { text-align: center; padding: 18px 0 6px; }
.hero img { width: 140px; height: 140px; border-radius: 26px; box-shadow: var(--shadow); border: 3px solid var(--surface); }
.hero h1 { font-size: 1.6rem; margin: 14px 0 4px; color: var(--accent); }
.hero p { margin: 0; color: var(--ink-2); }
.rodape-pub { text-align: center; font-size: .82rem; color: var(--ink-3); margin-top: 26px; }
.rodape-pub a { color: var(--ink-3); text-decoration: underline; }
.prod-pub { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.prod-pub:last-child { border-bottom: 0; }
.prod-pub .info small { display: block; }
.stepper { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.stepper button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--accent); font-size: 1.35rem; font-weight: 700; cursor: pointer; line-height: 1; }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper input { width: 46px; text-align: center; padding: 9px 4px; font-weight: 700; }
.barra-pedido {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: center; justify-content: space-between;
}
.barra-pedido .tot { font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.barra-pedido .tot small { display: block; font-weight: 400; font-size: .75rem; color: var(--ink-3); }
.barra-pedido .btn { flex: 0 0 auto; margin: 0; }
.ok-check { width: 74px; height: 74px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 10px auto; font-size: 2.4rem; }

/* botao "Faca seu pedido" na tela de login */
.pedir-card { text-align: center; margin-top: 18px; background: var(--accent-soft); border-color: var(--accent); }
.pedir-tit { font-weight: 700; color: var(--ink-2); }
.btn.pedir { background: var(--ok); border-color: var(--ok); color: #fff; font-size: 1.2rem; min-height: 58px; margin-top: 10px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.pedir { color: #0b1f14; } }
:root[data-theme="dark"] .btn.pedir { color: #0b1f14; }
