/* OBRIGATÓRIO no topo: sem isso, display:flex sobrescreve atributo hidden */
[hidden] { display: none !important; }

:root {
  --cdt-verde: #1E4D3D;
  --cdt-verde-claro: #2E7355;
  --cdt-bege: #FAF7F2;
  --cdt-paper: #FFFFFF;
  --cdt-line: #D8D2C5;
  --cdt-text: #1A2E25;
  --cdt-muted: #6B7770;
  --cdt-warn: #C84B1E;
  --cdt-ok: #2E7355;
  --cdt-promo: #7AD694;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--cdt-text);
  background: var(--cdt-bege);
  min-height: 100vh;
}

body { padding-top: 56px; }

/* ── Topbar ─────────────────────────────────────────── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--cdt-verde); color: #fff;
  box-shadow: var(--shadow-md); z-index: 50;
}
#topbar .brand { font-weight: 700; letter-spacing: 0.5px; font-size: 17px; }
#topbar .brand small { font-weight: 400; opacity: 0.75; margin-left: 6px; font-size: 12px; }
#topbar .topbar-right { display: flex; align-items: center; gap: 12px; }
#topbar #user-info { font-size: 13px; opacity: .9; }
#topbar button {
  background: rgba(255,255,255,.12);
  color: #fff; border: 1px solid rgba(255,255,255,.2);
  padding: 6px 12px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 13px;
}
#topbar button:hover { background: rgba(255,255,255,.22); }

/* ── Bottom nav (operação) ──────────────────────────── */
#bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; height: 60px;
  display: flex; background: var(--cdt-paper);
  border-top: 1px solid var(--cdt-line);
  z-index: 40;
}
#bottomnav button {
  flex: 1; background: transparent; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; color: var(--cdt-muted); padding: 6px 4px;
  border-top: 2px solid transparent;
}
#bottomnav button .icon { font-size: 20px; line-height: 1; margin-bottom: 2px; }
#bottomnav button.active { color: var(--cdt-verde); border-top-color: var(--cdt-verde); }
body:not([data-nav="on"]) #bottomnav { display: none; }

/* ── Containers ─────────────────────────────────────── */
main, section.screen {
  max-width: 760px; margin: 0 auto; padding: 16px;
  padding-bottom: 80px;
}
.card {
  background: var(--cdt-paper);
  border: 1px solid var(--cdt-line);
  border-radius: var(--r-md);
  padding: 16px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
h1, h2, h3 { color: var(--cdt-verde); margin-top: 0; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

/* ── Login ──────────────────────────────────────────── */
.screen-login {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 56px);
}
.login-card {
  background: var(--cdt-paper);
  max-width: 380px; width: 100%;
  padding: 28px; border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.login-card h1 { text-align: center; margin-bottom: 24px; }
.login-card .form-group { margin-bottom: 14px; }
.login-card label { display: block; font-size: 13px; color: var(--cdt-muted); margin-bottom: 4px; }
.login-card input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--cdt-line); border-radius: var(--r-sm);
  font-size: 15px; font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--cdt-verde); }
.erro-box {
  background: #FBEDE7; color: var(--cdt-warn);
  border: 1px solid #F0CFC3;
  padding: 10px; border-radius: var(--r-sm);
  margin-bottom: 12px; font-size: 13px;
}

/* ── Botões ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: filter .15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--cdt-verde); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-secondary { background: var(--cdt-paper); color: var(--cdt-verde); border-color: var(--cdt-verde); }
.btn-outline { background: transparent; color: var(--cdt-verde); border: 1px solid var(--cdt-line); }
.btn-warn { background: var(--cdt-warn); color: #fff; }
.btn-ghost { background: transparent; color: var(--cdt-muted); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; }

/* ── Forms ──────────────────────────────────────────── */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; color: var(--cdt-muted); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--cdt-line); border-radius: var(--r-sm);
  font-size: 14px; font-family: inherit;
}
.form-group input[type="number"] { text-align: right; }

.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }

