/* Design system do Dom — Pesque-Pague. Nada de neon/glow. */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --card: #ffffff;
  --border: #e4e7ec;
  --text: #1c2024;
  --muted: #60666f;
  --faint: #8b919a;
  --accent: #1e3a5f;
  --accent-soft: rgba(30, 58, 95, 0.08);
  --orange: #e07012;
  --orange-soft: rgba(224, 112, 18, 0.12);
  --code: #f3f4f6;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --yellow: #eab308;
  --yellow-soft: rgba(234, 179, 8, 0.12);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.10);
  --blue-soft: rgba(30, 58, 95, 0.10);
  --font: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", Cascadia, Consolas, ui-monospace, monospace;
  --tabbar-h: calc(64px + env(safe-area-inset-bottom, 0px));
  --topbar-h: 72px;
}

html[data-theme="dark"] {
  --bg: #000000;
  --bg-soft: #0c0d0f;
  --card: #0f1012;
  --border: #24272c;
  --text: #e8eaed;
  --muted: #9aa0a8;
  --faint: #6c727b;
  --accent: #e09550;
  --accent-soft: rgba(224, 149, 80, 0.16);
  --orange: #e09550;
  --orange-soft: rgba(224, 149, 80, 0.16);
  --code: #15171a;
  --shadow: none;
  --yellow-soft: rgba(234, 179, 8, 0.16);
  --green-soft: rgba(34, 197, 94, 0.16);
  --red-soft: rgba(239, 68, 68, 0.16);
  --blue-soft: rgba(224, 149, 80, 0.14);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.7;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: var(--tabbar-h);
}

h1, h2, h3, p { margin: 0; }

h1 {
  font-size: 1.55em;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2 {
  font-size: 1.25em;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--border);
  margin: 1.6rem 0 0.9rem;
}

h3 {
  font-size: 1.05em;
  font-weight: 650;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

a { color: var(--accent); }

#app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px 24px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 12px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}

.topbar-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
  margin-top: 2px;
}

.topbar-text { min-width: 0; flex: 1; }

.topbar-text h1 {
  font-size: 1.28em;
  line-height: 1.2;
}

.topbar .context {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 2px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.5;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn:focus-visible,
.btn:focus-visible,
.input:focus-visible,
.select:focus-visible,
.tabbar button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.view { padding-top: 8px; }
.hidden { display: none !important; }

/* Cartões */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.card.stripe {
  border-left: 4px solid var(--accent);
  padding-left: 16px;
}
.card.stripe.info { border-left-color: var(--accent); background: var(--blue-soft); }
.card.stripe.warn { border-left-color: var(--yellow); background: var(--yellow-soft); }
.card.stripe.ok { border-left-color: var(--green); background: var(--green-soft); }
.card.stripe.risk { border-left-color: var(--red); background: var(--red-soft); }

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 12px 0 20px;
}

.summary .card {
  padding: 14px 16px;
}

.summary .label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.summary .value {
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-top: 4px;
}

.summary .hint {
  color: var(--faint);
  font-size: 0.85rem;
  margin-top: 2px;
}

/* Listas e comandas */
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comanda-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  cursor: pointer;
  color: inherit;
}

.comanda-row .num {
  font-weight: 750;
  color: var(--accent);
  min-width: 2.4em;
  font-variant-numeric: tabular-nums;
}

.comanda-row .meta {
  flex: 1;
  min-width: 0;
}

.comanda-row .meta strong {
  display: block;
  font-weight: 650;
}

.comanda-row .meta span {
  color: var(--muted);
  font-size: 0.9rem;
}

