/* Acompanhamento remoto do Bury PDV. Mesmo visual do sistema do restaurante
   (vermelho Bury, madeira e areia; Bebas Neue nos titulos e Inter no texto).
   Feito primeiro para celular (375 px). Tema claro fixo, como o PDV. */

/* ---------- Fontes (as mesmas do PDV, servidas daqui: a pagina nao busca nada fora) ---------- */

@font-face {
  font-family: "Bebas Neue";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/bebas-neue-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/inter-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/inter-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/inter-latin-800-normal.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --red: #D92525;
  --red-dark: #B91C1C;
  --wood: #4A3B32;
  --sand: #F7F3E8;
  --surface: #ffffff;
  --text: #292524;
  --text-2: #78716C;
  --border: #E7E5E4;
  --border-2: #D6D3D1;
  --track: #F5F5F4;
  --bar: #D92525;
  --focus: #D92525;
  --good: #16A34A;
  --warning: #F59E0B;
  --critical: #DC2626;
  --ok-bg: #F0FDF4;
  --ok-border: #BBF7D0;
  --stale-bg: #FFFBEB;
  --stale-border: #FDE68A;
  --error-bg: #FEF2F2;
  --error-border: #FECACA;
  --shadow: 0 1px 2px rgba(74, 59, 50, 0.06), 0 1px 3px rgba(74, 59, 50, 0.08);
  --shadow-lg: 0 10px 30px rgba(74, 59, 50, 0.18);
  --display: "Bebas Neue", Impact, "Arial Narrow", sans-serif;
  /* Textura de cubos do PDV (o mesmo desenho do tailwind.config do sistema). */
  --pattern: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20width%3D'60'%20height%3D'104'%20viewBox%3D'0%200%2060%20104'%3E%3Cg%20fill%3D'none'%20stroke%3D'%234A3B32'%20stroke-opacity%3D'0.07'%20stroke-width%3D'1'%3E%3Cpath%20d%3D'M30%200L60%2017.32V51.96L30%2069.28L0%2051.96V17.32Z'%2F%3E%3Cpath%20d%3D'M30%2034.64L0%2017.32M30%2034.64L60%2017.32M30%2034.64V69.28'%2F%3E%3Cpath%20d%3D'M30%2069.28V104M0%2086.6L30%2069.28L60%2086.6M0%2086.6V104M60%2086.6V104M0%200V17.32M60%200V17.32'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--sand);
  background-image: var(--pattern);
  color: var(--text);
  font: 16px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, p { margin: 0; }

/* iPhone: sem o estilo nativo do Safari nos campos (busca arredondada, sombra
   interna) e sem zoom por toque duplo nos botoes e listas. Os campos tem 16 px
   de texto: menos que isso o Safari da zoom ao focar. */