/* ── Tabela ─────────────────────────────────────────── */
.tabela {
  width: 100%; border-collapse: collapse;
  background: var(--cdt-paper);
  border: 1px solid var(--cdt-line); border-radius: var(--r-md);
  overflow: hidden;
}
.tabela th, .tabela td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--cdt-line);
  font-size: 13px;
}
.tabela th { background: var(--cdt-bege); color: var(--cdt-verde); font-weight: 600; }
.tabela tr:hover { background: rgba(30,77,61,0.04); }
.tabela .right { text-align: right; }
.tabela .sem-estoque { background: #FBEDE7; color: var(--cdt-warn); }
.tabela .promo { background: rgba(122,214,148,.18); }

/* ── Toast ──────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  max-width: 90%;
  padding: 12px 18px;
  background: var(--cdt-text); color: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 200; opacity: 0; transition: opacity .25s;
  pointer-events: none;
}
#toast.show { opacity: 1; }
#toast.success { background: var(--cdt-ok); }
#toast.error   { background: var(--cdt-warn); }
#toast.info    { background: var(--cdt-verde-claro); }

/* ── Carrinho de venda ──────────────────────────────── */
.carrinho-item {
  display: grid; grid-template-columns: 1fr 80px 90px 30px;
  gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--cdt-line);
}
.carrinho-item .nome { font-weight: 600; }
.carrinho-item .preco-info { font-size: 11px; color: var(--cdt-muted); }
.carrinho-item input { padding: 6px 8px; font-size: 13px; }
.carrinho-item .subtotal { font-weight: 600; text-align: right; }
.carrinho-item .alerta { color: var(--cdt-warn); font-size: 11px; font-weight: 700; }

.total-bar {
  position: sticky; bottom: 60px;
  background: var(--cdt-verde); color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: var(--r-md); margin-top: 16px;
}
.total-bar .valor { font-size: 22px; font-weight: 700; }

/* ── Install banner ─────────────────────────────────── */
#install-banner {
  position: fixed; left: 12px; right: 12px;
  bottom: 76px;
  background: var(--cdt-paper); border: 1px solid var(--cdt-line);
  border-radius: var(--r-md); box-shadow: var(--shadow-md);
  padding: 12px; z-index: 90;
  max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 10px;
}
.install-body { display: flex; align-items: center; gap: 12px; }
.install-icon { width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0; }
.install-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.install-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Scanner modal ──────────────────────────────────── */
#scanner-modal {
  position: fixed; inset: 0; background: #000; z-index: 300;
  display: flex; align-items: center; justify-content: center;
}
.scanner-frame { position: relative; width: 100%; height: 100%; }
#scanner-video { width: 100%; height: 100%; object-fit: cover; }
.scanner-overlay { position: absolute; inset: 0; pointer-events: none; }
.scanner-overlay::before {
  content: ''; position: absolute; top: 30%; left: 10%; right: 10%; bottom: 30%;
  border: 3px solid var(--cdt-warn); border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
}
.scanner-line {
  position: absolute; top: 50%; left: 12%; right: 12%; height: 2px;
  background: var(--cdt-warn);
  animation: scanline 1.6s ease-in-out infinite;
}
@keyframes scanline { 0%, 100% { top: 32%; } 50% { top: 68%; } }
.scanner-status {
  position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%);
  color: #fff; background: rgba(0,0,0,.6); padding: 8px 14px; border-radius: 8px;
}
.scanner-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,.95); color: #000; border: none;
  padding: 10px 16px; border-radius: 8px; font-weight: 600;
}
.scanner-controls { position: absolute; top: 16px; left: 16px; display: flex; gap: 8px; }
.scanner-ctrl {
  background: rgba(255,255,255,.95); color: #000; border: none;
  padding: 10px 14px; border-radius: 8px; font-weight: 600;
}
.scanner-zoom-wrap {
  position: absolute; bottom: 150px; left: 16px; right: 16px;
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,.55); padding: 8px 14px; border-radius: 22px; color: #fff;
}
.scanner-zoom-wrap input[type=range] { flex: 1; accent-color: var(--cdt-warn); }

/* ── 2FA setup ──────────────────────────────────────── */
.totp-secret-display {
  font-family: monospace; font-size: 17px; letter-spacing: 2px;
  background: var(--cdt-bege);
  padding: 14px; border-radius: var(--r-sm);
  word-break: break-all;
  user-select: all; -webkit-user-select: all;
}

/* ── Botões de utilidade ────────────────────────────── */
.atualizar-card {
  text-align: center;
  background: transparent;
  border: 1px dashed var(--cdt-line);
  padding: 12px;
}
.atualizar-card p { font-size: 12px; color: var(--cdt-muted); margin: 0 0 6px; }

/* ── Layout helpers ─────────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.muted { color: var(--cdt-muted); font-size: 12px; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge-ok { background: rgba(46,115,85,.12); color: var(--cdt-ok); }
.badge-warn { background: rgba(200,75,30,.12); color: var(--cdt-warn); }
.badge-info { background: rgba(30,77,61,.12); color: var(--cdt-verde); }