.comanda-row .total {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

html[data-theme="dark"] .btn.primary { color: #0b1020; }

.btn.ghost {
  background: transparent;
}

.btn.danger {
  background: var(--red-soft);
  border-color: transparent;
  color: var(--red);
}

.btn.block { width: 100%; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(var(--tabbar-h) + 16px);
  z-index: 25;
  min-width: 56px;
  height: 56px;
  padding: 0 18px;
  border-radius: 28px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.14);
  border: none;
}

#view-home { padding-bottom: 88px; }

html[data-theme="dark"] .fab { box-shadow: none; }

/* Tab bar */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  font-size: 0.85rem;
  min-height: 64px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.tabbar button.active { color: var(--accent); }

.tabbar .tab-ico { font-size: 1.15rem; line-height: 1; }

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.field label {
  font-weight: 650;
  font-size: 0.9rem;
}

.field .help {
  color: var(--faint);
  font-size: 0.82rem;
  line-height: 1.4;
}

.input, .select, textarea.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}

textarea.input { min-height: 88px; resize: vertical; line-height: 1.5; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 560px) {
  .grid-2.collapse { grid-template-columns: 1fr; }
}

/* Produtos / espécies */
.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.tile {
  position: relative;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  padding-right: 40px;
  cursor: pointer;
  color: inherit;
  min-height: 84px;
}

.tile strong { display: block; font-weight: 650; }
.tile .price { color: var(--accent); font-weight: 750; margin-top: 4px; }
.tile-qty {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 28px;
  min-height: 28px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e08a3c;
  color: #1a1208;
  font-weight: 800;
  font-size: 0.85rem;
  line-height: 24px;
  text-align: center;
  box-sizing: border-box;
}
.tile-qty[hidden] { display: none; }
@keyframes tile-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(0.97); background: var(--accent-soft); border-color: #e08a3c; }
  100% { transform: scale(1); }
}
.tile.is-added { animation: tile-pulse 0.35s ease; }
@media (prefers-reduced-motion: reduce) {
  .tile.is-added { animation: none; outline: 2px solid #e08a3c; outline-offset: 1px; }
}
.tile .badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.live-total {
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin: 8px 0 4px;
}

/* Itens da comanda */
.item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.item:last-child { border-bottom: 0; }

.item .name { font-weight: 650; }
.item .sub { color: var(--muted); font-size: 0.88rem; }
.item .val { font-weight: 750; font-variant-numeric: tabular-nums; }
.item .rm {
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  min-width: 36px;
  min-height: 36px;
  font-size: 1.1rem;
}

.group-label {
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 14px 0 0;
}

/* Tabelas */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--bg-soft);
}

tr:last-child td { border-bottom: 0; }

td.num, th.num { text-align: right; }

/* Modal v2.4 — posição e tamanho vêm do JS em pixels (layoutModal).
   Sem flex de centralização, sem dvh/svh, sem inset e sem transform
   em ancestral. O overlay é filho direto de body. */
#modal-root { display: none; pointer-events: none; }

.modal-back {
  position: fixed;
  top: 0;
  left: 0;
  box-sizing: border-box;
  z-index: 10000;
  background: rgba(16, 24, 40, 0.55);
  display: block;
  overflow: auto;
  transform: none;
  filter: none;
  contain: none;
}

html[data-theme="dark"] .modal-back {
  background: rgba(0, 0, 0, 0.72);
}

.modal {
  box-sizing: border-box;
  height: auto;
  /* Reserva para o caso do JS falhar; o layoutModal sobrescreve em px. */
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  transform: none;
  filter: none;
}

/* Celular: folha de tela inteira, botões de ação alcançáveis pela rolagem. */
@media (max-width: 600px) {
  .modal {
    border-radius: 0;
    border-width: 0;
    max-height: 100vh;
    max-height: 100dvh;
  }
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}