input, button { -webkit-appearance: none; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
button, input, .catalog-row, .chip, .seg { touch-action: manipulation; }

[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.boot, .noscript { padding: 48px 16px; text-align: center; color: var(--text-2); }

/* ---------- Marca ---------- */

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 10px rgba(217, 37, 37, 0.3);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-family: var(--display); font-size: 1.75rem; line-height: 1; letter-spacing: 0.02em; color: var(--wood); text-transform: uppercase; }
.brand-place { margin-top: 2px; font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.2em; color: var(--red); text-transform: uppercase; }

/* ---------- Botoes ---------- */

.button {
  appearance: none;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--wood);
  font: inherit;
  font-weight: 800;
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.button:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.button.primary {
  width: 100%;
  min-height: 50px;
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(217, 37, 37, 0.25);
}
.button.primary:hover:not(:disabled) { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.button.small { min-height: 36px; padding: 0 12px; font-size: 0.8125rem; }
.button:disabled { opacity: 0.55; cursor: default; box-shadow: none; }

/* ---------- Entrada ---------- */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 28px 22px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.login-card h1 { margin-top: 22px; font-family: var(--display); font-size: 2rem; font-weight: 400; line-height: 1.05; letter-spacing: 0.01em; color: var(--wood); }
.login-lead { margin-top: 6px; color: var(--text-2); font-size: 0.9375rem; }
.login-card form { margin-top: 18px; }
.login-card label { display: block; margin-top: 16px; color: var(--wood); font-weight: 800; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.login-card input {
  display: block;
  width: 100%;
  min-height: 50px;
  margin-top: 6px;
  padding: 0 14px;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: #FAFAF9;
  color: var(--text);
  font: inherit; /* 16 px: o iPhone nao da zoom ao focar */
}
.login-card input:focus { border-color: var(--red); background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(217, 37, 37, 0.15); }
#code { text-transform: uppercase; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; font-weight: 600; }
#code::placeholder { letter-spacing: 0.08em; font-weight: 400; }
.hint { margin-top: 6px; color: var(--text-2); font-size: 0.8125rem; }
.form-error {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--error-border);
  border-radius: 12px;
  background: var(--error-bg);
  color: #991B1B;
  font-size: 0.9375rem;
  font-weight: 600;
}
.login-card .button.primary { margin-top: 22px; }

/* ---------- Painel ---------- */

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 12px calc(20px + env(safe-area-inset-bottom));
  padding-top: max(12px, env(safe-area-inset-top));
  /* Trava de seguranca contra a tela "andar" de lado. clip (e nao hidden) para
     nao virar area de rolagem e nao desligar a faixa presa no topo. */
  overflow-x: clip;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}
.top-text { flex: 1; min-width: 0; }
.top h1 {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--wood);
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.subtitle { margin-top: 3px; color: var(--red); font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }

/* A faixa de situacao fica presa no topo; o fundo areia atras dela esconde o
   conteudo que rola por baixo. */
.status-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -12px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--sand);
}
.status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.9375rem;
  font-weight: 600;
}
.status-text { flex: 1; min-width: 0; }
.status-detail { margin-top: 2px; color: var(--text-2); font-size: 0.8125rem; font-weight: 400; }
.status-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--text-2); }
.status.ok { background: var(--ok-bg); border-color: var(--ok-border); color: #166534; }
.status.ok .status-dot { background: var(--good); box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.15); }
.status.stale { background: var(--stale-bg); border-color: var(--stale-border); color: #92400E; }
.status.stale .status-dot { background: var(--warning); }
.status.error { background: var(--error-bg); border-color: var(--error-border); color: #991B1B; }
.status.error .status-dot { background: var(--critical); }

.panels { display: grid; gap: 12px; margin-top: 4px; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card-wide { grid-column: 1 / -1; }
.card-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card-label { color: var(--text-2); font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.card-value {
  margin-top: 4px;
  color: var(--wood);
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.card-value.hero { font-family: var(--display); font-size: 2.75rem; font-weight: 400; line-height: 1; letter-spacing: 0.01em; color: var(--red); }
.card-note { margin-top: 4px; color: var(--text-2); font-size: 0.8125rem; }

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel h2 { font-family: var(--display); font-size: 1.5rem; font-weight: 400; line-height: 1.05; letter-spacing: 0.02em; color: var(--wood); }
.panel-note { margin-top: 4px; color: var(--text-2); font-size: 0.8125rem; }
.panel-body { margin-top: 12px; }
.empty { color: var(--text-2); font-size: 0.9375rem; }
.subhead {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 4px;
  color: var(--wood);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.subhead:first-child { margin-top: 0; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); }
.dot.critical { background: var(--critical); }
.dot.warning { background: var(--warning); }

/* ---------- Barras (um valor por linha, sempre com o numero ao lado) ---------- */

/* Uma grade so para a lista inteira: todas as barras comecam e terminam na
   mesma coluna, entao os comprimentos sao comparaveis entre as linhas. */
.bars {
  display: grid;
  grid-template-columns: auto minmax(24px, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 8px;
  font-size: 0.875rem;
}
.bar-row { display: contents; }
.bar-label { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-label.today { color: var(--red); font-weight: 800; }
.bar-track { display: block; height: 10px; background: var(--track); border-radius: 0 5px 5px 0; }
.bar-fill { display: block; height: 100%; min-width: 0; background: var(--bar); border-radius: 0 5px 5px 0; }
.bar-value { text-align: right; color: var(--wood); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-extra { color: var(--text-2); font-weight: 400; }

/* Rotulos compridos (forma de pagamento): nome e valor em cima, barra embaixo. */
.bars.stacked { grid-template-columns: minmax(0, 1fr); row-gap: 12px; }
.bars.stacked .bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; row-gap: 6px; align-items: baseline; }
.bars.stacked .bar-label { color: var(--text); font-weight: 600; white-space: normal; overflow-wrap: anywhere; }
.bars.stacked .bar-track { grid-column: 1 / -1; grid-row: 2; }

/* ---------- Listas ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
  row-gap: 2px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}
.list > li:first-child { border-top: 0; padding-top: 0; }
.list > li:last-child { padding-bottom: 0; }
.item-title { color: var(--wood); font-weight: 800; overflow-wrap: anywhere; }
.item-title .light { color: var(--text-2); font-weight: 400; }
.item-value { text-align: right; color: var(--red); font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-meta { grid-column: 1 / -1; color: var(--text-2); font-size: 0.8125rem; overflow-wrap: anywhere; }
.rank { color: var(--text-2); font-weight: 400; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  background: #FAFAF9;
  color: var(--text-2);
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: 2px;
  white-space: nowrap;
}
.badge.open { border-color: var(--stale-border); background: var(--stale-bg); color: #92400E; }
.badge.ok { border-color: var(--ok-border); background: var(--ok-bg); color: #166534; }
.badge.bad { border-color: var(--error-border); background: var(--error-bg); color: #991B1B; }
.error-text { color: var(--critical); font-weight: 600; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-wide { grid-column: 1 / -1; }
.stat-value { margin-top: 2px; color: var(--wood); font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* Rodape igual ao do PDV: faixa madeira com a marca. */
.footer-band {
  margin-top: 16px;
  padding: 16px 14px;
  border-radius: 20px;
  background: var(--wood);
  color: var(--sand);
  text-align: center;
}
.footer-brand { font-family: var(--display); font-size: 1.375rem; letter-spacing: 0.04em; text-transform: uppercase; }
.footer { margin-top: 4px; color: rgba(247, 243, 232, 0.7); font-size: 0.75rem; }

/* ---------- Cardapio e estoque (alteracoes de fora) ---------- */

.catalog-tools { margin-top: 12px; }
.catalog-tools input[type="search"] {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: #FAFAF9;
  color: var(--text);
  font: inherit; /* 16 px: o iPhone nao da zoom ao focar */
}
.catalog-tools input[type="search"]:focus { border-color: var(--red); background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(217, 37, 37, 0.15); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  appearance: none;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--wood);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.chip[aria-pressed="true"], .seg[aria-pressed="true"] { border-color: var(--red); background: var(--red); color: #fff; box-shadow: 0 2px 8px rgba(217, 37, 37, 0.25); }

.list.catalog > li { display: block; padding: 0; }
.catalog-row {
  appearance: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
  row-gap: 2px;
  width: 100%;
  padding: 11px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.catalog-row:active .item-title { color: var(--red); }
.list.catalog > li:first-child .catalog-row { padding-top: 0; }
.more { margin-top: 10px; color: var(--text-2); font-size: 0.8125rem; }

/* Folha aberta: o iPhone ignora overflow:hidden no body, entao a pagina fica
   presa no lugar (o app.js guarda e devolve a posicao da rolagem). */
body.sheet-open { position: fixed; left: 0; right: 0; overflow: hidden; }
.sheet-backdrop {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(41, 37, 36, 0.55);
}
.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; /* rolar ate o fim da folha nao arrasta a pagina */
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.sheet-head { display: flex; align-items: flex-start; gap: 12px; }
.sheet-title-box { flex: 1; min-width: 0; }
.sheet-head h2 { font-family: var(--display); font-size: 1.75rem; font-weight: 400; line-height: 1.05; letter-spacing: 0.02em; color: var(--wood); overflow-wrap: anywhere; }
.sheet-head .subtitle { color: var(--text-2); letter-spacing: 0.04em; }
.sheet-msg {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 600;
}
.sheet-msg.ok { border-color: var(--ok-border); background: var(--ok-bg); color: #166534; }
.sheet-msg.info { border-color: var(--stale-border); background: var(--stale-bg); color: #92400E; }
.sheet-msg.error { border-color: var(--error-border); background: var(--error-bg); color: #991B1B; }
.sheet-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.sheet-block label, .block-label { display: block; margin-top: 12px; color: var(--wood); font-weight: 800; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.sheet-block > label:first-child, .sheet-block > .block-label:first-child { margin-top: 0; }
.sheet input[type="text"] {
  display: block;
  width: 100%;
  min-height: 50px;
  margin-top: 6px;
  padding: 0 14px;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: #FAFAF9;
  color: var(--text);
  font: inherit;
}
.sheet input[type="text"]:focus { border-color: var(--red); background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(217, 37, 37, 0.15); }
.sheet .row { display: flex; gap: 8px; margin-top: 6px; }
.sheet .row input[type="text"] { flex: 1; min-width: 0; margin-top: 0; }
.sheet .row .button { min-height: 50px; border-color: var(--red); background: var(--red); color: #fff; }
.sheet .row .button:hover:not(:disabled) { background: var(--red-dark); color: #fff; }
#avail-toggle { margin-top: 10px; }
#stock-save { margin-top: 16px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.seg {
  appearance: none;
  min-height: 42px;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--wood);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

/* ---------- Telas maiores ---------- */

@media (min-width: 720px) {
  .app { padding: 20px 20px 32px; }
  .top { padding: 14px 18px; }
  .top h1 { font-size: 2.125rem; }
  .panels { grid-template-columns: 1fr 1fr; align-items: start; }
  .cards { grid-column: 1 / -1; }
  .panel-wide { grid-column: 1 / -1; }
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 24px; }
}

@media (min-width: 960px) {
  .cards { grid-template-columns: repeat(6, 1fr); }
  .card-wide { grid-column: span 2; }
}
