/* ═══════════════════════════════════════════════
   Caderneta App — CSS
   Swiss design · B&W · Alto contraste · Minimalista
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ── Tokens ───────────────────────────────────── */
:root {
  --black:      #0a0a0a;
  --white:      #fafafa;
  --gray-50:    #f5f5f5;
  --gray-100:   #ebebeb;
  --gray-200:   #d8d8d8;
  --gray-400:   #999;
  --gray-600:   #555;
  --green:      #1a7a3f;
  --green-bg:   #e8f5ee;
  --red:        #b91c1c;
  --red-bg:     #fef2f2;
  --serif:      'DM Serif Display', serif;
  --sans:       'DM Sans', sans-serif;
  --mono:       'DM Mono', monospace;
  --rule:       1px solid var(--black);
  --rule-light: 1px solid var(--gray-200);
  --radius:     4px;
  --fab-h:      60px;
}

/* ── Reset ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body { font-family: var(--sans); background: var(--gray-50); color: var(--black); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button { font-family: var(--sans); cursor: pointer; border: none; outline: none; background: none; }
input, select, textarea { font-family: var(--sans); outline: none; }
a { text-decoration: none; color: inherit; }

/* ── App container ────────────────────────────── */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--white);
  position: relative;
  padding-bottom: calc(var(--fab-h) + 28px);
}

/* ── Splash ───────────────────────────────────── */
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: var(--black);
  gap: 12px;
}
.splash-logo {
  display: flex;
  align-items: baseline;
  gap: 1px;
  color: var(--white);
}
.splash-c {
  font-family: var(--serif);
  font-style: italic;
  font-size: 3rem;
  line-height: 1;
}
.splash-nome {
  font-family: var(--serif);
  font-size: 2rem;
  line-height: 1;
}
.splash-sub {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--gray-400);
  letter-spacing: 0.08em;
}
.splash-spinner {
  width: 28px; height: 28px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-top: 24px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Header ───────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--white);
  border-bottom: var(--rule);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}
.header-logo .negocio-nome {
  font-style: normal;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-left: 6px;
}
.header h2 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.header-actions { display: flex; align-items: center; gap: 8px; }

.btn-voltar {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-600);
  padding: 8px 4px;
  letter-spacing: 0;
}
.btn-voltar:active { color: var(--black); }

.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  border: var(--rule-light);
  border-radius: var(--radius);
  transition: all 0.1s;
}
.btn-icon:active { background: var(--gray-100); }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray-200);
}
.status-dot.online { background: var(--green); }

/* ── Total topo ───────────────────────────────── */
.resumo-topo {
  padding: 28px 20px 24px;
  border-bottom: var(--rule);
}
.total-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--gray-400);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.total-valor {
  font-family: var(--serif);
  font-size: 2.8rem;
  line-height: 1;
  letter-spacing: -0.03em;
}
.total-valor.zerado { color: var(--gray-400); }

/* ── Busca ────────────────────────────────────── */
.busca-container { padding: 16px 20px 8px; border-bottom: var(--rule-light); }
.campo-busca {
  width: 100%;
  padding: 13px 16px;
  border: var(--rule-light);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--gray-50);
  color: var(--black);
  transition: border-color 0.15s;
}
.campo-busca:focus { border-color: var(--black); background: var(--white); }

/* ── Lista clientes ───────────────────────────── */
.clientes-lista { padding: 8px 0; }
.cliente-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: var(--rule-light);
  cursor: pointer;
  transition: background 0.1s;
  -webkit-user-select: none;
  user-select: none;
  gap: 12px;
}
.cliente-card:active { background: var(--gray-50); }
.cliente-nome { font-size: 1rem; font-weight: 600; }
.cliente-tel { font-size: 0.78rem; color: var(--gray-400); font-family: var(--mono); margin-top: 3px; }
.cliente-total {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}
.tem-divida { color: var(--black); font-weight: 700; }
.sem-divida { color: var(--gray-400); font-size: 0.78rem; font-weight: 400; }

/* ── Empty state ──────────────────────────────── */
.vazio {
  text-align: center;
  padding: 60px 32px;
  color: var(--gray-400);
  border-bottom: var(--rule-light);
}
.vazio-icon { font-size: 2.5rem; margin-bottom: 16px; filter: grayscale(1); opacity: 0.4; }
.vazio p { font-size: 0.95rem; line-height: 1.6; font-weight: 300; }
.vazio strong { color: var(--black); font-weight: 600; }