@media (max-width: 600px) {
  .modal-head {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
}

.modal-head h2 {
  margin: 0;
  border: 0;
  padding: 0;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 1.2rem;
  line-height: 1.25;
}

.btn-fechar-modal {
  flex: 0 0 auto;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 16px;
  background: #e08a3c;
  border: 1px solid #c56a1a;
  color: #1a1208;
  font-weight: 800;
  border-radius: var(--radius-sm);
}

.btn-fechar-modal:hover,
.btn-fechar-modal:focus-visible {
  filter: brightness(1.08);
}

html[data-theme="dark"] .btn-fechar-modal {
  background: #e08a3c;
  border-color: #f0b070;
  color: #1a1208;
}

.modal-body {
  padding: 16px 20px 20px;
  box-sizing: border-box;
}

@media (max-width: 600px) {
  .modal-body {
    padding: 14px 16px calc(28px + env(safe-area-inset-bottom, 0px));
  }
}

html[data-theme="dark"] .modal {
  border-color: #3d424a;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
}

.modal h2 {
  margin-top: 0;
  border: 0;
  padding: 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.pay-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pay-grid .btn { min-height: 56px; }

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
}

.qr-box svg, .qr-box img {
  width: min(240px, 70vw);
  height: auto;
  background: #fff;
  padding: 8px;
  border-radius: 8px;
}

.mono {
  font-family: var(--mono);
  font-size: 0.82rem;
  word-break: break-all;
  background: var(--code);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.key-line {
  font-weight: 650;
  word-break: break-all;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px);
  transform: translateX(-50%);
  z-index: 10011;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 650;
  font-size: 0.92rem;
  max-width: 90vw;
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.toast.hidden { display: none; }
.toast-action {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
  min-height: 32px;
  padding: 0 4px;
}
body.modal-open .toast {
  bottom: 24px;
}

html[data-theme="dark"] .toast {
  background: #e8eaed;
  color: #0b0c0e;
}

/* Comanda header */
.cmd-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  color: var(--accent);
  font-weight: 650;
  cursor: pointer;
  padding: 4px 0;
  min-height: 36px;
}

.grand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  font-size: 1.15rem;
}

.grand strong { font-size: 1.4rem; font-weight: 750; }

.actions-sticky {
  position: sticky;
  bottom: calc(var(--tabbar-h) + 8px);
  background: var(--bg);
  padding: 10px 0 4px;
  margin-top: 16px;
}

/* Config rows */
.cfg-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.cfg-row .side { text-align: right; white-space: nowrap; }

