:root {
  color-scheme: light;
  --bg: #f3f2ef;
  --surface: #fcfcfb;
  --surface-2: #efeeea;
  --border: #e2e0da;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7b7a75;
  --accent: #2a78d6;
  --mesa: #2a78d6;
  --entrega: #eb6834;
  --balcao: #1baf7a;
  --aberto: #b9b7af;
  --good: #1a7f37;
  --warn: #9a6700;
  --bad: #c62828;
  --grid: #e7e5df;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #2e2e2b;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #3987e5;
    --mesa: #3987e5;
    --entrega: #d95926;
    --balcao: #199e70;
    --aberto: #55544f;
    --good: #4cc26a;
    --warn: #e0a72a;
    --bad: #ef6b6b;
    --grid: #2a2a27;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #242422; --border: #2e2e2b;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86; --accent: #3987e5;
  --mesa: #3987e5; --entrega: #d95926; --balcao: #199e70; --aberto: #55544f;
  --good: #4cc26a; --warn: #e0a72a; --bad: #ef6b6b; --grid: #2a2a27;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.erro { color: var(--bad); min-height: 1.4em; }

/* login */
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; text-align: center; }
.login h1 { margin: 12px 0 4px; font-size: 22px; }
.login form { display: flex; flex-direction: column; gap: 10px; width: min(280px, 100%); margin-top: 12px; }
.login input { padding: 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); text-align: center; font-size: 22px; letter-spacing: 6px; }
.login button[type="submit"] { padding: 14px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; }
.login form { width: min(340px, 100%); }
.login #passoPin { display: flex; flex-direction: column; gap: 10px; }
.login .busca-op { text-align: left; letter-spacing: normal; }
.busca-op { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 16px; margin-bottom: 8px; }
.lista-op { max-height: 46dvh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; text-align: left; }
.lista-op button { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; border: 0; border-top: 1px solid var(--border); background: none; font-size: 15px; cursor: pointer; }
.lista-op button:first-child { border-top: 0; }
.lista-op button:active, .lista-op button:hover { background: var(--surface-2); }
.lista-op small, .op-escolhido small { color: var(--muted); font-size: 12px; }
.lista-op .ultimo { font-weight: 600; }
.op-escolhido { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 16px; font-weight: 600; cursor: pointer; }
.op-escolhido::after { content: "trocar"; font-size: 12px; font-weight: 400; color: var(--accent); }
.usuario { margin-left: auto; margin-right: 2px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; color: var(--text-2); cursor: pointer; }

/* topo */
.topo { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(10px + env(safe-area-inset-top)) 16px 8px; border-bottom: 1px solid var(--border); }
.topo-linha { display: flex; justify-content: space-between; align-items: center; }
.titulo { font-weight: 700; font-size: 17px; }
.sub { font-size: 12.5px; color: var(--text-2); }
.sub .ponto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 5px; vertical-align: 1px; }
.sub .ponto.off { background: var(--bad); }
.icone { background: none; border: 0; padding: 8px; border-radius: 10px; color: var(--text-2); cursor: pointer; }
.icone:active { background: var(--surface-2); }
.icone.girando svg { animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.datas { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.datas input { flex: 1; min-width: 0; padding: 6px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); white-space: nowrap; font-size: 13px; cursor: pointer; }
.chip.ativo { background: var(--text); color: var(--bg); border-color: var(--text); }

main { padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }

/* abas inferiores */
.abas { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.abas button { flex: 1; background: none; border: 0; padding: 8px 0 7px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); cursor: pointer; }
.abas svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.abas button.ativa { color: var(--accent); font-weight: 600; }

/* cartões */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; }
.hero-valor { font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.hero-linha { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; color: var(--text-2); font-size: 13.5px; }
.comparativo { font-size: 13px; margin-top: 8px; }
.sobe { color: var(--good); } .desce { color: var(--bad); }

.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.kpi .rot { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 22px; font-weight: 700; margin-top: 2px; }
.kpi .det { font-size: 12.5px; color: var(--text-2); }
.kpi.toque { cursor: pointer; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* barras horizontais */
.hbar { margin: 8px 0; }
.hbar-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.hbar-top span:last-child { font-weight: 600; white-space: nowrap; }
.hbar-trilho { height: 8px; background: var(--surface-2); border-radius: 4px; margin-top: 4px; display: flex; gap: 2px; overflow: hidden; }
.hbar-trilho i { display: block; height: 100%; border-radius: 4px; }
.hbar-sub { font-size: 12px; color: var(--muted); }

/* gráfico de colunas */
.grafico { position: relative; }
.grafico svg { width: 100%; height: auto; display: block; overflow: visible; }
.grafico .eixo { fill: var(--muted); font-size: 10.5px; }
.grafico .grid { stroke: var(--grid); stroke-width: 1; }
.legenda { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.legenda span { display: inline-flex; align-items: center; gap: 5px; }
.tooltip { position: fixed; z-index: 30; background: var(--text); color: var(--bg); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; pointer-events: none; max-width: 220px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.tooltip b { display: block; margin-bottom: 2px; }

/* listas */
.segmentado { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.segmentado button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 9px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.segmentado button.ativo { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.mesas-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mesa { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--mesa); border-radius: 14px; padding: 10px 12px; cursor: pointer; text-align: left; }
.mesa.pedida { border-left-color: var(--warn); }
.mesa .num { font-size: 13px; color: var(--text-2); }
.mesa .num b { font-size: 20px; color: var(--text); }
.mesa .valor { font-size: 18px; font-weight: 700; margin: 2px 0; }
.mesa .info { font-size: 12px; color: var(--muted); }

.lista { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; margin-bottom: 12px; }
.item { display: flex; gap: 10px; justify-content: space-between; padding: 11px 14px; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item .esq { min-width: 0; }
.item .t1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item .t2 { font-size: 12.5px; color: var(--text-2); }
.item .dir { text-align: right; white-space: nowrap; }
.item .dir .t1 { font-weight: 700; }
.vazio { padding: 22px 14px; text-align: center; color: var(--muted); }

.selo { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.selo.ok { color: var(--good); }
.selo.alerta { color: var(--warn); }
.selo.ruim { color: var(--bad); }

.busca { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 12px; font-size: 16px; }
.aviso { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.carregando { padding: 40px 0; text-align: center; color: var(--muted); }

/* modal */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal-caixa { background: var(--bg); width: 100%; max-width: 640px; max-height: 85dvh; overflow: auto; border-radius: 18px 18px 0 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
.modal-topo { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 17px; }
