/* ==========================================================================
   SISTEMA DE GESTÃO — ESTOQUE & FINANCEIRO
   Paleta: cinza claro / off-white (sem branco puro) + tinta grafite + acentos
   Tipografia: Inter (interface) + IBM Plex Mono (códigos, valores, dados)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600;700&display=swap');

:root{
  /* --- superfícies (nunca #fff puro) --- */
  --bg:            #EFEFEC;
  --bg-soft:       #F5F5F2;
  --surface:       #FBFBF9;
  --surface-alt:   #E9E9E5;
  --sidebar:       #F8F8F6;
  --border:        #DCDCD6;
  --border-soft:   #E6E6E1;

  /* --- tinta / texto --- */
  --ink:           #1E1E1C;
  --ink-2:         #4A4A45;
  --ink-3:         #7A7A73;
  --ink-inverse:   #F5F5F2;

  /* --- marca / ação --- */
  --brand:         #232320;
  --brand-hover:   #35352F;

  /* --- semântica (tons abafados, não neon) --- */
  --success:       #3E7350;
  --success-bg:    #E3EDE4;
  --danger:        #A6402F;
  --danger-bg:     #F1E1DC;
  --warning:       #92661E;
  --warning-bg:    #F0E7D4;
  --info:          #33607E;
  --info-bg:       #DFE8ED;

  /* --- tokens de forma --- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(30,30,28,0.06);
  --shadow-md: 0 4px 16px rgba(30,30,28,0.08);
  --shadow-lg: 0 12px 40px rgba(30,30,28,0.14);

  --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --sidebar-w: 236px;
  --topbar-h: 68px;
}

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

/* Tamanho padrão de qualquer ícone SVG solto no sistema — evita que um ícone
   sem classe (ou dentro de um contexto sem regra própria) renderize no
   tamanho intrínseco do navegador (bem maior que o esperado). Qualquer
   seletor de classe mais específico definido abaixo (.btn svg, .nav-item svg
   etc.) continua vencendo este padrão normalmente. */
svg{ width: 16px; height: 16px; flex-shrink: 0; }