/* Print */
@media print {
  body { padding: 0; background: #fff; color: #000; }
  #app { max-width: none; padding: 0; }
  .topbar, .tabbar, .fab, .no-print, .toast, .modal-back { display: none !important; }
  .view.hidden { display: none !important; }
  #view-fechamento, #view-comanda { display: block !important; }
  h2 { border-color: #ccc; }
  .card, .table-wrap { box-shadow: none; border-color: #ccc; }
  a[href]::after { content: none !important; }
}

@page { margin: 16mm; }

/* ---------- v2: Visão de helicóptero ---------- */
.tabbar {
  grid-template-columns: repeat(4, 1fr);
  position: fixed;
}

.tabbar .indicator {
  position: absolute;
  top: 6px;
  left: 0;
  width: 0;
  height: calc(64px - 12px);
  border-radius: 10px;
  background: var(--accent-soft);
  pointer-events: none;
  transition: left 0.22s ease, width 0.22s ease;
}

.tabbar button { position: relative; z-index: 1; }

.pill.live {
  color: var(--accent);
  border-color: transparent;
  background: var(--accent-soft);
}

.pill.warn {
  color: #8a6d00;
  background: var(--yellow-soft);
  border-color: transparent;
}

html[data-theme="dark"] .pill.warn { color: #facc15; }

.pill.ok {
  color: #15803d;
  background: var(--green-soft);
  border-color: transparent;
}

html[data-theme="dark"] .pill.ok { color: #4ade80; }

.pill.risk {
  color: #b91c1c;
  background: var(--red-soft);
  border-color: transparent;
}

html[data-theme="dark"] .pill.risk { color: #f87171; }

.group-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 8px;
  color: inherit;
  cursor: pointer;
}

.group-row .num {
  font-weight: 750;
  color: var(--accent);
  min-width: 2.2em;
  font-variant-numeric: tabular-nums;
}

.group-row .meta { flex: 1; min-width: 0; }
.group-row .meta strong { display: block; font-weight: 650; line-height: 1.3; }
.group-row .sub { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.group-row .total { font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums; }

.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin: 8px 0 16px;
}

.stock-tile {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: inherit;
  min-height: 110px;
}

.stock-tile.warn { border-left-color: var(--yellow); background: var(--yellow-soft); }
.stock-tile.risk { border-left-color: var(--red); background: var(--red-soft); }
.stock-tile.ok { border-left-color: var(--green); }
.stock-tile strong { display: block; font-weight: 650; }
.stock-tile .kg {
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin-top: 4px;
}
.stock-tile .sub { color: var(--muted); font-size: 0.85rem; }

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 8px 0 14px;
  font-weight: 650;
}
.check-row input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; }

.banner-ro {
  margin: 8px 0 14px;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-gate .box {
  width: min(420px, 100%);
}

.weigh-preview {
  margin: 8px 0 12px;
}

.weigh-preview p { display: flex; justify-content: space-between; gap: 12px; }
.weigh-preview .muted { color: var(--muted); }

#view-estoque, #view-historico { padding-bottom: 24px; }

.search-row {
  display: flex;
  gap: 8px;
  margin: 8px 0 16px;
}
.search-row .input { flex: 1; }

.sync-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
}


/* Movimentações de estoque — cartões compactos (cabem em 320px, sem rolagem) */
.mov-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.mov-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  min-width: 0;
}

.mov-card.mov-entrada { border-left-color: var(--green); }
.mov-card.mov-saida { border-left-color: var(--red); }
.mov-card.mov-ajuste { border-left-color: var(--yellow); }

.mov-when {
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.3;
  margin-bottom: 2px;
}

.mov-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.mov-meta {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.mov-meta strong { font-weight: 650; }

.mov-note {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.mov-kg {
  flex: 0 0 auto;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.4;
}

.mov-card.mov-entrada .mov-kg { color: #15803d; }
.mov-card.mov-saida .mov-kg { color: #b91c1c; }
.mov-card.mov-ajuste .mov-kg { color: #8a6d00; }

html[data-theme="dark"] .mov-card.mov-entrada .mov-kg { color: #4ade80; }
html[data-theme="dark"] .mov-card.mov-saida .mov-kg { color: #f87171; }
html[data-theme="dark"] .mov-card.mov-ajuste .mov-kg { color: #facc15; }


/* Conta e versão em Config */
.conta-block { margin: 8px 0 16px; }
.conta-block .status { margin-top: 4px; }
.cfg-versao {
  display: block;
  width: 100%;
  margin: 28px 0 8px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 0.78rem;
  font-weight: 650;
  text-align: center;
  cursor: default;
}


/* ======================================================================
   v2.2 — Histórico por período (Dia / Semana / Mês)
   Estas regras valem no celular e no notebook; o layout do celular segue o mesmo.
   ====================================================================== */
.side-brand, .side-foot { display: none; }

.hist-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 4px;
}

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  min-height: 42px;
  border-radius: 6px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--card);
  color: var(--accent);
  box-shadow: var(--shadow);
  outline: 1px solid var(--border);
}

.seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.period-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.period-label {
  flex: 1;
  min-width: 140px;
  text-align: center;
  font-weight: 750;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.nav-btn {
  min-width: 48px;
  padding: 0 14px;
  font-size: 1.4rem;
  line-height: 1;
}

.summary.summary-5 { grid-template-columns: repeat(2, 1fr); }

.hist-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin: 8px 0 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
  min-width: 0;
}

.panel h3 {
  font-size: 0.78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 12px;
}

.panel .empty.small { padding: 14px 0; }
.panel .help { color: var(--faint); font-size: 0.82rem; margin-top: 8px; }

.panel-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 10px;
}

.panel-foot strong { font-size: 1.15rem; font-weight: 750; font-variant-numeric: tabular-nums; }

/* Gráfico de barras (CSS puro) */
.bars {
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 200px;
  padding-top: 4px;
}

.bar-col {
  appearance: none;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: 4px;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-family: inherit;
  cursor: pointer;
  border-radius: 6px;
}

.bar-val {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  min-height: 0.8em;
}

.bar-track {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid var(--border);
  min-height: 0;
}

.bar-fill {
  display: block;
  width: 100%;
  background: var(--accent);
  border-radius: 6px 6px 0 0;
  opacity: 0.9;
  min-height: 0;
}

.bar-col.today .bar-fill { background: var(--orange); }
.bar-col.empty .bar-track { border-bottom-color: var(--border); }

.bar-lab {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.2;
  color: var(--faint);
  min-height: 2.4em;
}

.bars.month { gap: 3px; }
.bars.month .bar-lab { font-size: 0.66rem; min-height: 1.4em; }
.bars.month .bar-lab.sparse { color: transparent; }

.bar-col:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Forma de pagamento */
.pay-row { margin-bottom: 12px; }
.pay-top { display: flex; align-items: baseline; gap: 10px; }
.pay-top .k { font-weight: 650; flex: 1; }
.pay-top .v { font-weight: 750; font-variant-numeric: tabular-nums; }
.pay-top .pc { color: var(--faint); font-size: 0.82rem; min-width: 3.6em; text-align: right; font-variant-numeric: tabular-nums; }
.pay-bar { height: 8px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.pay-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.pay-sub { color: var(--muted); font-size: 0.82rem; margin-top: 3px; }

/* Tabelas dentro de painéis */
.table-wrap.mini { border: 0; border-radius: 0; background: transparent; }
.table-wrap.mini th, .table-wrap.mini td { padding: 8px 8px; }
.table-wrap.mini th:first-child, .table-wrap.mini td:first-child { padding-left: 0; }
.table-wrap.mini th:last-child, .table-wrap.mini td:last-child { padding-right: 0; }
.table-wrap.mini th { background: transparent; border-bottom: 1px solid var(--border); }
.table-wrap.mini .sub { color: var(--faint); font-size: 0.78rem; line-height: 1.3; }
tr.total-row td { font-weight: 750; border-top: 1px solid var(--border); border-bottom: 0; background: var(--bg-soft); }
tr.muted-row td { color: var(--faint); }
tr.row-click { cursor: pointer; }
tr.row-click:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.num-accent { color: var(--accent); }

.detail-empty { display: none; }

@media (max-width: 560px) {
  .col-opt { display: none; }
}

/* ======================================================================
   v2.2 — Layout de notebook (>= 1024px): menu lateral fixo, colunas e tabelas largas.
   O layout do celular (abaixo de 1024px) não é tocado.
   ====================================================================== */
@media (min-width: 1024px) {
  :root {
    --side-w: 252px;
    --tabbar-h: 0px;
  }

  html, body { font-size: 17px; }
  body { padding-bottom: 0; background: var(--bg-soft); }

  /* Menu lateral */
  .tabbar {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: var(--side-w);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 22px 14px 18px;
    background: var(--card);
    border-top: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
  }

  .tabbar .indicator { display: none; }

  .side-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 18px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
  }

  .side-brand img { width: 56px; height: 56px; object-fit: contain; flex-shrink: 0; }
  .side-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
  .side-brand-text strong { font-size: 1rem; font-weight: 750; letter-spacing: -0.01em; }
  .side-brand-text span { color: var(--faint); font-size: 0.8rem; margin-top: 2px; }

  .tabbar button {
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    min-height: 50px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    text-align: left;
    transition: background-color 0.12s ease, color 0.12s ease;
  }

  .tabbar .tab-ico { width: 1.4em; text-align: center; font-size: 1.15rem; }
  .tabbar button:hover { background: var(--bg-soft); color: var(--text); }
  .tabbar button.active {
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
  }

  .side-foot {
    display: flex;
    margin-top: auto;
    padding: 14px 8px 0;
    border-top: 1px solid var(--border);
  }

  /* Área principal */
  #app {
    max-width: none;
    margin: 0 0 0 var(--side-w);
    padding: 0 44px 40px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }

  .topbar {
    position: static;
    grid-column: 1 / -1;
    background: transparent;
    padding: 28px 0 14px;
    align-items: center;
  }

  .topbar .brand-logo { display: none; }
  .topbar-text { display: flex; flex-direction: column; }
  .topbar-text h1 {
    order: 2;
    font-size: 0.85rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--faint);
    margin-top: 2px;
  }
  .topbar .context {
    order: 1;
    margin: 0;
    color: var(--text);
    font-size: 1.9rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    line-height: 1.2;
  }
  .topbar .pills { order: 3; margin-top: 10px; }

  .pill { font-size: 0.82rem; }
  .icon-btn { transition: background-color 0.12s ease; }
  .icon-btn:hover { background: var(--bg-soft); }

  .view { grid-column: 1 / -1; padding-top: 0; min-width: 0; }
  #view-home { padding-bottom: 0; }
  #view-config { max-width: 900px; }

  h2 { margin: 1.8rem 0 1rem; }

  /* Controles com mais precisão de mouse */
  .btn { min-height: 44px; transition: background-color 0.12s ease, border-color 0.12s ease; }
  .btn:hover { background: var(--accent-soft); border-color: var(--accent); }
  .btn.primary:hover { background: var(--accent); filter: brightness(1.12); }
  .btn.danger:hover { background: var(--red-soft); border-color: var(--red); }
  .btn.ghost:hover { background: var(--bg-soft); border-color: var(--border); }
  .input, .select, textarea.input { min-height: 44px; }
  .input:hover, .select:hover { border-color: var(--faint); }

  /* Lista de grupos + detalhe lado a lado */
  #app.split { grid-template-columns: minmax(380px, 460px) minmax(0, 1fr); column-gap: 32px; }
  #app.split #view-home { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; }
  #app.split #view-comanda { grid-column: 2; grid-row: 2; }
  #app.split #view-home,
  #app.split #view-comanda { align-self: start; }

  #app.split #view-comanda {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 28px 28px;
    min-height: 420px;
  }

  #app.split .back-link { display: none; }
  #app.split .actions-sticky { background: var(--card); bottom: 0; padding: 12px 0 4px; margin-top: 12px; border-top: 1px solid var(--border); }
  #app.split .actions-sticky .btn.block { width: auto; flex: 1 1 auto; }
  #app.split #view-comanda h2:first-of-type { margin-top: 0; }

  #view-home .fab {
    position: static;
    order: -1;
    width: 100%;
    height: 52px;
    border-radius: var(--radius-sm);
    box-shadow: none;
    margin: 4px 0 6px;
    font-size: 1rem;
    transition: filter 0.12s ease;
  }
  #view-home .fab:hover { filter: brightness(1.12); }
  #view-home .summary { margin-top: 10px; }

  .group-row { padding: 14px 16px; transition: background-color 0.12s ease, border-color 0.12s ease; }
  .group-row:hover { background: var(--bg-soft); border-color: var(--faint); }
  .group-row.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }

  .detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
    min-height: 360px;
    color: var(--muted);
  }
  .detail-empty .ico { font-size: 2.2rem; color: var(--faint); }
  .detail-empty h3 { color: var(--text); font-size: 1.25rem; }
  .detail-empty p { max-width: 34ch; }

  .item { padding: 12px 0; }
  .item .rm:hover { color: var(--red); }
  .grand { font-size: 1.25rem; }
  .grand strong { font-size: 1.7rem; }

  /* Cartões de resumo */
  .summary { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
  .summary .card { padding: 18px 20px; }
  .summary .label { font-size: 0.8rem; }
  .summary .value { font-size: 1.7rem; }
  .summary.summary-5 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #app.split .summary { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  #app.split .summary .value { font-size: 1.35rem; }

  /* Histórico */
  .desk-only { display: grid; }
  .hist-bar { flex-direction: row; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 4px; }
  .seg { width: 300px; }
  .period-nav { flex: 1; min-width: 360px; flex-wrap: nowrap; }
  .period-label { font-size: 1.2rem; }
  .search-row { max-width: 640px; }
  .hist-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .hist-grid .panel.wide { grid-column: 1 / -1; }
  .panel { padding: 20px 22px 18px; }
  .panel h3 { font-size: 0.82rem; }
  .bars { height: 260px; gap: 10px; }
  .bars.month { gap: 5px; }
  .bar-val { font-size: 0.8rem; }
  .bar-lab { font-size: 0.82rem; }
  .bars.month .bar-lab { font-size: 0.74rem; }
  .bar-col:hover .bar-fill { opacity: 1; filter: brightness(1.12); }
  .bar-col:hover { background: var(--bg-soft); }
  .bar-col:hover .bar-lab { color: var(--text); }
  .table-wrap.mini th, .table-wrap.mini td { padding: 10px 10px; }
  .col-opt { display: table-cell; }

  .hist-table table { font-size: 1rem; }
  .hist-table th, .hist-table td { padding: 14px 18px; }
  tr.row-click { transition: background-color 0.12s ease; }
  tr.row-click:hover td { background: var(--accent-soft); }
  tr.total-row:hover td { background: var(--bg-soft); }

  /* Estoque e config em colunas */
  .stock-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
  .stock-tile { transition: border-color 0.12s ease; }
  .stock-tile:hover { border-color: var(--faint); }
  .mov-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mov-card:hover { border-color: var(--faint); }
  .cfg-row { transition: background-color 0.12s ease; padding: 12px 10px; margin: 0 -10px; border-radius: var(--radius-sm); }
  .cfg-row:hover { background: var(--bg-soft); }
  .catalog { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .tile { transition: border-color 0.12s ease, background-color 0.12s ease; }
  .tile:hover { border-color: var(--accent); background: var(--accent-soft); }

  .modal { padding: 0; }
  .modal-head { padding: 16px 20px; }
  .modal-body { padding: 8px 28px 22px; }
  .toast { bottom: 24px; left: calc(50% + var(--side-w) / 2); }
}

@media (min-width: 1440px) {
  #app { padding: 0 64px 48px; }
  #app.split { grid-template-columns: minmax(420px, 500px) minmax(0, 1fr); }
  .hist-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media print {
  #app { margin-left: 0 !important; padding: 0 !important; display: block !important; }
  .side-brand, .side-foot { display: none !important; }
  .hist-list { display: none !important; }
  .hist-table, .desk-only { display: block !important; }
  .hist-grid { display: block !important; }
  .panel { break-inside: avoid; margin-bottom: 12px; box-shadow: none; }
}


/* Peixe por espécie (cartões) — Dia, Semana e Mês */
.fish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.fish-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-width: 0;
}

.fish-card.zero { border-left-color: var(--border); }
.fish-card.zero .fish-kg { color: var(--faint); }
.fish-name { font-weight: 650; line-height: 1.3; }
.fish-kg { font-size: 1.4rem; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.3; margin-top: 2px; }
.fish-kg small { font-size: 0.8rem; font-weight: 650; color: var(--muted); }
.fish-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 8px 0 10px; }
.fish-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.fish-nums { margin: 0; display: grid; gap: 2px; }
.fish-nums div { display: flex; justify-content: space-between; gap: 8px; font-size: 0.88rem; }
.fish-nums dt { color: var(--muted); }
.fish-nums dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }

