:root {
  --bg: #F4F1EC;
  --panel: #FFFFFF;
  --ink: #1C1A17;
  --ink-2: #5E5850;
  --ink-3: #928A7F;
  --line: #E4DED4;
  --line-2: #EFEAE2;
  --side: #191714;
  --side-ink: #EDE7DD;
  --side-ink-2: #9B9386;
  --accent: #1F6F5C;
  --accent-ink: #FFFFFF;
  --good: #1F7A4D;
  --warn: #B86E00;
  --warn-bg: #FFF3DC;
  --bad: #C0362C;
  --bad-bg: #FDECEA;
  --ifood: #E3262F;
  --food99: #F2B705;
  --keeta: #1B8A7A;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 26, 23, .06), 0 4px 16px rgba(28, 26, 23, .05);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { display: grid; grid-template-columns: 232px 1fr; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- lateral ---------- */
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--side-ink); color: var(--side); display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.brand-name { font-weight: 700; font-size: 14px; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: var(--side-ink-2); }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-ink-2); text-decoration: none; font-size: 14px; }
nav a:hover { background: rgba(255,255,255,.05); color: var(--side-ink); }
nav a.on { background: rgba(255,255,255,.09); color: #fff; }
nav .ico { width: 18px; text-align: center; opacity: .8; }
.badge { margin-left: auto; background: var(--ifood); color: #fff; font-size: 11px; border-radius: 99px; padding: 1px 7px; font-weight: 700; }
.badge.warn { background: var(--warn); }
.conn { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding: 14px 8px 0; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.conn-row { display: flex; align-items: center; gap: 8px; color: var(--side-ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5A544C; flex: none; }
.dot.ok { background: #3CCB7F; box-shadow: 0 0 0 3px rgba(60,203,127,.15); }
.dot.err { background: #F0605A; }
.dot.off { background: #5A544C; }

/* ---------- topo ---------- */
main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 28px 14px; gap: 12px; flex-wrap: wrap; }
.top h1 { font-size: 22px; font-weight: 750; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.demo-pill { font-size: 12px; background: var(--warn-bg); color: var(--warn); padding: 4px 10px; border-radius: 99px; font-weight: 600; }
#view { padding: 0 28px 40px; }
.alert-bar { margin: 0 28px 14px; background: var(--warn-bg); border: 1px solid #F1D9A6; color: #6B4300; padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px; }
.alert-bar a { color: inherit; font-weight: 600; }
.sound-gate { margin: 0 28px 14px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px; cursor: pointer; }

/* ---------- botões e campos ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
a.btn { text-decoration: none; color: inherit; display: inline-block; }
.btn:hover { border-color: #CFC7BA; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.big { padding: 11px 18px; font-size: 15px; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
input, select, textarea { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 10px; font-size: 14px; font-weight: 400; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,111,92,.25); border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.hint { font-size: 12.5px; color: var(--ink-3); }
.muted { color: var(--ink-3); }

.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; z-index: 20; min-width: 150px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--bg); }

/* ---------- painel / cartões ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; font-size: 13px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.ch { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 800; letter-spacing: .02em; padding: 3px 8px; border-radius: 5px; text-transform: uppercase; }
.ch.ifood { background: var(--ifood); color: #fff; }
.ch.food99 { background: var(--food99); color: #1C1A17; }
.ch.keeta { background: var(--keeta); color: #fff; }

/* ---------- quadro de pedidos ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.col { background: #ECE7DF; border-radius: 12px; padding: 10px; min-height: 200px; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; font-weight: 700; font-size: 13.5px; }
.col-head .count { background: #fff; border-radius: 99px; padding: 1px 9px; font-size: 12px; }
.col.new { background: #FBE3DE; }
.col-empty { text-align: center; color: var(--ink-3); font-size: 13px; padding: 30px 8px; }
.order { background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line-2); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.order.fresh { animation: pulse 1.4s ease-in-out infinite; border-color: var(--ifood); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(227,38,47,.18); } }
.order-top { display: flex; align-items: center; gap: 8px; }
.order-id { font-weight: 800; font-size: 17px; }
.order-time { margin-left: auto; font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.order-time.late { color: var(--bad); font-weight: 700; }
.order-cust { font-size: 13.5px; color: var(--ink-2); margin: 6px 0 8px; }
.order-items { list-style: none; margin: 0; padding: 8px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); font-size: 14px; }
.order-items li { display: flex; gap: 8px; padding: 2px 0; }
.order-items .q { font-weight: 800; min-width: 26px; }
.order-items .obs { display: block; font-size: 12.5px; color: var(--warn); }
.order-items .opt { display: block; font-size: 12.5px; color: var(--ink-3); }
.unlinked { color: var(--bad); font-size: 12px; font-weight: 700; cursor: pointer; text-decoration: underline; }
.order-note { font-size: 12.5px; background: var(--warn-bg); color: #6B4300; border-radius: 6px; padding: 6px 8px; margin-top: 8px; }
.order-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 6px; flex-wrap: wrap; }
.order-total { font-weight: 800; font-variant-numeric: tabular-nums; }
.order-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.order-actions .btn { flex: 1; }
.status-tag { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--bg); color: var(--ink-2); }
.status-tag.CANCELLED { background: var(--bad-bg); color: var(--bad); }
.status-tag.CONCLUDED, .status-tag.DISPATCHED { background: #E3F2EA; color: var(--good); }
.sched { font-size: 12px; font-weight: 700; color: #5B3FB0; background: #EEE8FB; padding: 2px 7px; border-radius: 5px; }

/* ---------- tabelas ---------- */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #FAF8F4; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t td.r, .t th.r { text-align: right; font-variant-numeric: tabular-nums; }
.t tr.off td { color: var(--ink-3); }
.t .actions { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.lvl { width: 90px; height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.lvl > i { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.lvl.low > i { background: var(--bad); }
.lvl.mid > i { background: var(--warn); }
.pill { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.ok { background: #E3F2EA; color: var(--good); }
.pill.neutral { background: var(--bg); color: var(--ink-2); }

/* ---------- KPIs e gráfico ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { padding: 14px 16px; }
.kpi .l { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.kpi .v { font-size: 24px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .s { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .tip { position: fixed; pointer-events: none; background: var(--ink); color: #fff; padding: 6px 9px; border-radius: 6px; font-size: 12.5px; z-index: 50; }

/* ---------- modal e avisos ---------- */
.modal { position: fixed; inset: 0; background: rgba(25,23,20,.45); display: grid; place-items: center; z-index: 40; padding: 20px; }
.modal-card { background: #fff; border-radius: 14px; width: min(760px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 18px 20px 20px; overflow: auto; }
.x { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--ink-3); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 11px 15px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); max-width: 380px; }
.toast.err { background: var(--bad); }
.recipe-row { display: grid; grid-template-columns: 1fr 120px 70px 90px 34px; gap: 8px; align-items: center; margin-bottom: 6px; }
.map-row { display: grid; grid-template-columns: 130px 1fr 34px; gap: 8px; margin-bottom: 6px; }
.section-t { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin: 18px 0 10px; }
.cols-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.label-preview { background: #D9D3C8; border-radius: 10px; padding: 24px; display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: flex-start; }
.label-preview .lbl { zoom: 1.7; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.log { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; max-height: 320px; overflow: auto; }
.log div { padding: 4px 0; border-bottom: 1px solid var(--line-2); }
.log .error { color: var(--bad); }
.log .warn { color: var(--warn); }
code { word-break: break-all; background: var(--bg); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
#printFrame { position: fixed; width: 0; height: 0; border: 0; right: 0; bottom: 0; }
.empty { text-align: center; padding: 40px; color: var(--ink-3); }

@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; gap: 6px; }
  .brand { padding: 4px; }
  nav { flex-direction: row; flex-wrap: wrap; }
  nav a { padding: 7px 9px; font-size: 13px; }
  .conn { display: none; }
  .top, #view { padding-left: 14px; padding-right: 14px; }
  .alert-bar, .sound-gate { margin-left: 14px; margin-right: 14px; }
  .board, .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}

/* ---------- login, instalação, usuário ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; grid-template-columns: 1fr; padding: 24px 16px; }
.auth-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; width: min(400px, 100%); }
.auth-box.wide { width: min(640px, 100%); }
.auth-box h1 { font-size: 22px; margin: 18px 0 14px; }
.auth-box form { display: block; }
.auth-box .btn { display: inline-block; text-align: center; text-decoration: none; }
.auth-brand { display: flex; gap: 10px; align-items: center; }
.auth-brand .brand-mark { background: var(--side); color: var(--side-ink); }
.notice { border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.warn { background: var(--warn-bg); color: #6B4300; }
.reqs { list-style: none; padding: 0; margin: 0 0 8px; font-size: 14px; }
.reqs li { padding: 2px 0; }
.reqs .ok { color: var(--good); }
.reqs .bad { color: var(--bad); font-weight: 700; }
.alert-bar.bad { background: var(--bad-bg); border-color: #F3C4BF; color: var(--bad); }
.me { border-top: 1px solid rgba(255,255,255,.08); margin-top: 12px; padding: 12px 8px 0; font-size: 13px; color: var(--side-ink); display: flex; flex-direction: column; gap: 6px; }
.me .hint { color: var(--side-ink-2); }
.me-actions { display: flex; gap: 12px; }
.me-actions form { margin: 0; }
button.link { background: none; border: 0; padding: 0; color: var(--side-ink-2); cursor: pointer; font-size: 12.5px; text-decoration: underline; }
button.link:hover { color: #fff; }
@media (max-width: 760px) { .me { display: none; } }
