/* Estilo do painel. Identidade "o." do Manual visual Coolin, paleta P1 (cacau e amarelo-gema), v0 de 15/10/2026.
   Só existem as cores do manual: papel, cacau, canela, pedra, amarelo-gema e, no escuro, fundo escuro, texto escuro e secundário.
   Cartão e linha são misturas de texto sobre fundo (5% e 16%), como no manual. O gema é só fundo ou preenchimento, nunca texto
   (no escuro o manual usa o gema também nos links). Aviso, erro e pendência: fundo gema, texto cacau (9,6:1) e um ícone; o manual
   ainda não define uma cor de erro na P1. Nada de vermelho, laranja ou verde: pendente, pago e erro se diferenciam pelo
   formato do selo (anel, ✓, ✕), não por cor nova.
   Layout: menu lateral fixo + área de trabalho; no celular o menu vira uma faixa rolável no topo. */
:root {
  --font: "Public Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  --paper: #FBF7F0;      /* papel */
  --ink: #2E2019;        /* cacau */
  --link: #8A4B14;       /* canela */
  --muted: #6B5E55;      /* pedra */
  --fill: #F5C518;       /* amarelo-gema: só fundo ou preenchimento */
  --on-fill: #2E2019;
  --on-link: #FBF7F0;
  --card: color-mix(in srgb, var(--ink) 5%, var(--paper));
  --line: color-mix(in srgb, var(--ink) 16%, var(--paper));
  --mark: var(--ink);
  --tit: var(--ink);
  --btn-bg: var(--ink);
  --btn-ink: var(--paper);
  --scrim: rgba(27, 20, 17, .55);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1B1411; --ink: #F6EDE0; --link: #F5C518; --muted: #B9A99A; --fill: #F5C518; --on-fill: #2E2019;
    --on-link: #2E2019; --mark: var(--fill); --tit: var(--fill); --btn-bg: var(--fill); --btn-ink: var(--on-fill);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1B1411; --ink: #F6EDE0; --link: #F5C518; --muted: #B9A99A; --fill: #F5C518; --on-fill: #2E2019;
  --on-link: #2E2019; --mark: var(--fill); --tit: var(--fill); --btn-bg: var(--fill); --btn-ink: var(--on-fill);
  color-scheme: dark;
}