.fish-total { flex-wrap: wrap; gap: 6px 12px; }
.fish-total .ft-vals { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; font-variant-numeric: tabular-nums; color: var(--muted); }
.fish-total .ft-vals strong { color: var(--text); font-size: 1.15rem; }

.fish-day { margin-top: 4px; }

@media (min-width: 1024px) {
  .fish-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
  .fish-card { padding: 18px 20px; transition: border-color 0.12s ease; }
  .fish-card:hover { border-color: var(--faint); border-left-color: var(--accent); }
  .fish-kg { font-size: 2rem; }
  .fish-name { font-size: 1.05rem; }
  .fish-nums div { font-size: 0.95rem; }
  .fish-day .panel { margin-bottom: 4px; }
}


/* v2.3 — tilápia por tanque e perfil de funcionário */
.stock-species { margin-bottom: 18px; }
.stock-species-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 4px 0 10px;
}
.stock-species-head strong { font-size: 1.1rem; }
.stock-total { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 650; }
.stock-grid.tanks { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 8px; }
.stock-tile.muted-tank { opacity: 0.78; border-left-color: var(--border); }
.stock-tile .btn-row.tight { margin: 8px 0 0; }
.btn.sm { padding: 6px 10px; font-size: 0.85rem; }
.tank-kg {
  list-style: none;
  margin: 10px 0 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 4px;
}
.tank-kg li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.tank-kg li span:first-child { color: var(--muted); }
#tabbar [data-nav].hidden,
#tabbar [data-nav][hidden] { display: none !important; }

