/* Driver Controler — estilos mobile-first */
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #23201a;
  --muted: #6b7280;
  --brand: #60a5fa;
  --brand-dark: #1d4ed8;
  --accent: #60a5fa;
  --danger: #d64545;
  --ok: #1f9d55;
  --line: #e5e7eb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(60, 40, 10, 0.08);
  --tabbar-h: 64px;
}
* { box-sizing: border-box; }
/* Garante que o atributo hidden sempre esconda o elemento,
   mesmo quando outra regra define display (ex.: modal-backdrop) */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

/* Barra superior */
#appbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.appbar-title { display: flex; align-items: center; gap: 10px; }
.appbar-title strong { display: block; font-size: 17px; letter-spacing: 0.2px; }
.appbar-title small { display: block; font-size: 11px; opacity: 0.85; }
.appbar-logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: rgba(255,255,255,0.16);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
}
.appbar-right { display: flex; align-items: center; gap: 8px; }
.appbar-date { font-size: 12px; opacity: 0.9; text-align: right; line-height: 1.4; }
.icon-btn {
  background: rgba(255,255,255,0.16); color: #fff; border: none;
  width: 40px; height: 40px; border-radius: 50%; font-size: 20px; cursor: pointer; flex: none;
}

/* Conteúdo */
#view { padding: 14px 14px 20px; max-width: 640px; margin: 0 auto; }
h2.page-title { font-size: 20px; margin: 4px 2px 12px; }
h3.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin: 18px 2px 8px; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
  border: 1px solid var(--line);
}
.card.tint-warn { border-left: 4px solid var(--accent); }
.card.tint-danger { border-left: 4px solid var(--danger); }
.card.tint-ok { border-left: 4px solid var(--ok); }
.card.trial { border-left: 4px solid var(--accent); }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Estatísticas do painel */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.stat .num { font-size: 22px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.danger .num { color: var(--danger); }
.stat.ok .num { color: var(--ok); }

/* Seletor de período (segmentado) */
.seg { display: flex; gap: 6px; margin-bottom: 12px; }
.seg-btn {
  flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 10px 4px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.seg-btn.active { background: #1f2937; border-color: var(--brand); color: #fff; }

/* Listas */
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow);
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.list-item:active { background: #faf6ee; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: #1f2937; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.avatar.in { background: var(--ok); }
.avatar.out { background: var(--danger); }
.avatar.off { background: #9a938a; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; margin: 2px 4px 2px 0;
  white-space: nowrap;
}
.badge.ok { background: #e3f5e9; color: #14663a; }
.badge.warn { background: #fff3d9; color: #8a5c00; }
.badge.danger { background: #fde7e7; color: #a02c2c; }
.badge.info { background: #e2eefb; color: #1d4f9c; }
.badge.neutral { background: #edf1ef; color: var(--muted); }

.money-in { color: var(--ok); }
.money-out { color: var(--danger); }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 12px 16px;
  font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
  background: #1f2937; color: #fff; box-shadow: var(--shadow);
}
.btn:active { transform: scale(0.98); }
.btn.block { display: flex; width: 100%; }
.btn.secondary { background: #ece5d5; color: var(--ink); }
.btn.ghost { background: transparent; color: var(--brand); box-shadow: none; padding: 8px 10px; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1; }
.btn-col { display: flex; flex-direction: column; gap: 8px; }

/* Formulários */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 5px; color: #4a4234; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 15px;
  padding: 11px 12px; border: 1px solid #d5cbb6; border-radius: 10px;
  background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Chips */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; }
.chips.wrap { flex-wrap: wrap; overflow-x: visible; }
.chip {
  flex: none; border: 1px solid #d5cbb6; background: #fff; color: var(--ink);
  border-radius: 999px; padding: 8px 13px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.active { background: #1f2937; border-color: var(--brand); color: #fff; }
.chip.cat { padding: 11px 15px; font-size: 14px; }
.chip.add { border-style: dashed; color: var(--brand); }
.chip.static { cursor: default; display: inline-flex; align-items: center; gap: 6px; }
.chip-x {
  border: none; background: #fde7e7; color: #a02c2c; border-radius: 50%;
  width: 20px; height: 20px; font-size: 11px; cursor: pointer; line-height: 1;
}

/* Barra de progresso (meta diária) */
.progress { height: 10px; background: #ece5d5; border-radius: 999px; margin-top: 10px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: #1f2937; border-radius: 999px; transition: width 0.4s; }

/* Gráficos */
canvas.chart { width: 100%; height: 230px; display: block; }
canvas.chart.donut { height: 200px; }
.legend { margin-top: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; border-bottom: 1px solid var(--line); }
.legend-item:last-child { border-bottom: none; }
.legend-item .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

/* Overlay / modal / toast */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(20, 15, 8, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  background: #23201a; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; z-index: 60; box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  max-width: 90vw; text-align: center;
}

/* Barra de abas */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
  display: flex;
}
.tab {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font: inherit;
}
.tab-icon { font-size: 19px; line-height: 1; }
.tab-label { font-size: 11px; font-weight: 600; }
.tab.active { color: var(--brand); }

.empty { text-align: center; color: var(--muted); padding: 34px 16px; font-size: 14px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; font-weight: 600; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th, table.mini td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
table.mini th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ---- Tela de licença ---- */
.lock-screen { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.lock-card { text-align: center; max-width: 320px; width: 100%; }
.lock-logo {
  width: 72px; height: 72px; border-radius: 20px;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff; font-size: 28px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.lock-input {
  width: 100%; font-size: 28px; text-align: center; letter-spacing: 12px;
  text-indent: 12px; padding: 12px; border: 2px solid var(--line);
  border-radius: 12px; margin: 12px 0; background: #fff; color: var(--ink);
}
.lock-input:focus { border-color: var(--brand); outline: none; }
.lock-card .btn { width: 100%; }

/* ---- Botão flutuante da calculadora ---- */
.fab {
  position: fixed; right: 16px; z-index: 30;
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  width: 62px; height: 62px; border-radius: 50%;
  background: #1f2937; color: #fff; font-size: 30px; line-height: 1;
  border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0,0,0,0.30);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.fab:active { transform: scale(0.94); }

/* ---- Calculadora "Vale a pena?" ---- */
.calc-hero {
  background: var(--accent); color: #fff;
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 12px;
}
.calc-hero h2 { font-size: 20px; margin: 0 0 2px; }
.calc-hero p { font-size: 13px; margin: 0; opacity: 0.95; }
.calc-back {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.22); color: #fff;
  font-size: 24px; line-height: 1; cursor: pointer;
}
.card-title { font-size: 15px; color: var(--muted); margin: 0 0 10px; }
.calc-input {
  width: 100%; font-size: 20px; font-weight: 700;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink);
}
.calc-input:focus { border-color: var(--brand); outline: none; background: #fff; }
.verdict {
  border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 700;
  text-align: center; margin-bottom: 8px;
}
.verdict-ok { background: #e3f5e9; color: #166534; }
.verdict-warn { background: #fef3c7; color: #92400e; }
.verdict-bad { background: #fde7e7; color: #b91c1c; }
.verdict-none { background: #f5f2ec; color: var(--muted); }
.kv .big { font-size: 17px; }
.kv .avg { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.up { color: var(--ok); }
.down { color: var(--danger); }

/* ---- Tela de ativação: planos, oferta e indicação ---- */
.lock-card.wide { max-width: 340px; }
.promo-tag { display: inline-block; background: #dcfce7; color: #15803d; font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 20px; }
.plan-card { position: relative; border: 1px solid #e2e8f0; border-radius: 12px; padding: 12px 14px; margin: 10px 0; text-align: left; background: #fff; }
.plan-card.popular { border: 2px solid var(--brand); box-shadow: 0 4px 14px rgba(0,0,0,.10); }
.badge-pop { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: #f59e0b; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .6px; padding: 3px 12px; border-radius: 20px; white-space: nowrap; }
.plan-price { font-size: 22px; font-weight: 800; color: var(--brand); margin: 2px 0 8px; }
.plan-note { color: #059669; font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.strike { color: #94a3b8; font-size: 12px; text-decoration: line-through; }
.btn.wa { background: #25d366; color: #fff; width: 100%; }
.offer-banner { background: #fef9c3; border: 1px solid #fde68a; border-radius: 12px; padding: 12px 14px; margin: 12px 0; text-align: left; font-size: 13px; line-height: 1.5; color: #78350f; }
.offer-tag { display: inline-block; background: #f59e0b; color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .8px; padding: 2px 10px; border-radius: 20px; margin-bottom: 6px; }
.or-div { display: flex; align-items: center; gap: 10px; margin: 14px 2px 10px; color: #64748b; font-size: 12px; }
.or-div::before, .or-div::after { content: ''; flex: 1; height: 1px; background: #e2e8f0; }
.ref-code { font-size: 24px; font-weight: 800; letter-spacing: 2px; text-align: center; margin: 8px 0 12px; color: var(--brand); }

/* ---- Termos de Uso ---- */
.terms-screen { min-height: 100dvh; display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px 40px; background: var(--bg); }
.terms-card { width: 100%; max-width: 560px; background: #fff; border-radius: 16px; padding: 24px 20px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.terms-card h2 { margin: 0 0 4px; }
.terms-body { max-height: 46dvh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px 10px; margin: 12px 0 16px; background: #fafcfb; }
.terms-clause { font-size: 14px; margin: 12px 0 4px; color: var(--brand-dark); }
.terms-body p { font-size: 13px; color: var(--muted); margin: 0 0 6px; line-height: 1.55; }
.btn-link { display: block; width: 100%; background: none; border: none; color: var(--brand); font: inherit; font-weight: 700; padding: 12px; cursor: pointer; }
.big{font-size:26px;font-weight:800}
.pill{display:inline-block;background:#e5e7eb;border-radius:20px;padding:4px 10px;font-size:12px}
.field span{display:block;font-size:13px;font-weight:700;margin-bottom:5px}
.fab{position:fixed;right:16px;bottom:76px;width:auto;height:auto;background:#1d4ed8;color:#fff;border:0;border-radius:28px;padding:14px 18px;font-weight:800;font-size:14px;white-space:nowrap;box-shadow:0 4px 14px rgba(0,0,0,.3);z-index:30}

/* Ícones coloridos do menu (um por aba, sempre coloridos) */
.tab[data-tab="home"] .tab-icon { color: #16a34a; }
.tab[data-tab="home"].active .tab-label { color: #16a34a; }
.tab[data-tab="pdv"] .tab-icon { color: #ea580c; }
.tab[data-tab="pdv"].active .tab-label { color: #ea580c; }
.tab[data-tab="produtos"] .tab-icon { color: #d97706; }
.tab[data-tab="produtos"].active .tab-label { color: #d97706; }
.tab[data-tab="clientes"] .tab-icon { color: #2563eb; }
.tab[data-tab="clientes"].active .tab-label { color: #2563eb; }
.tab[data-tab="reports"] .tab-icon { color: #7c3aed; }
.tab[data-tab="reports"].active .tab-label { color: #7c3aed; }
.tab[data-tab="settings"] .tab-icon { color: #6b7280; }
.tab[data-tab="settings"].active .tab-label { color: #6b7280; }
.tab.active { font-weight: 700; }

.calc-display{font-size:32px;font-weight:800;text-align:right;padding:10px 12px;background:#f3f4f6;border-radius:12px;margin:8px 0}
.calc-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.calc-btn{padding:14px 0;font-size:18px;font-weight:700;border:1px solid var(--line);border-radius:12px;background:#fff;cursor:pointer}
.calc-btn:active{background:#ffedd5}

/* ---- Frente de loja (PDV): grade de produtos + carrinho lateral ---- */
.pdv-busca{display:flex;gap:8px;align-items:center}
.pdv-busca input{flex:1}
.pdv-scan{flex:none;background:#1d4ed8;color:#fff;border:0;border-radius:10px;padding:11px 14px;font-weight:800;white-space:nowrap;cursor:pointer}
.pdv-layout{display:block}
.pdv-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}
.pdv-prod{cursor:pointer;text-align:left}
.pdv-prod strong{display:block;font-size:15px}
.pdv-prod .preco{font-size:17px;font-weight:800;color:#1d4ed8}
.pdv-carrinho{position:sticky;top:8px}
.pdv-troco{font-size:20px;font-weight:800;color:#166534}
.pdv-qtd{display:inline-flex;gap:6px;align-items:center}
.pdv-qtd button{width:28px;height:28px;border-radius:8px;border:1px solid var(--line);background:#fff;font-weight:800;cursor:pointer}
.scan-box{border:3px solid #1d4ed8;border-radius:12px;overflow:hidden;background:#000}
.scan-box video{width:100%;display:block;max-height:280px;object-fit:cover}
@media (min-width:900px){
  .pdv-layout{display:grid;grid-template-columns:1fr 380px;gap:16px;align-items:start}
  .pdv-grid{grid-template-columns:repeat(3,1fr)}
  #view{max-width:1200px;margin:0 auto}
}