html, body { height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; font-weight: 400; }
* { box-sizing: border-box; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.wm { display: block; height: 26px; width: auto; color: var(--ink); flex: none; overflow: visible; }

.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
nav.side { background: var(--paper); color: var(--ink); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: env(safe-area-inset-top, 0px); align-self: start; height: 100vh; height: 100dvh; overflow-y: auto; }
.brand { padding: 4px 10px; }
.brand b { display: block; }
.brand span { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.menu { display: flex; flex-direction: column; gap: 4px; }
.menu button { background: none; border: 0; text-align: left; padding: 10px 12px; border-radius: 10px; color: var(--muted); cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; }
.menu button:hover { background: var(--card); color: var(--ink); }
.menu button[aria-current="page"] { background: var(--card); color: var(--ink); box-shadow: inset 3px 0 0 var(--link); }
.badge { background: var(--fill); color: var(--on-fill); font-size: 12px; font-weight: 600; min-width: 22px; text-align: center; padding: 1px 7px; border-radius: 999px; }
.me { margin-top: auto; font-size: 13px; color: var(--muted); padding: 12px 10px 4px; border-top: 1px solid var(--line); }

main { padding: 28px clamp(16px, 3vw, 36px) 56px; min-width: 0; }
.notice a { color: inherit; font-weight: 700; }
.notice.plan { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.notice { background: var(--fill); color: var(--on-fill); border-radius: 12px; padding: 10px 14px; font-size: 13.5px; font-weight: 600; margin-bottom: 22px; }
h1 { font-size: clamp(22px, 3vw, 28px); letter-spacing: -.03em; margin: 0 0 4px; font-weight: 700; line-height: 1.12; text-wrap: balance; }
.lede { color: var(--muted); margin: 0 0 24px; max-width: 62ch; }

.stats { display: flex; flex-wrap: wrap; gap: 0 22px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.stat { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 2px; margin-bottom: -1px; min-width: 0; cursor: pointer; text-align: left; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.stat:hover { color: var(--ink); }
.stat[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.stat small { display: inline; font-size: 14px; font-weight: 600; color: inherit; }
.stat strong { font-size: 12px; font-weight: 600; line-height: 20px; min-width: 22px; text-align: center; padding: 0 7px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-variant-numeric: tabular-nums; }
.stat[aria-pressed="true"] strong { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* fila: o valor que espera decisão vem primeiro */
.queue { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 24px; margin: 0 0 22px; padding: 2px 0 2px 16px; border-left: 3px solid var(--link); }
.queue .sub { display: block; font-size: 13.5px; }
.queue b { display: block; font-size: clamp(30px, 4vw, 42px); font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.queue.clear { border-left-color: var(--line); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.tablewrap { overflow: hidden; overflow-x: auto; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: color-mix(in srgb, var(--ink) 3%, var(--card)); }
td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.r b { font-size: 16px; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
tr.row { cursor: pointer; }
tr.row:hover td { background: var(--paper); }
td.r, th.r { text-align: right; }
.who { font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; }

/* Selos de situação: a forma diz o que é. Anel = esperando; ✓ = concluído; ✕ = precisa de atenção; mar cheio = aprovado. */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.p-submitted { background: transparent; color: var(--muted); border-color: var(--line); }
.p-warn { background: var(--fill); color: var(--on-fill); }
.p-submitted::before, .p-warn::before { background: transparent; border: 2px solid currentColor; width: 9px; height: 9px; }
.p-approved { background: var(--link); color: var(--on-link); }
.p-paid, .p-ok { background: var(--ink); color: var(--paper); }
.p-paid::before, .p-ok::before { content: "✓"; width: auto; height: auto; background: none; font-size: 11px; line-height: 1; }
.p-rejected, .p-failed, .p-bad { background: var(--fill); color: var(--on-fill); border-color: var(--on-fill); }
.p-rejected::before, .p-failed::before, .p-bad::before { content: "✕"; width: auto; height: auto; background: none; font-size: 11px; line-height: 1; }
.p-muted { background: transparent; color: var(--muted); border-color: var(--line); }

.btn { border: 1px solid var(--line); background: transparent; padding: 8px 14px; border-radius: 12px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-ink); }
.btn.primary:hover { filter: brightness(.92); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--ink); border-color: var(--ink); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.section-title { font-size: 16px; font-weight: 700; margin: 26px 0 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.msg { padding: 10px 14px; border-radius: 12px; font-weight: 600; font-size: 14px; margin: 0 0 14px; }
.msg.ok { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.msg.ok::before { content: "✓ "; }
.msg.info { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.msg.err { background: var(--fill); color: var(--on-fill); }
.msg.err::before { content: "✕ "; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }
.list { padding: 6px 0; }
.item { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.item:last-child { border-bottom: 0; }
.item .main { min-width: 0; flex: 1 1 260px; }

.keydiff { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13.5px; margin-top: 6px; }
.keydiff dt { color: var(--muted); }
.keydiff dd { margin: 0; word-break: break-all; }
.keydiff .new { color: var(--link); font-weight: 600; }

/* gaveta de detalhe do pedido */
.scrim { position: fixed; inset: 0; background: var(--scrim); display: flex; justify-content: flex-end; z-index: 20; }
.drawer { background: var(--paper); border-left: 1px solid var(--line); width: min(460px, 100%); height: 100%; overflow-y: auto; padding: 22px 22px calc(28px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }
.drawer:focus { outline: none; }
.drawer h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.close { align-self: flex-end; }
dl.facts { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 13.5px; }
dl.facts dd { margin: 0; font-weight: 600; }
.receipt { border: 1px dashed var(--muted); border-radius: 12px; padding: 16px; background: var(--card); }
.cupom { background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; max-width: 260px; margin: 0 auto; }
.cupom hr { border: 0; border-top: 1px dashed var(--muted); margin: 8px 0; }
.cupom .tot { display: flex; justify-content: space-between; font-weight: 700; }
.timeline { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.timeline li { color: var(--muted); }
.timeline b { color: var(--ink); }
.reason { display: flex; flex-direction: column; gap: 8px; }
.reason textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--paper); resize: vertical; min-height: 70px; font: inherit; color: inherit; }

.qr { width: 190px; height: 190px; align-self: center; border-radius: 12px; background: #FBF7F0; padding: 8px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.45; }
.check-row input { margin-top: 3px; accent-color: var(--link); }
.check-row a { color: var(--link); font-weight: 600; }
.check { width: 18px; height: 18px; accent-color: var(--link); }

/* cadastro da empresa e retorno do banco */
.formgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.formgrid .c2 { grid-column: span 2; } .formgrid .c3 { grid-column: span 3; } .formgrid .c4 { grid-column: span 4; } .formgrid .c6 { grid-column: span 6; }
.field input.bad { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--fill); color: var(--on-fill); }
.box { border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.box h3 { margin: 0; font-size: 16px; font-weight: 700; }
.box.warn { background: var(--fill); color: var(--on-fill); }
.box.warn .sub, .box.bad .sub { color: var(--on-fill); }
.box.neutral { background: var(--card); border: 1px solid var(--line); }
.box.bad { background: var(--fill); color: var(--on-fill); border: 1px solid var(--on-fill); }
.box.warn .btn, .box.bad .btn { border-color: var(--on-fill); color: var(--on-fill); }
.box.warn .btn.primary, .box.bad .btn.primary { background: var(--on-fill); color: var(--fill); }
.res { display: flex; gap: 12px; align-items: flex-start; }
.res .dot { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--line); }
.res .dot.ok { background: var(--ink); color: var(--paper); }
.res .dot.bad { background: var(--fill); color: var(--on-fill); border: 1px solid var(--on-fill); }
.res .dot.warn { background: var(--fill); color: var(--on-fill); }
.res b { display: block; }
.res span { color: var(--muted); font-size: 13.5px; }
.dup { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.count { background: var(--fill); color: var(--on-fill); font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.sim { border: 1px dashed var(--muted); border-radius: 14px; padding: 14px 16px; margin-top: 22px; }
@media (max-width: 820px) { .formgrid .c2, .formgrid .c3, .formgrid .c4 { grid-column: span 6; } }

@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  nav.side { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { flex: none; }
  .brand span { display: none; }
  .menu { flex-direction: row; flex: none; }
  .menu button { white-space: nowrap; }
  /* No celular o "Sair" continua na faixa do menu (antes o bloco inteiro sumia e não havia como sair). */
  .me { flex: none; margin: 0; padding: 0 4px; border: 0; white-space: nowrap; }
  .me br { display: none; }
  .me button { margin-left: 8px; }
  dl.facts { grid-template-columns: 120px 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .drawer { animation: slide .18s ease-out; }
  @keyframes slide { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}

/* ---------- telas de entrada (login, código, empresa nova, convite) ---------- */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate .card { width: min(440px, 100%); padding: 28px 26px; display: flex; flex-direction: column; gap: 16px; }
.gate h1 { font-size: 24px; }
.gate .lede { margin: 0; }
.gate form { display: flex; flex-direction: column; gap: 14px; }
.gate .btn.primary { padding: 11px 16px; }
.gate .field input { padding: 11px 12px; }
.code-input { letter-spacing: .4em; font-size: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.wordmark { color: var(--ink); display: flex; align-items: center; }
.wordmark .wm { height: 30px; }
.linkbox { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.linkbox input { flex: 1 1 260px; font-size: 13px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.topbar { display: flex; justify-content: flex-end; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.topbar select { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; }
.me button { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 0; font-size: 13px; }
.busy { opacity: .6; pointer-events: none; }

/* ---------- escolha de tema (Automático / Claro / Escuro) ---------- */
.theme-btn { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.theme-btn:hover { background: var(--card); color: var(--ink); }
nav.side .theme-btn { margin: 0 10px; align-self: flex-start; }
.gate .theme-btn { align-self: flex-start; }
@media (max-width: 820px) { nav.side .theme-btn { margin: 0; flex: none; } }

/* Aprovação em massa (aba Pedidos) */
.pickcol { width: 44px; padding-right: 0; user-select: none; }
td.pickcol { cursor: pointer; }
td.pickcol:hover .check:not([disabled]) { outline: 2px solid var(--line); outline-offset: 2px; }
tr.row.picked td { background: var(--line); }
tr.row:focus-visible { outline: 2px solid var(--link); outline-offset: -2px; }
.bulkhint { margin: 0 0 12px; max-width: 78ch; line-height: 1.5; }
.bulkhint summary { cursor: pointer; display: inline-block; font-weight: 600; color: var(--muted); padding: 2px 0; }
.bulkhint summary:hover { color: var(--ink); }
.bulkhint p { margin: 6px 0 0; }
.bulk { position: sticky; top: 8px; z-index: 5; display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap;
  padding: 12px 16px; margin: 0 0 12px; border-radius: 14px; background: var(--paper); border: 1px solid var(--ink); }
.bulk.confirm { background: var(--fill); color: var(--on-fill); border-color: var(--on-fill); }
.bulk.confirm .btn { border-color: var(--on-fill); color: var(--on-fill); }
.bulk.confirm .btn.primary { background: var(--on-fill); color: var(--fill); }
.bulk .actions { justify-content: flex-end; }
/* No escuro o link é gema; sobre fundo gema o anel de foco some. Dentro das caixas de aviso o anel usa a cor do texto. */
.bulk.confirm :focus-visible, .box.warn :focus-visible, .box.bad :focus-visible, .notice :focus-visible, .msg.err :focus-visible { outline-color: var(--on-fill); }

/* Giro do botão de entrada enquanto o painel carrega. */
.btn .spin { display: inline-block; width: 1em; height: 1em; margin-right: 8px; vertical-align: -.15em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; }
@media (prefers-reduced-motion: no-preference) {
  @keyframes spin { to { transform: rotate(360deg); } }
  .btn .spin { animation: spin .8s linear infinite; }
}
.gate .btn.primary[disabled] { opacity: .8; }