/* ── FAB ──────────────────────────────────────── */
.btn-fab {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  height: var(--fab-h);
  background: var(--black);
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: var(--radius);
  z-index: 200;
  transition: all 0.1s;
}
.btn-fab:active { background: #333; transform: translateX(-50%) scale(0.99); }

/* ── Formulário ───────────────────────────────── */
.formulario { padding: 24px 20px; display: flex; flex-direction: column; gap: 20px; }
.campo-grupo { display: flex; flex-direction: column; gap: 6px; }
.campo-label {
  font-size: 0.78rem;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.campo {
  width: 100%;
  padding: 14px 16px;
  border: var(--rule-light);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  background: var(--gray-50);
  color: var(--black);
  transition: border-color 0.15s, background 0.15s;
  appearance: none;
}
.campo:focus { border-color: var(--black); background: var(--white); }
.campos-linha { display: flex; gap: 12px; }
.flex-1 { flex: 1; }

.select-wrapper { position: relative; }
.select-wrapper::after {
  content: '▾';
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
  font-size: 0.8rem;
}

.subtotal-linha {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--gray-50);
  border: var(--rule-light);
  border-radius: var(--radius);
}
.subtotal-label { font-family: var(--mono); font-size: 0.72rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.08em; }
.subtotal-valor { font-family: var(--serif); font-size: 1.4rem; letter-spacing: -0.02em; }

.divisor-form { border: none; border-top: var(--rule-light); margin: 4px 0; }

.btn-salvar {
  width: 100%;
  padding: 18px;
  background: var(--black);
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: var(--radius);
  transition: background 0.1s;
}
.btn-salvar:active { background: #333; }

/* ── Tela cliente ─────────────────────────────── */
.cliente-hero {
  padding: 24px 20px;
  border-bottom: var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.cliente-hero-nome { font-family: var(--serif); font-size: 1.6rem; letter-spacing: -0.025em; font-style: italic; }
.cliente-hero-total { text-align: right; }
.cliente-hero-total-label { font-family: var(--mono); font-size: 0.65rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 2px; }
.cliente-hero-total-valor { font-family: var(--mono); font-size: 1.2rem; font-weight: 500; }
.valor-devendo { color: var(--black); }
.valor-pago { color: var(--gray-400); }

/* Seletor de mês */
.mes-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: var(--rule-light);
}
.btn-mes-seta {
  width: 36px; height: 36px;
  border: var(--rule-light);
  border-radius: var(--radius);
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.1s;
}
.btn-mes-seta:active { background: var(--gray-100); }
.mes-info { text-align: center; }
.mes-nome-txt { font-size: 0.95rem; font-weight: 600; }
.mes-total-txt { font-family: var(--mono); font-size: 0.78rem; color: var(--gray-600); margin-top: 1px; }

/* Ações mês */
.acoes-mes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: var(--rule);
}
.btn-acao-mes {
  padding: 14px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  border-right: var(--rule-light);
  transition: background 0.1s;
}
.btn-acao-mes:last-child { border-right: none; }
.btn-acao-mes:active { background: var(--gray-50); }
.btn-acao-mes.primario { background: var(--black); color: var(--white); }
.btn-acao-mes.primario:active { background: #333; }
.badge-fechado {
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--gray-400);
  border-right: var(--rule-light);
}

/* Lista vendas */
.vendas-lista { padding: 0; }
.venda-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px;
  border-bottom: var(--rule-light);
  gap: 12px;
  transition: background 0.1s;
}
.venda-item.paga { opacity: 0.45; }
.venda-left { flex: 1; min-width: 0; }
.venda-data { font-family: var(--mono); font-size: 0.68rem; color: var(--gray-400); margin-bottom: 3px; }
.venda-desc { font-size: 0.95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.venda-qtd { font-size: 0.78rem; color: var(--gray-600); margin-top: 2px; }
.venda-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.venda-valor { font-family: var(--mono); font-size: 0.95rem; font-weight: 500; }
.venda-btns { display: flex; gap: 5px; }

.btn-mini {
  padding: 5px 10px;
  border: var(--rule-light);
  border-radius: var(--radius);
  font-size: 0.72rem;
  font-weight: 600;
  transition: all 0.1s;
  font-family: var(--mono);
}
.btn-pagar { color: var(--green); border-color: var(--green); }
.btn-pagar:active { background: var(--green); color: var(--white); }
.btn-excluir { color: var(--red); border-color: var(--red-bg); }
.btn-excluir:active { background: var(--red); color: var(--white); }
.tag-pago { font-family: var(--mono); font-size: 0.68rem; color: var(--green); }

/* ── Resumo cobrança ──────────────────────────── */
.resumo-head {
  padding: 28px 20px 20px;
  border-bottom: var(--rule);
}
.resumo-cliente-nome { font-family: var(--serif); font-style: italic; font-size: 1.5rem; letter-spacing: -0.02em; }
.resumo-mes-label { font-family: var(--mono); font-size: 0.72rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; }
.resumo-total-val { font-family: var(--serif); font-size: 2.2rem; letter-spacing: -0.03em; margin-top: 12px; }

.resumo-itens { padding: 0; }
.resumo-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 20px;
  border-bottom: var(--rule-light);
  gap: 16px;
}
.resumo-item-desc { font-size: 0.9rem; font-weight: 500; flex: 1; }
.resumo-item-meta { font-family: var(--mono); font-size: 0.72rem; color: var(--gray-400); display: block; margin-top: 2px; }
.resumo-item-val { font-family: var(--mono); font-size: 0.9rem; font-weight: 500; flex-shrink: 0; }

