:root {
  --bg: #fbf6ef;
  --surface: #ffffff;
  --surface-2: #f5ede2;
  --ink: #2a1d17;
  --ink-2: #5c4a40;
  --muted: #8a7a70;
  --line: #e6dccf;
  --marca: #a3262a;  /* trocada pela cor da marca (Cadastros > Marca) */
  --marca2: #6a9a3e;
  --brand: var(--marca);
  --brand-ink: #ffffff;
  --brand-soft: color-mix(in srgb, var(--marca) 14%, #ffffff);
  --ok: #2f6b3a;
  --ok-soft: #dcefdc;
  --warn: #9a5b00;
  --warn-soft: #fbe9c8;
  --bad: #a3262a;
  --bad-soft: #f8dcda;
  --info-soft: #e4ecf5;
  --bar: #c0592f;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(42, 29, 23, .08), 0 4px 16px rgba(42, 29, 23, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1512; --surface: #261d19; --surface-2: #30251f; --ink: #f5ece4; --ink-2: #d4c4b8; --muted: #a8968a;
    --line: #43352d; --brand: color-mix(in srgb, var(--marca) 62%, #ffffff); --brand-ink: #1c1512; --brand-soft: color-mix(in srgb, var(--marca) 32%, #1c1512); --ok: #8fd49a; --ok-soft: #1f3a24;
    --warn: #f0b75a; --warn-soft: #43321a; --bad: #f08a85; --bad-soft: #4a2523; --info-soft: #23303d; --bar: #e8875c;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1512; --surface: #261d19; --surface-2: #30251f; --ink: #f5ece4; --ink-2: #d4c4b8; --muted: #a8968a;
  --line: #43352d; --brand: color-mix(in srgb, var(--marca) 62%, #ffffff); --brand-ink: #1c1512; --brand-soft: color-mix(in srgb, var(--marca) 32%, #1c1512); --ok: #8fd49a; --ok-soft: #1f3a24;
  --warn: #f0b75a; --warn-soft: #43321a; --bad: #f08a85; --bad-soft: #4a2523; --info-soft: #23303d; --bar: #e8875c;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 8px 16px; flex-wrap: wrap;
}
.brand { font-weight: 800; letter-spacing: .06em; color: var(--brand); font-size: 1.1rem; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; }
.brand img { height: 40px; width: auto; display: block; }
.login .brand img { height: auto; width: 100%; max-width: 260px; margin: 0 auto; }
/* no escuro o logo ganha um fundo claro (logos costumam ser feitos para fundo branco) */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand img { background: #fbf6ef; border-radius: 8px; padding: 2px 8px; } }
:root[data-theme="dark"] .brand img { background: #fbf6ef; border-radius: 8px; padding: 2px 8px; }
.marca-previa { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 12px; background: var(--surface-2); border-radius: 8px; margin-bottom: 12px; }
.marca-previa img.logo { max-height: 70px; max-width: 260px; }
.marca-previa img.icone { width: 64px; height: 64px; border-radius: 14px; }
.cor-campo { display: flex; gap: 8px; align-items: center; }
.cor-campo input[type=color] { width: 48px; height: 38px; padding: 2px; flex: 0 0 auto; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1 1 auto; scrollbar-width: none; }
.nav a {
  text-decoration: none; color: var(--ink-2); padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-weight: 600; font-size: .95rem;
}
.nav a:hover { background: var(--surface-2); }
.nav a.ativo { background: var(--brand-soft); color: var(--brand); }
.topo-dir { display: flex; align-items: center; gap: 10px; }
.status-impressora { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: #2f9e44; }
.dot.off { background: #c92a2a; }
.loja-aberta { display: inline-flex; align-items: center; gap: 6px; }
button.abrir-loja { background: #2f9e44; border-color: #2f9e44; color: #fff; }
button.abrir-loja:hover { background: #2b8a3e; }

main { max-width: 1280px; margin: 0 auto; padding: 16px; }
.cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cab .acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- controles ---------- */
button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; white-space: nowrap; min-height: 38px;
}
button:hover, .btn:hover { background: var(--surface-2); }
button.prim, .btn.prim { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.prim:hover { filter: brightness(1.08); }
button.grande { padding: 12px 20px; font-size: 1.05rem; }
button.peq { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
button.perigo { color: var(--bad); }
button.fantasma { border-color: transparent; background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; min-height: 38px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.campo { margin-bottom: 12px; }
.linha { display: flex; gap: 10px; flex-wrap: wrap; }
.linha > * { flex: 1 1 160px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; cursor: pointer; }
.check input { width: auto; min-height: auto; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg button { padding: 6px 12px; min-height: 34px; font-weight: 600; }
.seg button.sel { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ---------- cartões e tabelas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tabela-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; background: var(--surface); position: sticky; top: 0; }
tr.total td { font-weight: 800; border-top: 2px solid var(--ink-2); }
tr.clicavel { cursor: pointer; }
tr.clicavel:hover td { background: var(--surface-2); }
td input, td select { min-height: 34px; padding: 5px 8px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tile .rot { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.tile .val { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .sub { font-size: .82rem; color: var(--muted); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--ink-2); }
button.chip { min-height: 28px; cursor: pointer; }

.barra { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.barra .trilho { flex: 1; height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.barra .preench { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; }

/* ---------- pedidos ---------- */
.abas-dia { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.abas-dia button { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.2; padding: 8px 14px; }
.abas-dia button small { font-weight: 500; color: var(--muted); }
.abas-dia button.sel { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.abas-dia button.sel small { color: inherit; opacity: .85; }
.horarios { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.horarios .chip { font-size: .82rem; }

.pedidos { display: flex; flex-direction: column; gap: 10px; }
.pedido {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid; grid-template-columns: 74px 1fr auto; gap: 4px 14px; padding: 12px 14px; align-items: start;
}
.pedido.cancelado { opacity: .55; }
.pedido .num-hora { text-align: center; }
.pedido .num-hora .n { font-size: .82rem; color: var(--muted); font-weight: 700; }
.pedido .num-hora .h { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pedido .cli { font-weight: 800; font-size: 1.05rem; }
.pedido .itens { margin: 4px 0; }
.pedido .itens .pz { font-weight: 700; }
.pedido .end { color: var(--ink-2); font-size: .9rem; }
.pedido .lado { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.pedido .total { font-size: 1.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pedido .acoes { grid-column: 2 / 4; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 4px; }
.origem-ia { background: var(--info-soft); color: var(--ink-2); }
@media (max-width: 640px) {
  .pedido { grid-template-columns: 56px 1fr; }
  .pedido .lado { grid-column: 1 / 3; flex-direction: row; justify-content: space-between; align-items: center; text-align: left; }
  .pedido .acoes { grid-column: 1 / 3; justify-content: flex-start; }
}

/* ---------- gaveta / modal ---------- */
.fundo { position: fixed; inset: 0; background: rgba(20, 12, 8, .45); z-index: 50; display: flex; justify-content: flex-end; }
.gaveta { background: var(--bg); width: min(760px, 100%); height: 100%; display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0,0,0,.2); }
.gaveta .g-cab { padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.gaveta .g-corpo { padding: 16px 18px; overflow-y: auto; flex: 1; }
.gaveta .g-rodape { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.modal-centro { align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 18px; width: min(520px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.secao { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.secao h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); }
.item-linha { display: grid; grid-template-columns: 1fr 1fr 80px 38px; gap: 8px; margin-bottom: 8px; align-items: end; }
.item-linha.beb { grid-template-columns: 2fr 80px 38px; }
@media (max-width: 560px) { .item-linha { grid-template-columns: 1fr 1fr; } .item-linha.beb { grid-template-columns: 1fr 70px 38px; } }
.insight { background: var(--info-soft); border-radius: 8px; padding: 10px 12px; font-size: .9rem; margin-bottom: 12px; }
.insight b { font-weight: 800; }
.totais { display: flex; gap: 16px; flex-wrap: wrap; align-items: baseline; flex: 1; }
.totais .t { font-size: .85rem; color: var(--muted); }
.totais .t b { color: var(--ink); font-variant-numeric: tabular-nums; }
.totais .grande { font-size: 1.35rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }

/* menu suspenso */
.menu { position: relative; display: inline-block; }
.menu .lista { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); z-index: 30; min-width: 220px; padding: 4px; }
.menu .lista button { width: 100%; justify-content: flex-start; border: 0; }

/* avisos */
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 100; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.erro { background: var(--bad); color: #fff; }
.aviso { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-weight: 600; }
.vazio { text-align: center; padding: 40px 16px; color: var(--muted); }

/* login */
.login { max-width: 360px; margin: 10vh auto; }
.login .brand { display: block; text-align: center; font-size: 1.8rem; margin-bottom: 4px; }

/* DRE */
.dre td:first-child { width: 70%; }
.dre tr.sub td { font-weight: 800; background: var(--surface-2); }
.dre tr.res td { font-weight: 800; font-size: 1.1rem; background: var(--brand-soft); }
.dre tr.ind td:first-child { padding-left: 24px; color: var(--ink-2); }

/* abas internas */
.abas { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.abas a { padding: 8px 12px; text-decoration: none; color: var(--ink-2); font-weight: 600; border-bottom: 3px solid transparent; }
.abas a.ativo { color: var(--brand); border-bottom-color: var(--brand); }

.preview-cupom { background: #fff; color: #000; width: 80mm; max-width: 100%; padding: 10px; border: 1px solid var(--line); font-family: "Courier New", monospace; }
.lista-simples { list-style: none; margin: 0; padding: 0; }
.lista-simples li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }

/* ---------- gráficos ---------- */
.viz-cartao { width: 100%; }
.viz-box { width: 100%; }
svg.viz { display: block; overflow: visible; }
.viz-grade { stroke: var(--line); stroke-width: 1; }
.viz-base { stroke: var(--muted); stroke-width: 1; }
.viz-rot { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-ao-vivo { opacity: .55; }
.viz-legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); margin-bottom: 6px; }
.viz-legenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.viz-dica { position: fixed; z-index: 200; display: none; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: .85rem; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
.viz-dica-tit { font-weight: 800; margin-bottom: 2px; }
.viz-tabela { margin-top: 6px; font-size: .85rem; }
.viz-tabela summary { cursor: pointer; color: var(--muted); }
.viz-hbar { display: flex; flex-direction: column; gap: 8px; }
.viz-hbar-linha { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; }
.viz-hbar-nome { font-size: .9rem; }
.viz-hbar-trilho { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.viz-hbar-barra { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.viz-hbar-valor { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; font-size: .9rem; }
.viz-hbar-valor small { color: var(--muted); font-weight: 500; }
.var-pos { color: var(--ok); font-weight: 700; }
.var-neg { color: var(--bad); font-weight: 700; }
.insights li { margin-bottom: 6px; }

th.ordenavel { cursor: pointer; user-select: none; white-space: nowrap; }
th.ordenavel:hover { color: var(--ink); }
.seta { color: var(--brand); }
.tabela-ferr { display: flex; justify-content: flex-end; margin-bottom: 2px; }
.tile .info { cursor: help; color: var(--muted); font-weight: 600; }
.atualizado { font-size: .78rem; color: var(--muted); }