@media (min-width: 1024px) {
  .stock-grid.tanks { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tank-kg li { font-size: 0.95rem; }
}


/* Botão Sair — visível para qualquer usuário logado (também funcionário) */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.btn-sair-top {
  min-height: 40px;
  padding: 0 12px;
  font-weight: 650;
}
.btn-sair-side { display: none; }

@media (min-width: 1024px) {
  .btn-sair-side:not(.hidden) {
    display: flex;
    width: 100%;
    margin-top: 8px;
    color: var(--muted);
  }
  .btn-sair-side:hover { background: var(--bg-soft); color: var(--text); }
}

/* Prévia local */
.preview-banner {
  display: none;
  position: sticky;
  top: 0;
  z-index: 90;
  background: #7a4a00;
  color: #fff8e8;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding: 8px 12px;
  border-bottom: 1px solid #c4841a;
}
.preview-banner.is-on,
body[data-preview="1"] .preview-banner { display: block; }

/* ---------- v2.8: estoque de produtos ---------- */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.field-row > .field { min-width: 0; }
@media (max-width: 380px) { .field-row { grid-template-columns: 1fr; } }
.help { color: var(--faint); font-size: 0.85rem; line-height: 1.4; margin: 6px 0 10px; }
.prod-period { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 10px; }
.prod-period-label { color: var(--faint); font-size: 0.9rem; }
.prod-summary .hint { white-space: normal; }
.prod-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.prod-tile .kg { font-variant-numeric: tabular-nums; }
.prod-cost { margin-top: 6px; font-size: 0.84rem; line-height: 1.35; color: var(--text); }
.prod-cost b { font-weight: 700; color: #15803d; }
html[data-theme="dark"] .prod-cost b { color: #4ade80; }
.prod-cost.none { color: var(--faint); font-style: italic; }
/* v2.8: 5 abas (dono) ou 3 (funcionário) numa linha só no celular */
@media (max-width: 1023.98px) {
  .tabbar { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .tabbar button { font-size: 0.78rem; padding: 0 2px; white-space: nowrap; }
}

.stock-tile.fresh { border-left-color: var(--border); }
.prod-cost.neg b { color: #b91c1c; }
html[data-theme="dark"] .prod-cost.neg b { color: #f87171; }
@media (min-width: 1024px) {
  .preview-banner.is-on { margin-left: var(--side-w); }
}
@media (max-width: 600px) {
  .prod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .prod-tile { padding: 10px; }
  .prod-tile .btn-row.tight { flex-wrap: wrap; gap: 6px; }
  .prod-tile .btn-row.tight .btn { flex: 1 1 auto; }
}