.bloco-texto {
  margin: 16px 20px;
  padding: 18px;
  background: var(--gray-50);
  border: var(--rule-light);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.75;
  white-space: pre-wrap;
  color: var(--gray-600);
}

.acoes-cobranca { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: var(--rule); }
.btn-cob {
  padding: 18px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 0.1s;
  border-right: var(--rule);
}
.btn-cob:last-child { border-right: none; }
.btn-cob:active { background: var(--gray-50); }
.btn-cob.whatsapp { background: var(--black); color: var(--white); border: none; }
.btn-cob.whatsapp:active { background: #333; }
.btn-cob.desabilitado { color: var(--gray-400); cursor: default; }

.btn-extrato-link {
  display: block;
  text-align: center;
  padding: 16px;
  border-bottom: var(--rule-light);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-600);
  transition: background 0.1s;
}
.btn-extrato-link:active { background: var(--gray-50); }

/* ── Extrato visual ───────────────────────────── */
.extrato-doc {
  margin: 16px;
  border: var(--rule);
}
.extrato-header {
  padding: 28px 24px;
  background: var(--black);
  color: var(--white);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.extrato-marca { font-family: var(--serif); font-style: italic; font-size: 1.4rem; }
.extrato-titulo-doc { font-family: var(--mono); font-size: 0.65rem; color: #777; text-transform: uppercase; letter-spacing: 0.1em; text-align: right; }
.extrato-titulo-doc strong { display: block; color: var(--white); font-size: 0.8rem; margin-bottom: 2px; }

.extrato-info { padding: 20px 24px; border-bottom: var(--rule-light); display: flex; flex-direction: column; gap: 10px; }
.extrato-info-linha { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.85rem; }
.extrato-info-label { font-family: var(--mono); font-size: 0.68rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.08em; }
.extrato-info-val { font-weight: 600; }

.extrato-table { padding: 0; }
.extrato-th {
  display: grid;
  grid-template-columns: 72px 1fr 40px 84px;
  padding: 10px 24px;
  background: var(--gray-50);
  border-bottom: var(--rule-light);
}
.extrato-th span { font-family: var(--mono); font-size: 0.62rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.08em; }
.extrato-tr {
  display: grid;
  grid-template-columns: 72px 1fr 40px 84px;
  padding: 12px 24px;
  border-bottom: var(--rule-light);
  font-size: 0.85rem;
}
.extrato-tr span:last-child { font-family: var(--mono); font-size: 0.82rem; text-align: right; }

.extrato-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: var(--black);
  color: var(--white);
}
.extrato-total-label { font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: #777; }
.extrato-total-val { font-family: var(--serif); font-size: 1.8rem; letter-spacing: -0.02em; }

.extrato-footer {
  padding: 16px 24px;
  border-top: var(--rule-light);
  text-align: center;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--gray-400);
  letter-spacing: 0.06em;
}
.acoes-extrato { padding: 16px 20px 24px; }

/* ── Onboarding ───────────────────────────────── */
.onboarding {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--white);
}
.ob-slide {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 48px 28px 32px;
}
.ob-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 48px;
}
.ob-dot {
  height: 3px;
  flex: 1;
  background: var(--gray-200);
  border-radius: 2px;
  transition: background 0.3s;
}
.ob-dot.ativo { background: var(--black); }