html, body{ height: 100%; }
body{
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
h1,h2,h3,h4{ margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p{ margin: 0; }
button{ font-family: inherit; }
input, select, textarea{ font-family: inherit; font-size: 14px; }
::selection{ background: #cfcfc4; }

:focus-visible{
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- menu toggle (mobile) ---------- */
.menu-toggle{
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}
.menu-toggle svg{ width: 18px; height: 18px; }
.menu-toggle:hover{ background: var(--surface-alt); }

.sidebar-backdrop{
  display: none;
  position: fixed; inset: 0;
  background: rgba(20,20,18,0.42);
  z-index: 90;
}

/* ---------- barra de código assinatura (motivo visual) ---------- */
.barstripe{
  height: 6px;
  width: 100%;
  background-image: repeating-linear-gradient(
    90deg,
    var(--ink) 0px, var(--ink) 2px,
    transparent 2px, transparent 4px,
    var(--ink) 4px, var(--ink) 5px,
    transparent 5px, transparent 9px,
    var(--ink) 9px, var(--ink) 12px,
    transparent 12px, transparent 14px
  );
  opacity: 0.9;
}
.barstripe.thin{ height: 3px; opacity: 0.55; }

/* ============================== LAYOUT ============================== */
#app{ display: flex; min-height: 100vh; }

/* ---------- SIDEBAR ESCURA ---------- */
.sidebar{
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #1C2537;
  border-right: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand{
  padding: 20px 20px 16px;
}
.brand-mark{
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark .glyph{
  width: 34px; height: 34px;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark .glyph svg{ width: 18px; height: 18px; }
.brand-name{
  font-weight: 800;
  font-size: 15px;
  color: #F0F2F5;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.brand-sub{
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.38);
  text-transform: uppercase;
  margin-top: 2px;
}
.sidebar .barstripe{ opacity: 0.15; }

.nav{
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
}
.nav::-webkit-scrollbar-thumb{ background: rgba(255,255,255,0.12); }
.nav::-webkit-scrollbar-thumb:hover{ background: rgba(255,255,255,0.22); }

.nav-item{
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.62);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  margin-bottom: 2px;
  transition: background .12s ease, color .12s ease;
  position: relative;
}
.nav-item svg{ width: 17px; height: 17px; flex-shrink: 0; opacity: .75; }
.nav-item:hover{ background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.92); }
.nav-item:hover svg{ opacity: 1; }
.nav-item.active{
  background: rgba(99,179,237,0.16);
  color: #90CDF4;
}
.nav-item.active::before{
  content: '';
  position: absolute;
  left: 0; top: 5px; bottom: 5px;
  width: 3px;
  background: #63B3ED;
  border-radius: 0 3px 3px 0;
}
.nav-item.active svg{ opacity: 1; }
.nav-item .badge{
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--danger);
  color: #fff;
  border-radius: 20px;
  padding: 1px 6px;
  min-width: 16px;
  text-align: center;
}
.nav-item.active .badge{ background: rgba(255,255,255,0.22); }
.nav-item .badge.ok{ background: var(--success); color: #F2F7F3; }
.nav-item.active .badge.ok{ background: rgba(255,255,255,0.22); }
.nav-item .badge:not(.ok):not([hidden])::before{
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 4px;
  vertical-align: middle;
  animation: badgePulse 1.8s infinite;
}
@keyframes badgePulse{ 0%,100%{ opacity: .5; } 50%{ opacity: 1; } }

.nav-group-label{
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  padding: 14px 12px 6px;
}

.sidebar-foot{
  padding: 12px 20px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-foot .clock{
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.35);
}
.sidebar-version{
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255,255,255,0.22);
  margin-top: 5px;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-version::before{
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #48BB78;
  flex-shrink: 0;
}

/* ---------- SEGURANÇA — status chips ---------- */
.security-status-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.security-chip{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  font-size: 12.5px;
}
.security-chip .chip-icon{
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.security-chip .chip-icon svg{ width: 16px; height: 16px; }
.security-chip.ok .chip-icon{ background: var(--success-bg); color: var(--success); }
.security-chip.warn .chip-icon{ background: var(--warning-bg); color: var(--warning); }
.security-chip.danger .chip-icon{ background: var(--danger-bg); color: var(--danger); }
.security-chip .chip-label{ font-weight: 600; color: var(--ink); line-height: 1.2; }
.security-chip .chip-sub{ font-size: 11px; color: var(--ink-3); }

/* ---------------------------- MAIN ---------------------------- */
.main{
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------------------------- TROCA DE ABA (transição) ---------------------------- */
.view{ animation: viewIn .16s ease; }
@keyframes viewIn{ from{ opacity: 0; transform: translateY(4px); } to{ opacity: 1; transform: translateY(0); } }

.topbar{
  min-height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 40;
}
.page-title{
  font-size: 18px;
  white-space: nowrap;
}
.page-eyebrow{
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 1px;
  display: block;
}

.scan-field{
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 40px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.scan-field.is-focused{
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(30,30,28,0.08);
}
.scan-field svg{ width: 16px; height: 16px; color: var(--ink-3); flex-shrink: 0; }
.scan-field input{
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
}
.scan-field input::placeholder{ color: var(--ink-3); font-family: var(--font-ui); }
.scan-pulse{
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  animation: pulse 1.8s infinite;
}
@keyframes pulse{
  0%,100%{ opacity: .35; transform: scale(0.85); }
  50%{ opacity: 1; transform: scale(1); }
}

.topbar-actions{ margin-left: auto; display: flex; gap: 10px; align-items: center; }

.view{
  flex: 1;
  padding: 22px 26px 60px;
  overflow-y: auto;
}
.view[hidden]{ display: none; }

/* ---------------------------- BUTTONS ---------------------------- */
.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform .06s ease, background .12s ease, border-color .12s ease, opacity .12s ease;
  white-space: nowrap;
}
.btn svg{ width: 15px; height: 15px; }
.btn:active{ transform: translateY(1px); }
.btn-primary{ background: var(--brand); color: var(--ink-inverse); }
.btn-primary:hover{ background: var(--brand-hover); }
.btn-secondary{ background: var(--surface); border-color: var(--border); color: var(--ink); }
.btn-secondary:hover{ background: var(--surface-alt); }
.btn-ghost{ background: transparent; color: var(--ink-2); }
.btn-ghost:hover{ background: var(--surface-alt); color: var(--ink); }
.btn-danger{ background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover{ opacity: .85; }
.btn-sm{ padding: 6px 10px; font-size: 12px; }
.btn-icon{ padding: 8px; }
.btn:disabled{ opacity: .45; cursor: not-allowed; }
.btn-block{ width: 100%; }

/* ---------------------------- CARDS / GRID ---------------------------- */
.grid{ display: grid; gap: 14px; }
.grid-stats{ grid-template-columns: repeat(4, 1fr); }
.grid-2{ grid-template-columns: 1.3fr 1fr; align-items: start; }
.grid-3{ grid-template-columns: repeat(3, 1fr); }

.card{
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: box-shadow .18s ease, border-color .18s ease;
}
.card:hover{ box-shadow: var(--shadow-sm); border-color: var(--border); }
.card-header{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title{ font-size: 14.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 7px; }
.card-title svg{ width: 16px; height: 16px; flex-shrink: 0; }
.card-link{ font-size: 12px; color: var(--ink-3); font-weight: 600; cursor: pointer; background:none; border:none; font-family: inherit;}
.card-link:hover{ color: var(--ink); text-decoration: underline; }

.stat-card{
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease;
}
.stat-card:hover{ box-shadow: var(--shadow-sm); border-color: var(--border); transform: translateY(-1px); }
.stat-label{
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-value{
  font-size: 24px;
  font-weight: 800;
  margin-top: 8px;
  letter-spacing: -0.02em;
  font-family: var(--font-mono);
}
.stat-sub{ font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.stat-card.warn .stat-value{ color: var(--danger); }
.stat-card .stat-icon{
  position: absolute; right: 14px; top: 14px;
  width: 15px; height: 15px; color: var(--ink-3); opacity: .5;
}

/* ---------------------------- TABLES ---------------------------- */
.table-wrap{ overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius-lg); background: var(--surface); }
table{ width: 100%; border-collapse: collapse; font-size: 13px; }
thead th{
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 11px 14px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
tbody td{
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--ink-2);
}
tbody tr:last-child td{ border-bottom: none; }
tbody tr:hover{ background: var(--bg-soft); }
td.num, th.num{ text-align: right; font-family: var(--font-mono); }
.cell-strong{ color: var(--ink); font-weight: 600; }
.mono{ font-family: var(--font-mono); }
.empty-row td{ text-align: center; padding: 40px 20px; color: var(--ink-3); }
tfoot td{ padding: 10px 14px; background: var(--bg-soft); border-top: 1.5px solid var(--border); font-weight: 700; color: var(--ink); }

/* ---------------------------- BADGES / TAGS ---------------------------- */
.tag{
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.tag-ok{ background: var(--success-bg); color: var(--success); }
.tag-warn{ background: var(--warning-bg); color: var(--warning); }
.tag-danger{ background: var(--danger-bg); color: var(--danger); }
.tag-info{ background: var(--info-bg); color: var(--info); }
.tag-neutral{ background: var(--surface-alt); color: var(--ink-2); }
.tag-dot{ width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------------------- FORMS ---------------------------- */
.field{ margin-bottom: 14px; }
.field-row{ display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label{
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field .hint{ font-size: 11px; color: var(--ink-3); margin-top: 5px; }
.field input, .field select, .field textarea{
  width: 100%;
  padding: 9px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color .12s ease;
}
.field input:focus, .field select:focus, .field textarea:focus{ border-color: var(--ink); }
.field .input-group{ display: flex; gap: 8px; }
.field textarea{ resize: vertical; min-height: 60px; }
.field-check{ display: flex; align-items: center; gap: 8px; }
.field-check input{ width: auto; }

.search-bar{
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.search-input{
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 38px;
}
.search-input svg{ width: 15px; height: 15px; color: var(--ink-3); }
.search-input input{ border: none; outline: none; background: transparent; width: 100%; font-size: 13px; }
.search-bar select{
  height: 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 10px;
  color: var(--ink-2);
  font-size: 13px;
}
.search-bar input[type="date"]{
  height: 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 10px;
  color: var(--ink-2);
  font-size: 13px;
}

/* ---------------------------- MODAL ---------------------------- */
.modal-overlay{
  position: fixed; inset: 0;
  background: rgba(20,20,18,0.42);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn .12s ease;
}
@keyframes fadeIn{ from{ opacity: 0; } to{ opacity: 1; } }
.modal{
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal.modal-lg{ max-width: 760px; }
.modal.modal-sm{ max-width: 400px; }
.modal-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-head h3{ font-size: 15px; }
.modal-body{ padding: 20px; overflow-y: auto; }
.modal-foot{
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-soft);
}
.modal-close{
  border: none; background: transparent; cursor: pointer;
  color: var(--ink-3); padding: 4px; border-radius: 6px;
}
.modal-close:hover{ background: var(--surface-alt); color: var(--ink); }

/* ---------------------------- TOASTS ---------------------------- */
.toast-stack{
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 400;
}
.toast{
  display: flex; align-items: center; gap: 10px;
  background: var(--ink);
  color: var(--ink-inverse);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  min-width: 260px;
  animation: toastIn .18s ease;
}
@keyframes toastIn{ from{ opacity:0; transform: translateY(8px);} to{opacity:1; transform: translateY(0);} }
.toast.ok{ background: #2E4E37; }
.toast.err{ background: #6E2E22; }
.toast svg{ width: 16px; height: 16px; flex-shrink: 0; }

/* ---------------------------- SCAN RESULT PANEL ---------------------------- */
.scan-result-card{
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.scan-result-head{
  padding: 16px 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  border-bottom: 1px dashed var(--border);
}
.scan-result-head .barcode-thumb{ background: var(--surface-alt); border-radius: 8px; padding: 6px 8px; }
.scan-result-body{ padding: 18px 20px; }
.scan-result-body .price-big{ font-family: var(--font-mono); font-size: 26px; font-weight: 800; }
.qty-stepper{
  display: inline-flex; align-items: center; border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
}
.qty-stepper button{
  border: none; background: var(--surface); width: 32px; height: 32px; cursor: pointer; font-size: 16px; color: var(--ink);
}
.qty-stepper button:hover{ background: var(--surface-alt); }
.qty-stepper input{
  width: 46px; text-align: center; border: none; border-left: 1.5px solid var(--border); border-right: 1.5px solid var(--border);
  height: 32px; font-family: var(--font-mono); font-weight: 700;
}

/* ---------------------------- LEITOR PAGE ---------------------------- */
.scanner-zone{
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 46px 30px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.scanner-zone.active-scan{ border-color: var(--ink); }
.scanner-zone .sweep{
  position: absolute; left: 0; right: 0; top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ink) 50%, transparent);
  opacity: 0;
}
.scanner-zone.sweeping .sweep{
  animation: sweep 1.1s ease-in-out;
}
@keyframes sweep{
  0%{ top: 10%; opacity: 0; }
  10%{ opacity: .7; }
  90%{ opacity: .7; }
  100%{ top: 90%; opacity: 0; }
}
.scanner-zone .big-input{
  font-family: var(--font-mono);
  font-size: 20px;
  text-align: center;
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  max-width: 420px;
  border-bottom: 2px solid var(--border);
  padding: 10px 6px;
  color: var(--ink);
}
.scanner-zone .big-input:focus{ border-color: var(--ink); }
.scan-icon-lg{ width: 40px; height: 40px; color: var(--ink-3); margin-bottom: 14px; }

.scan-log-item{
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.scan-log-item:last-child{ border-bottom: none; }
.scan-log-item .time{ font-family: var(--font-mono); color: var(--ink-3); font-size: 11px; width: 60px; flex-shrink: 0;}

/* ---------------------------- PDV ---------------------------- */
.pdv-layout{ display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.cart-item{
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.cart-item:last-child{ border-bottom: none; }
.cart-item .name{ font-weight: 600; font-size: 13px; }
.cart-item .meta{ font-size: 11.5px; color: var(--ink-3); font-family: var(--font-mono); }
.summary-row{ display: flex; justify-content: space-between; padding: 7px 0; font-size: 13px; color: var(--ink-2); }
.summary-row.total{ font-size: 18px; font-weight: 800; color: var(--ink); border-top: 1.5px dashed var(--border); margin-top: 6px; padding-top: 12px; font-family: var(--font-mono); }
.pay-methods{ display: grid; grid-template-columns: repeat(auto-fit, minmax(84px,1fr)); gap: 8px; margin: 10px 0 16px; }
.pay-btn{
  border: 1.5px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  padding: 9px 4px; font-size: 11.5px; font-weight: 600; cursor: pointer; color: var(--ink-2); text-align:center;
}
.pay-btn.selected{ border-color: var(--ink); background: var(--brand); color: var(--ink-inverse); }

/* ---------------------------- MINI BAR CHART ---------------------------- */
.chart-wrap{ display: flex; align-items: flex-end; gap: 14px; height: 160px; padding: 10px 6px 0; }
.chart-col{ flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.chart-bars{ display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart-bar{ width: 12px; border-radius: 3px 3px 0 0; transition: height .3s ease; }
.chart-bar.receita{ background: var(--ink); }
.chart-bar.despesa{ background: var(--ink-3); }
.chart-label{ font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); }
.chart-legend{ display:flex; gap:16px; margin-top: 14px; font-size: 12px; color: var(--ink-2); }
.chart-legend span{ display:flex; align-items:center; gap:6px; }
.chart-legend .dot{ width:9px;height:9px;border-radius:2px; }

/* ---------------------------- MISC ---------------------------- */
.divider{ height: 1px; background: var(--border-soft); margin: 18px 0; }
.muted{ color: var(--ink-3); }
.section-title{ font-size: 13px; font-weight: 700; margin-bottom: 10px; display:flex; align-items:center; gap:8px;}
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.stack{ display:flex; flex-direction:column; gap:10px; }
.row-gap{ display:flex; gap:10px; align-items:center; }
.empty-state{ text-align:center; padding: 50px 20px; color: var(--ink-3); }
.empty-state svg{ width:34px;height:34px;margin-bottom:12px;opacity:.5; }
.kbd{ font-family: var(--font-mono); background: var(--surface-alt); padding: 1px 6px; border-radius: 4px; font-size: 11px; border: 1px solid var(--border); }
.checkbox-cell{ width: 34px; }
a.link-quiet{ color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--border); cursor: pointer; }

/* barcode svg inside table rows */
.mini-barcode svg{ width: auto; height: 26px; display: block; }
.barcode-preview svg{ width: 100%; height: auto; }
/* qualquer outro "buraco" de código de barras/QR sem classe própria (recibo,
   etiquetas) — deixa o tamanho a cargo do que o JsBarcode/QRCode já define */
.code-holder svg{ width: auto; height: auto; }

/* scrollbar */
::-webkit-scrollbar{ width: 9px; height: 9px; }
::-webkit-scrollbar-track{ background: transparent; }
::-webkit-scrollbar-thumb{ background: #CFCFC7; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover{ background: #BEBEB4; }

/* ---------------------------- ETIQUETA (pré-visualização em tela) ---------------------------- */
.etiqueta-preview{
  width: 58mm; min-height: 32mm; box-sizing: border-box;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.etiqueta-preview .barstripe{ margin-bottom: 4px; }
.etiqueta-loja{ font-family: var(--font-mono); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.etiqueta-nome{ font-weight: 700; font-size: 13px; line-height: 1.25; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.etiqueta-var{ font-size: 11px; color: var(--ink-2); margin-top: 2px; }
.etiqueta-linha{ display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: 8px; }
.etiqueta-preco{ font-family: var(--font-mono); font-weight: 800; font-size: 16px; white-space: nowrap; }
.etiqueta-sku{ font-family: var(--font-mono); font-size: 9px; color: var(--ink-3); margin-top: 5px; }

/* ---------------------------- PRINT ---------------------------- */
/* ---------------------------- BOOT LOADING ---------------------------- */
#boot-loading{
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity .25s ease;
}
#boot-loading.hidden{ opacity: 0; pointer-events: none; }
.boot-loading-inner{
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: .04em;
  color: var(--ink-2);
}

/* A #print-area fica oculta na tela normal — ela só existe para receber o
   conteúdo do cupom/relatório no instante da impressão (ver @media print). */
#print-area{ display: none; }

@media print{
  body *{ visibility: hidden; }
  #print-area{ display: block; position: absolute; left: 0; top: 0; width: 100%; }
  #print-area, #print-area *{ visibility: visible; }
  .no-print{ display: none !important; }
  @page{ margin: 8mm; }
}

/* ---------------------------- RESPONSIVE ---------------------------- */
@media (max-width: 1100px){
  .grid-stats{ grid-template-columns: repeat(2,1fr); }
  .grid-2{ grid-template-columns: 1fr; }
  .pdv-layout{ grid-template-columns: 1fr; }
}
@media (max-width: 760px){
  .menu-toggle{ display: inline-flex; }
  .sidebar{
    position: fixed;
    left: 0; top: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open{ transform: translateX(0); }
  .sidebar-backdrop.open{ display: block; }
  .topbar{ padding: 10px 14px; gap: 10px; height: auto; flex-wrap: wrap; }
  .topbar > div:first-child{ order: 1; }
  .menu-toggle{ order: 0; }
  .topbar-actions{ order: 2; margin-left: 0; }
  .scan-field{ order: 3; max-width: none; width: 100%; flex-basis: 100%; }
  .grid-stats{ grid-template-columns: 1fr 1fr; }
  .field-row{ grid-template-columns: 1fr; }
  .view{ padding: 16px 14px 60px; }
}
@media (max-width: 420px){
  .grid-stats{ grid-template-columns: 1fr; }
  .security-status-grid{ grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ==========================================================================
   TOQUE / MOBILE / PWA
   Pensado pro sistema funcionar de verdade como "app" no celular: alvos de
   toque maiores (não dá pra contar com :hover em tela sensível ao toque),
   sem zoom automático do navegador ao focar um campo, respeito à área
   segura de notch/barra de gestos, e modal em estilo "bottom sheet" (sobe
   do rodapé) no lugar do modal flutuante central, mais parecido com o
   padrão visual de app mobile.
   ========================================================================== */
html{ -webkit-text-size-adjust: 100%; }
button, .btn, .nav-item, .modal-close, .tab{ -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* Em qualquer dispositivo de toque (celular OU tablet, não importa a
   largura de tela) os alvos clicáveis crescem: ~40px é o mínimo confortável
   pra dedo, contra os ~28-32px pensados originalmente só pra mouse. Isso
   importa especialmente nas linhas de tabela, onde há vários botões de
   ação (editar/excluir/etc.) lado a lado e um toque errado pode ser caro
   (ex: excluir um produto sem querer). */
@media (pointer: coarse){
  .btn{ min-height: 40px; }
  .btn-sm{ min-height: 36px; }
  .btn-icon{ min-width: 40px; min-height: 40px; }
  .btn-icon.btn-sm{ min-width: 38px; min-height: 38px; padding: 8px; }
  .nav-item{ min-height: 46px; padding: 12px; }
  .modal-close{ min-width: 38px; min-height: 38px; display: inline-flex; align-items: center; justify-content: center; }
  .menu-toggle{ min-width: 40px; min-height: 40px; }
  tbody td{ padding: 12px 14px; }
  .row-gap{ gap: 8px; }
  .scan-field-cam-btn{ width: 34px; height: 34px; }
  .pay-btn{ min-height: 44px; }
  /* campo com pelo menos 16px evita que o Safari/Chrome no iPhone dê zoom
     na tela inteira só por causa do foco no campo */
  .field input, .field select, .field textarea,
  .search-bar select, .search-bar input, .search-input input,
  #global-scan-input{ font-size: 16px; }
}

/* Área segura (notch, "ilha dinâmica", barra de gestos) -- só funciona
   junto com viewport-fit=cover no <meta name="viewport"> do index.html */
.topbar{ padding-top: env(safe-area-inset-top); }
.sidebar-foot{ padding-bottom: max(16px, env(safe-area-inset-bottom)); }

@media (max-width: 760px){
  .modal-overlay{ align-items: flex-end; padding: 0; }
  .modal{
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    animation: sheetUp .22s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal::before{
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 99px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }
  .modal-foot{ flex-wrap: wrap; }
  .modal-foot .btn{ flex: 1; }
}
@keyframes sheetUp{ from{ transform: translateY(24px); opacity: .4; } to{ transform: translateY(0); opacity: 1; } }

@media (display-mode: standalone){
  /* instalado como app (sem barra de endereço do navegador): dá mais
     respiro no topo em telas com notch */
  .topbar{ padding-top: max(14px, env(safe-area-inset-top)); }
}

/* ---------------------------- LEITOR POR CÂMERA ---------------------------- */
.scan-field{ position: relative; }
.scan-field-cam-btn{
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border: none; border-radius: var(--radius-sm);
  background: var(--surface-alt); color: var(--ink-2);
  cursor: pointer;
}
.scan-field-cam-btn svg{ width: 14px; height: 14px; }
.scan-field-cam-btn:active{ transform: translateY(1px); }

.camera-scan-modal .modal-body{ padding: 0; background: #0c0c0b; }
.camera-scan-wrap{ position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 62vh; overflow: hidden; background: #000; }
.camera-scan-wrap video{ width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-scan-frame{
  position: absolute; inset: 18% 14%;
  border: 2.5px solid rgba(245,245,242,0.9);
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.38);
  pointer-events: none;
  transition: border-color .15s ease;
}
.camera-scan-frame.hit{ border-color: var(--success); }
.camera-scan-status{
  position: absolute; left: 0; right: 0; bottom: 14px;
  text-align: center; font-size: 12.5px; color: #F5F5F2;
  text-shadow: 0 1px 4px rgba(0,0,0,.7);
  padding: 0 16px;
}
.camera-scan-error{ padding: 22px 20px; color: var(--ink-2); font-size: 13px; line-height: 1.6; }

/* ==========================================================================
   TELA DE LOGIN (Supabase Auth)
   ========================================================================== */
.login-screen{
  display: none;
  position: fixed; inset: 0; z-index: 999;
  align-items: center; justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-screen:not([hidden]){ display: flex; }
.login-card{
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px;
}
.login-title{ font-size: 18px; font-weight: 800; color: var(--ink); letter-spacing: -0.01em; }
.login-sub{ font-size: 12.5px; color: var(--ink-3); margin: 4px 0 20px; }
.login-erro{
  font-size: 12px; color: var(--danger); background: var(--danger-bg);
  border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 6px; line-height: 1.5;
}
.login-hint{ font-size: 11px; color: var(--ink-3); text-align: center; margin-top: 16px; line-height: 1.5; }