* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #0f172a; background: #f1f5f9; }
body { min-height: 100vh; padding-bottom: 96px; }
.container { max-width: 720px; margin: 0 auto; padding: 16px; }
.muted { color: #64748b; font-size: 14px; }
.link { color: #2563eb; font-weight: 500; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link-btn { background: none; border: none; color: #64748b; font-size: 14px; cursor: pointer; padding: 0; font-family: inherit; }
.link-btn:hover { color: #0f172a; }

/* Topbar */
.topbar { background: white; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }

/* Cards */
.cards { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.card { padding: 12px; border-radius: 12px; text-align: left; border: 2px solid transparent; cursor: pointer; font-family: inherit; }
.card.card-amber { background: #fef3c7; color: #78350f; }
.card.card-red { background: #fee2e2; color: #7f1d1d; }
.card.card-green { background: #d1fae5; color: #064e3b; cursor: default; }
.card.active { border-color: currentColor; }
.card-label { font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.card-value { font-size: 24px; font-weight: 700; }
.card.card-green .card-value { font-size: 20px; }

/* Busca */
.search { position: relative; margin-bottom: 16px; }
.search-icon { position: absolute; left: 12px; top: 14px; color: #94a3b8; }
.search input {
  width: 100%; padding: 12px 16px 12px 36px; border: 1px solid #cbd5e1; border-radius: 12px;
  font-size: 16px; background: white; font-family: inherit;
}
.search input:focus { outline: 2px solid #3b82f6; border-color: #3b82f6; }

/* Filtro ativo */
.filtro-ativo { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 12px; }
.badge { background: #dbeafe; color: #1e40af; padding: 4px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; }

/* Lista */
.lista { display: flex; flex-direction: column; gap: 8px; }
.cliente-item {
  display: block; background: white; border-radius: 12px; padding: 14px; border: 1px solid #f1f5f9;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04); text-decoration: none; color: inherit;
}
.cliente-item:active { background: #f8fafc; }
.cliente-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cliente-info { flex: 1; min-width: 0; }
.cliente-nome { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cliente-tel { font-size: 14px; color: #64748b; }
.cliente-saldo { text-align: right; flex-shrink: 0; }
.cliente-valor { font-weight: 700; }
.cliente-valor.devendo { color: #dc2626; }
.cliente-valor.em-dia { color: #059669; }
.status-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 500; display: inline-block; margin-top: 2px; }
.status-em-dia { background: #d1fae5; color: #065f46; }
.status-vence-hoje { background: #fef3c7; color: #78350f; }
.status-atrasado { background: #fee2e2; color: #991b1b; }
.status-futuro { background: #f1f5f9; color: #475569; }
.status-aberto { background: #fef3c7; color: #78350f; }

/* Empty */
.empty { text-align: center; padding: 48px 16px; color: #94a3b8; }
.empty-icon { font-size: 40px; margin-bottom: 8px; }

/* FAB */
.fab {
  position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px;
  background: #2563eb; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 32px; text-decoration: none; box-shadow: 0 4px 16px rgba(37,99,235,0.4);
}
.fab:active { transform: scale(0.95); }

/* Forms (compartilhado) */
.form-card { background: white; border-radius: 12px; padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); margin-bottom: 16px; }
.form-card h2 { font-size: 16px; margin-bottom: 12px; }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 14px; font-weight: 500; color: #334155; margin-bottom: 4px; }
.form-row input[type=text], .form-row input[type=tel], .form-row input[type=number], .form-row input[type=date], .form-row input[type=search], .form-row textarea, .form-row select {
  width: 100%; padding: 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 16px; font-family: inherit; background: white;
}
.form-row textarea { resize: vertical; min-height: 60px; }
.form-row input:focus, .form-row textarea:focus { outline: 2px solid #3b82f6; border-color: #3b82f6; }
.btn-primary { width: 100%; padding: 14px; background: #2563eb; color: white; border: none; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-green { background: #059669; }
.btn-green:hover:not(:disabled) { background: #047857; }
.btn-emerald { background: #10b981; }
.btn-emerald:hover:not(:disabled) { background: #059669; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn-primary { flex: 1; padding: 12px; font-size: 14px; }
.erro { background: #fef2f2; color: #b91c1c; padding: 10px; border-radius: 6px; font-size: 14px; margin-bottom: 12px; display: none; }
.erro.show { display: block; }

/* Header/back link compartilhado */
.back-bar { background: white; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; z-index: 10; }
.back-bar-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; max-width: 720px; margin: 0 auto; }
.back-title { font-weight: 600; }
.back-bar a { color: #2563eb; text-decoration: none; font-weight: 500; }

/* Cliente */
.saldo-box { background: white; border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.saldo-label { font-size: 14px; color: #64748b; }
.saldo-valor { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.saldo-vencimento { font-size: 14px; color: #64748b; margin-bottom: 12px; }
.acoes-cliente { display: flex; gap: 8px; }
.acoes-cliente a, .acoes-cliente button { flex: 1; text-align: center; padding: 10px; border-radius: 8px; font-weight: 600; text-decoration: none; border: none; cursor: pointer; font-family: inherit; font-size: 14px; }
.btn-whatsapp { background: #059669; color: white; }
.btn-receber { background: #10b981; color: white; }
.bloco { background: white; border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.bloco-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.bloco h2 { font-size: 16px; font-weight: 600; }
.linha { padding: 8px 0; border-top: 1px solid #f1f5f9; display: flex; justify-content: space-between; gap: 8px; }
.linha:first-child { border-top: 0; padding-top: 0; }
.linha-info { flex: 1; min-width: 0; }
.linha-data { font-size: 14px; color: #334155; }
.linha-sub { font-size: 12px; color: #64748b; }
.linha-valor { text-align: right; font-weight: 500; }
.text-red { color: #dc2626; }
.text-green { color: #059669; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 30; display: none; align-items: flex-end; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: white; width: 100%; max-width: 460px; border-radius: 16px 16px 0 0; padding: 24px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 28px; color: #94a3b8; cursor: pointer; }
.info-box { background: #f8fafc; padding: 10px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.input-grande { font-size: 24px !important; font-weight: 700; padding: 14px !important; }
.atalhos { display: flex; gap: 6px; margin-top: 8px; }
.atalhos button { font-size: 12px; padding: 4px 10px; background: #f1f5f9; border: none; border-radius: 6px; cursor: pointer; font-family: inherit; }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 16px; }
}

/* Catálogo + venda */
.produtos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 320px; overflow-y: auto; }
.produto-btn { text-align: left; padding: 10px; border: 1px solid #e2e8f0; border-radius: 8px; background: white; cursor: pointer; font-family: inherit; }
.produto-btn:hover { background: #eff6ff; }
.produto-btn:active { background: #dbeafe; }
.produto-nome { font-size: 14px; font-weight: 500; }
.produto-valor { font-size: 12px; color: #64748b; }
.item-venda { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #f1f5f9; }
.item-venda:first-child { border-top: 0; }
.qtd-controle { display: flex; align-items: center; gap: 4px; }
.qtd-btn { width: 32px; height: 32px; background: #e2e8f0; border: none; border-radius: 8px; font-weight: 700; font-size: 18px; cursor: pointer; font-family: inherit; }
.qtd-btn:active { background: #cbd5e1; }
.qtd-num { width: 32px; text-align: center; font-weight: 600; }
.total-row { display: flex; justify-content: space-between; align-items: center; font-size: 20px; padding: 8px 0; }
.total-valor { font-weight: 700; color: #047857; }