.ob-numero {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--gray-400);
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}
.ob-titulo {
  font-family: var(--serif);
  font-size: 2.2rem;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}
.ob-titulo em { font-style: italic; }
.ob-desc {
  font-size: 1rem;
  color: var(--gray-600);
  font-weight: 300;
  line-height: 1.65;
  flex: 1;
}
.ob-campo-grupo { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.ob-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ob-input {
  padding: 16px;
  border: none;
  border-bottom: 2px solid var(--black);
  font-family: var(--serif);
  font-size: 1.6rem;
  font-style: italic;
  letter-spacing: -0.02em;
  background: none;
  color: var(--black);
  width: 100%;
}
.ob-input:focus { outline: none; }
.ob-input::placeholder { color: var(--gray-200); }

.ob-footer { padding: 24px 0 0; }
.btn-ob-next {
  width: 100%;
  padding: 18px;
  background: var(--black);
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: var(--radius);
  transition: background 0.1s;
}
.btn-ob-next:active { background: #333; }
.btn-ob-pular {
  width: 100%;
  padding: 14px;
  font-size: 0.85rem;
  color: var(--gray-400);
  text-align: center;
  margin-top: 8px;
}

/* ── PIN ──────────────────────────────────────── */
.tela-pin {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--black);
  color: var(--white);
  padding: 40px 28px;
  text-align: center;
}
.pin-logo { font-family: var(--serif); font-style: italic; font-size: 2.2rem; margin-bottom: 6px; }
.pin-sub { font-family: var(--mono); font-size: 0.72rem; color: var(--gray-600); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 48px; }
.pin-display {
  font-family: var(--mono);
  font-size: 2.5rem;
  letter-spacing: 20px;
  margin-bottom: 40px;
  padding: 16px 24px;
  border: 1px solid #333;
  border-radius: var(--radius);
  min-width: 220px;
}
.pin-teclado {
  display: grid;
  grid-template-columns: repeat(3, 80px);
  gap: 12px;
}
.pin-btn {
  height: 72px;
  border: 1px solid #222;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--white);
  background: #111;
  transition: all 0.1s;
}
.pin-btn:active { background: #333; border-color: #555; }
.pin-confirmar { background: var(--white); color: var(--black); border-color: var(--white); }
.pin-confirmar:active { background: var(--gray-100); }
.pin-apagar { color: var(--gray-600); }
.pin-negocio { font-family: var(--mono); font-size: 0.7rem; color: #555; margin-top: 32px; letter-spacing: 0.08em; }

/* ── Config ───────────────────────────────────── */
.config-lista { padding: 0; }
.config-secao { border-bottom: var(--rule); }
.config-secao-titulo {
  padding: 16px 20px 12px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--gray-50);
  border-bottom: var(--rule-light);
}
.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: var(--rule-light);
  cursor: pointer;
  transition: background 0.1s;
}
.config-item:last-child { border-bottom: none; }
.config-item:active { background: var(--gray-50); }
.config-item-txt { font-size: 0.95rem; font-weight: 500; }
.config-item-sub { font-size: 0.78rem; color: var(--gray-400); margin-top: 2px; }
.config-item-arrow { font-size: 0.75rem; color: var(--gray-400); font-family: var(--mono); }
.config-item.perigo .config-item-txt { color: var(--red); }

/* ── Toast ────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--fab-h) + 32px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--black);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 9999;
  white-space: nowrap;
  max-width: calc(100vw - 40px);
  text-align: center;
  font-family: var(--sans);
}
.toast.ativo { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.erro { background: var(--red); }
.toast.aviso { background: #7a5c00; }
.toast.info { background: #444; }

/* ── Print ────────────────────────────────────── */
@media print {
  .header, .btn-fab, .acoes-extrato, .no-print { display: none !important; }
  body, #app { background: white; }
  .extrato-doc { border: 1px solid #ccc; margin: 0; box-shadow: none; }
  .extrato-header, .extrato-total { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ── Mobile fine-tuning ───────────────────────── */
@media (max-width: 360px) {
  .total-valor { font-size: 2.2rem; }
  .pin-btn { height: 60px; }
  .pin-teclado { grid-template-columns: repeat(3, 70px); }
}
