/* =========================================================
   CADERNETA CERTA — tema claro, premium
   Paleta: base neutra clara + verde de marca + azul/laranja/
   vermelho para indicadores (saldo, entradas, saídas, fiado)
   Tipografia: só fontes de sistema (funciona 100% offline)
   ========================================================= */

:root {
  color-scheme: light;
  --bg: #F3F5FA;
  --surface: #FFFFFF;
  --surface-2: #F7F8FC;
  --border: #E6E9F1;
  --border-soft: #EEF0F6;
  --text: #131A28;
  --text-muted: #6B7385;
  --text-faint: #9AA1B4;

  --green: #16A34A;
  --green-dark: #0E7C3A;
  --green-tint: #E4F7EC;
  --blue: #2E6FF2;
  --blue-dark: #1E52C2;
  --blue-tint: #E8EFFE;
  --orange: #F2994A;
  --orange-dark: #C9761F;
  --orange-tint: #FDF0E1;
  --red: #EB5757;
  --red-dark: #C13A3A;
  --red-tint: #FCE9E9;
  --gold: #D8A94A;

  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-num: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(20,26,46,.05), 0 1px 1px rgba(20,26,46,.03);
  --shadow: 0 2px 6px rgba(20,26,46,.05), 0 10px 24px -12px rgba(20,26,46,.14);
  --shadow-lg: 0 16px 40px -16px rgba(20,26,46,.22);
}

* { box-sizing: border-box; }

/* desliga a aparência nativa do sistema em botões/campos de texto — sem
   isso, alguns Android desenham um fundo/borda cinza por cima do nosso
   estilo (foi o caso do botão "+ Adicionar" ficando com essa caixa cinza
   feia). Não mexe em <select> de propósito, pra não perder a setinha
   nativa de "isso é uma lista pra escolher". */
button, input, textarea {
  -webkit-appearance: none;
  appearance: none;
}
/* exceções: esses tipos de campo dependem da aparência nativa pra
   funcionar/aparecer direito (calendário, caixinha de marcar) */
input[type="date"], input[type="checkbox"], input[type="radio"], input[type="file"] {
  -webkit-appearance: auto;
  appearance: auto;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: 15px; }
h1, h2, h3 { font-family: var(--font-body); }

/* ---------- layout shell ---------- */
#layout {
  display: flex;
  min-height: 100vh;
}
#sidebar {
  width: 240px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: none;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
#main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 90px; /* espaço p/ bottom nav no mobile */
}

/* ---------- sidebar ---------- */
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sb-foot { border-top: 1px solid var(--border-soft); padding-top: 10px; margin-top: 10px; }
.sb-item {
  display: flex; align-items: center; gap: 11px;
  background: transparent; border: none; text-align: left;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  cursor: pointer;
}
.sb-item:hover { background: var(--surface-2); color: var(--text); }
.sb-item.active { background: var(--green-tint); color: var(--green-dark); font-weight: 600; }
.sb-icon { display: flex; width: 20px; height: 20px; flex: none; }
.sb-item.active .sb-icon { color: var(--green-dark); }

/* ---------- header / topbar ---------- */
#app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 0;
  position: sticky;
  top: 0;
  z-index: 20;
}
.hdr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  padding-bottom: 13px;
}
.hdr-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.hdr-brand > div { min-width: 0; }
.hdr-mark {
  font-family: var(--font-body);
  font-size: 19px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--green);
  color: #fff;
  border-radius: 9px;
  font-weight: 700;
  flex: none;
  overflow: hidden;
}
.hdr-mark img { width: 100%; height: 100%; object-fit: cover; }
.hdr-brand strong { display: block; font-size: 15px; letter-spacing: .1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-sub { display: block; font-size: 11px; color: var(--text-faint); margin-top: 1px; }
.hdr-title { flex: 1; font-size: 18px; font-weight: 700; margin: 0; display: none; }
.hdr-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; flex: none; }
.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  flex: none;
}
.icon-btn.has-dot::after {
  content: '';
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--surface);
}
.alert-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--red-tint);
  color: var(--red-dark);
  padding: 10px 14px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin: 0 -16px;
  padding-left: 16px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.alert-strip .alert-avatar { width: 24px; height: 24px; }
.alert-strip svg:last-child { margin-left: auto; width: 16px; height: 16px; opacity: .6; flex: none; }
.alert-strip-soft { background: var(--orange-tint); color: var(--orange-dark); }

/* ---------- bottom nav (mobile) ---------- */
#bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -6px 20px rgba(20,26,46,.06);
}
.nav-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-faint);
  padding: 9px 2px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
}
.nav-btn svg { width: 21px; height: 21px; }
.nav-btn.active { color: var(--green-dark); }

/* ---------- content ---------- */
#app { flex: 1; padding: 18px 20px 20px; max-width: 1180px; width: 100%; margin: 0 auto; }
.view { display: flex; flex-direction: column; gap: 18px; }
.view h2 { margin: 0; font-size: 21px; font-weight: 700; }
.view-head { display: flex; align-items: center; justify-content: space-between; }
.view-toprow { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.data-especifica-wrap { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.data-especifica-label { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.data-especifica-wrap input[type="date"] {
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px;
  background: var(--surface); color: var(--text); font-size: 13px;
  min-width: 150px; max-width: 190px;
}
.data-especifica-wrap .btn-mini { padding: 8px; }
.data-especifica-wrap .btn-mini svg { width: 13px; height: 13px; }

.date-full-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text-faint);
  position: relative;
}
.date-full-wrap input[type="date"] {
  border: none; outline: none; background: transparent;
  flex: 1; min-width: 0; font-size: 14.5px; color: var(--text); padding: 0;
  position: relative; z-index: 1;
}
.date-placeholder-overlay {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 14.5px;
  pointer-events: none;
  z-index: 0;
  display: none;
}
.date-full-wrap .btn-mini { flex: none; padding: 6px; }
.date-full-wrap .btn-mini svg { width: 13px; height: 13px; }

/* no mobile, o campo de data vazio ficava branco em alguns Android mesmo
   com color-scheme:light — então escondemos o texto nativo do campo
   (só quando vazio) e mostramos nosso próprio "dd/mm/aaaa" por cima,
   que a gente controla 100%. No desktop já funciona bem nativamente,
   então deixamos como está lá. */
@media (max-width: 959.98px) {
  .date-full-wrap input[type="date"].input-date-vazio { color: transparent; }
  .date-placeholder-overlay { display: block; }
}
.link-back { align-self: flex-start; background: none; border: none; color: var(--green-dark); font-size: 14px; cursor: pointer; padding: 0; font-weight: 600; }

/* ---------- segmented control ---------- */
.seg-control {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  background: transparent;
  border: none;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}
.seg-btn.on { background: var(--text); color: #fff; }

/* esse seg-control específico tem palavras mais compridas (Automático,
   Retangular) que não cabem numa linha só no celular — deixa quebrar em
   grade 2x2 em vez de estourar a tela */
.logo-formato-bloco .seg-control { display: flex; flex-wrap: wrap; width: 100%; }
.logo-formato-bloco .seg-btn { flex: 1 1 calc(50% - 2px); text-align: center; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kpi-card {
  border-radius: var(--radius-lg);
  padding: 16px 18px 18px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 108px;
}
.kpi-card::after {
  content: '';
  position: absolute; right: -30px; top: -30px;
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.kpi-blue { background: linear-gradient(150deg, #3E7BFA, #2352C9); }
.kpi-green { background: linear-gradient(150deg, #2BC373, #0E8C48); }
.kpi-red { background: linear-gradient(150deg, #F16767, #D33F3F); }
.kpi-orange { background: linear-gradient(150deg, #FBB040, #E38018); cursor: pointer; }
.kpi-top { display: flex; align-items: center; gap: 9px; }
.kpi-icon { display: flex; width: 20px; height: 20px; opacity: .92; }
.kpi-label { font-size: 12.5px; font-weight: 600; opacity: .92; }
.kpi-value { font-family: var(--font-num); font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
.kpi-tag {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255,255,255,.22);
  font-size: 10.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 20px;
}

/* ---------- busca ---------- */
.search-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text-faint);
}
.search-wrap svg { flex: none; width: 18px; height: 18px; }
.search-wrap input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font-size: 14.5px;
  color: var(--text);
}
.search-wrap input::placeholder { color: var(--text-faint); }

/* ---------- lista de clientes (cards por status) ---------- */
.client-list { display: flex; flex-direction: column; gap: 10px; }
.client-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform .1s;
}
.client-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.client-card-vencida { background: #FDF0EF; border-color: #F3B4AE; }
.client-card-atencao { background: #FEF8E9; border-color: #F0D48A; }
.client-avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.client-avatar svg { width: 19px; height: 19px; }
.client-avatar-ok { background: var(--surface-2); color: var(--text-faint); }
.client-avatar-vencida { background: #F7D2CE; color: var(--red-dark); }
.client-avatar-atencao { background: #F5E1A8; color: var(--orange-dark); }
.client-name { display: block; font-size: 14.5px; font-weight: 700; }
.client-name-ok { color: var(--text); }
.client-name-vencida { color: var(--red-dark); }
.client-name-atencao { color: var(--orange-dark); }
.client-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.badge-status {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 800; letter-spacing: .3px;
  padding: 2px 7px; border-radius: 6px;
}
.badge-status svg { width: 11px; height: 11px; }
.badge-vencida { background: #F7D2CE; color: var(--red-dark); }
.badge-atencao { background: #F5E1A8; color: var(--orange-dark); }
.client-value-col { flex: none; text-align: right; }
.client-value { display: block; font-family: var(--font-num); font-size: 15px; font-weight: 700; color: #D64545; }
.client-value-label { display: block; font-size: 10.5px; color: var(--text-faint); margin-top: 1px; }

/* ---------- painel de dados do cliente ---------- */
.client-info-panel { display: flex; flex-direction: column; gap: 9px; }
.client-info-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-muted); }
.client-info-row svg { flex: none; width: 16px; height: 16px; color: var(--text-faint); }

/* ---------- tela de login / cadastro ---------- */
#auth-screen {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
}
.auth-tabs { display: flex; gap: 10px; margin-bottom: 22px; }
.auth-tabs button {
  border: none; border-radius: 10px; padding: 12px 20px; font-size: 14.5px; font-weight: 700; cursor: pointer;
  background: transparent; color: var(--text-muted);
}
.auth-tabs button.on { background: var(--green-dark); color: #fff; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-brand .hdr-mark { width: 56px; height: 56px; border-radius: 14px; font-size: 30px; }
.auth-brand strong { display: block; font-size: 19px; }
.auth-brand .hdr-sub { font-size: 12.5px; }
.auth-card h2 { margin: 4px 0 6px; font-size: 21px; font-weight: 700; color: var(--text); }
.auth-card .auth-subtitulo { margin: 0 0 20px; font-size: 13.5px; color: var(--text-muted); }
.auth-aviso { background: var(--orange-tint); color: var(--orange-dark); font-size: 12.5px; padding: 9px 11px; border-radius: 9px; margin-bottom: 14px; }
.auth-erro { background: var(--red-tint); color: var(--red-dark); font-size: 12.5px; padding: 9px 11px; border-radius: 9px; margin-bottom: 14px; }
.auth-sucesso { background: var(--green-tint); color: var(--green-dark); font-size: 12.5px; padding: 9px 11px; border-radius: 9px; margin-bottom: 14px; }
.auth-linha-lembrar { display: flex; align-items: center; justify-content: space-between; margin: -6px 0 16px; }
.auth-linha-lembrar .check-field { width: auto; margin: 0; }
.auth-linha-lembrar .check-field span { font-size: 13px; color: var(--text-muted); }
.auth-esqueci { text-align: right; margin: -8px 0 14px; }
.auth-esqueci .link-back { font-size: 12.5px; }
.auth-termos { align-items: flex-start; margin: 4px 0 16px; }
.auth-termos input { margin-top: 2px; flex: none; }
.auth-termos span { line-height: 1.4; }
.auth-termos a { color: var(--green-dark); font-weight: 600; }
.legal-links-rodape { text-align: center; font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.legal-links-rodape a { color: var(--text-muted); }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-faint); font-size: 12.5px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.campo-duplo { display: flex; flex-direction: column; }
@media (min-width: 620px) {
  .auth-card { max-width: 460px; }
  .campo-duplo { flex-direction: row; gap: 12px; }
  .campo-duplo > .field { flex: 1; min-width: 0; }
}

/* ---------- logo / QR code (Configurações) ---------- */
.logo-upload-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.logo-preview {
  flex: none; width: 64px; height: 64px; border-radius: 12px;
  border: 1.5px dashed var(--border); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; color: var(--text-faint);
  overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-upload-row label.btn-secondary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.logo-upload-row label.btn-secondary svg { width: 15px; height: 15px; }
.logo-formato-bloco { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px dashed var(--border); }
textarea#cfg-modelo-cobranca {
  border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px;
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 14px; resize: vertical;
}
.btn-google { margin-top: 8px; }
.auth-troca { text-align: center; font-size: 13px; color: var(--text-muted); margin: 16px 0 0; }
.auth-troca .link-back { font-size: 13px; margin-left: 4px; }
.auth-trial { text-align: center; font-size: 11.5px; color: var(--text-faint); margin: 10px 0 0; }

/* ---------- páginas de documento legal (termos/privacidade) ---------- */
.legal-page { max-width: 760px; margin: 0 auto; padding: 32px 20px 60px; }
.legal-page .auth-brand { margin-bottom: 24px; }
.legal-page h1 { font-size: 24px; margin: 0 0 6px; }
.legal-page .legal-atualizado { color: var(--text-faint); font-size: 12.5px; margin: 0 0 28px; }
.legal-page h2 { font-size: 16px; margin: 28px 0 8px; }
.legal-page p, .legal-page li { font-size: 14px; line-height: 1.65; color: var(--text); }
.legal-page ul, .legal-page ol { padding-left: 20px; margin: 8px 0; }
.legal-page li { margin-bottom: 4px; }
.legal-page .legal-aviso { background: var(--orange-tint); color: var(--orange-dark); font-size: 12.5px; padding: 10px 14px; border-radius: 9px; margin-bottom: 20px; }
.legal-page .placeholder { background: #FDF0E1; padding: 1px 5px; border-radius: 4px; color: var(--orange-dark); font-weight: 600; }
.legal-page .legal-voltar { display: inline-block; margin-top: 30px; }

/* ---------- cards de item genéricos (vendas/produtos/contas) ---------- */
.item-list { display: flex; flex-direction: column; gap: 10px; }
.item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform .1s;
}
.item-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.item-card-danger { background: #FDF0EF; border-color: #F3B4AE; }
.item-card-atencao { background: #FEF8E9; border-color: #F0D48A; }
.item-avatar-item {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.item-avatar-item svg { width: 19px; height: 19px; }
.item-avatar-neutral { background: var(--surface-2); color: var(--text-faint); }
.item-avatar-danger { background: #F7D2CE; color: var(--red-dark); }
.item-avatar-atencao { background: #F5E1A8; color: var(--orange-dark); }
.item-name { display: block; font-size: 14.5px; font-weight: 700; }
.item-name-neutral { color: var(--text); }
.item-name-danger { color: var(--red-dark); }
.item-name-atencao { color: var(--orange-dark); }
.item-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.item-value-col { flex: none; text-align: right; }
.item-value { display: block; font-family: var(--font-num); font-size: 15px; font-weight: 700; color: var(--text); }
.item-value-label { display: block; font-size: 10.5px; color: var(--text-faint); margin-top: 1px; }
.item-value-col .btn-mini, .item-value-col .pill { margin-top: 4px; }

/* ---------- Sr. Fiado (mascote) ---------- */
.alert-avatar { flex: none; width: 28px; height: 28px; border-radius: 50%; overflow: hidden; background: #fff; }
.alert-avatar svg { display: block; width: 100%; height: 100%; }

.mascote-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--border);
}
.mascote-vencido { border-left-color: var(--red); background: linear-gradient(90deg, var(--red-tint), var(--surface) 55%); }
.mascote-atencao { border-left-color: var(--orange); background: linear-gradient(90deg, var(--orange-tint), var(--surface) 55%); }
.mascote-ok { border-left-color: var(--green); background: linear-gradient(90deg, var(--green-tint), var(--surface) 55%); }
.mascote-avatar { flex: none; width: 68px; height: 68px; }
.mascote-avatar svg { display: block; width: 100%; height: 100%; }
.mascote-fala { flex: 1; min-width: 0; }
.mascote-nome { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-faint); margin-bottom: 2px; }
.mascote-titulo { margin: 0 0 2px; font-size: 15px; font-weight: 700; }
.mascote-msg { margin: 0; font-size: 13px; color: var(--text-muted); line-height: 1.45; }
.mascote-btn { flex: none; }
.mascote-panel-lg { padding: 20px; gap: 18px; }
.mascote-panel-lg .mascote-avatar { width: 84px; height: 84px; }
.mascote-panel-lg .mascote-titulo { font-size: 17px; }
.mascote-panel-lg .mascote-msg { font-size: 14px; }

@media (max-width: 480px) {
  .mascote-panel { flex-wrap: wrap; }
  .mascote-btn { width: 100%; }
}

/* ---------- banner de instalar app ---------- */
.install-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: var(--radius-lg);
  padding: 14px 14px 14px 16px;
  box-shadow: var(--shadow-sm);
}
.install-banner-icon {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--green-tint); color: var(--green-dark);
  display: flex; align-items: center; justify-content: center;
}
.install-banner-icon svg { width: 19px; height: 19px; }
.install-banner strong { display: block; font-size: 14px; }
.install-banner .muted { font-size: 12.5px; }
.install-banner .btn-primary { flex: none; padding: 9px 14px; font-size: 13px; }
.install-banner-fechar {
  flex: none; background: transparent; border: none; color: var(--text-faint);
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; border-radius: 50%;
}
.install-banner-fechar svg { width: 14px; height: 14px; }
.install-banner-fechar:hover { background: var(--surface-2); }

@media (max-width: 480px) {
  .install-banner { flex-wrap: wrap; }
  .install-banner .btn-primary { order: 3; width: 100%; }
}

@media (min-width: 960px) {
  .instalar-so-mobile { display: none; }
}

/* ---------- content grid ---------- */
.content-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }

/* ---------- panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.panel-title { font-size: 14.5px; font-weight: 700; margin: 0 0 10px; color: var(--text); }
.muted-count { font-weight: 400; color: var(--text-faint); font-size: 13px; }
.pendencia-panel { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }

/* ---------- bar chart ---------- */
.bar-chart { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 66px 1fr 78px; align-items: center; gap: 10px; }
.bar-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.bar-track { height: 9px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }
.bar-green { background: linear-gradient(90deg, #2BC373, #16A34A); }
.bar-blue { background: linear-gradient(90deg, #5D93FF, #2E6FF2); }
.bar-orange { background: linear-gradient(90deg, #FBB040, #F2994A); }
.bar-value { font-family: var(--font-num); font-size: 12.5px; text-align: right; font-weight: 600; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-soft);
  gap: 12px;
}
.list-row:last-child { border-bottom: none; }
.list-row-click { cursor: pointer; margin: 0 -8px; padding: 11px 8px; border-radius: 10px; }
.list-row-click:hover { background: var(--surface-2); }
.list-row > div:not(.row-icon) { flex: 1; min-width: 0; }
.list-row strong { display: block; font-size: 14px; font-weight: 600; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-muted); font-size: 12.5px; }
.row-end { display: flex; align-items: center; gap: 8px; flex: none; }
.row-icon {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.row-icon svg { width: 17px; height: 17px; }
.row-icon-green { background: var(--green-tint); color: var(--green-dark); }
.row-icon-red { background: var(--red-tint); color: var(--red-dark); }
.val-in { color: var(--green-dark); font-family: var(--font-num); font-weight: 700; font-size: 13.5px; }
.val-out { color: var(--red-dark); font-family: var(--font-num); font-weight: 700; font-size: 13.5px; }
.empty { color: var(--text-faint); font-size: 13px; padding: 18px 0; text-align: center; }

/* ---------- pills ---------- */
.pill { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; }
.pill svg { width: 11px; height: 11px; }
.pill-ok { background: var(--green-tint); color: var(--green-dark); }
.pill-warn { background: var(--orange-tint); color: var(--orange-dark); }
.pill-danger { background: var(--red-tint); color: var(--red-dark); }

.entrega-info {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin: 4px 0 6px;
}
.entrega-info-icon { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--orange-tint); color: var(--orange-dark); display: flex; align-items: center; justify-content: center; }
.entrega-info-icon svg { width: 16px; height: 16px; }
.entrega-info strong { display: block; font-size: 13.5px; }

.resumo-venda-icone {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--green-tint); color: var(--green-dark);
  display: flex; align-items: center; justify-content: center;
  margin: 4px auto 14px;
}
.resumo-venda-icone svg { width: 26px; height: 26px; }

/* ---------- buttons ---------- */
.btn-primary, .btn-secondary, .btn-danger, .btn-mini {
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary { background: var(--green); color: #fff; padding: 11px 18px; font-size: 14px; box-shadow: 0 6px 16px -6px rgba(22,163,74,.55); }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--surface); color: var(--text); padding: 10px 14px; font-size: 13px; border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--red-tint); color: var(--red-dark); padding: 11px 16px; font-size: 14px; }
.btn-mini { background: var(--surface-2); color: var(--text); padding: 6px 11px; font-size: 12px; display: inline-flex; align-items: center; border: 1px solid var(--border); }
.btn-mini-danger { background: var(--red-tint); color: var(--red-dark); border-color: transparent; }
.btn-block { width: 100%; margin-top: 4px; justify-content: center; }
.row-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.fab {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 8px 20px -8px rgba(22,163,74,.6);
}
.fab:hover { background: var(--green-dark); }
.fab svg { width: 16px; height: 16px; }
a.btn-primary, a.btn-secondary, a.btn-danger { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-whats { background: #E7F7EE; color: #0E7C3A; border-color: transparent; }
.btn-whats:hover { background: #D4F0DF; }
.panel-title svg { vertical-align: -4px; margin-right: 5px; width: 16px; height: 16px; }
.parcelas-preview { margin: -4px 0 12px; }
.parcelas-preview p { margin: 0; font-size: 12px; line-height: 1.5; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field span { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.field input, .field select {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 11px;
  background: var(--surface);
  color: var(--text);
}
.field input:focus, .field select:focus, .field-row input:focus, .field-row select:focus {
  outline: 2px solid var(--green);
  outline-offset: 1px;
  border-color: var(--green);
}
.field-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.field-row .grow { flex: 1; margin-bottom: 0; }
.field-row select, .field-row input { border: 1px solid var(--border); border-radius: 9px; padding: 9px; background: var(--surface); color: var(--text); }

.produto-busca-wrap { position: relative; }
.produto-busca-wrap input { width: 100%; box-sizing: border-box; }
.produto-busca-lista {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
  z-index: 20;
}
.produto-busca-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  font-size: 13.5px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
}
.produto-busca-item:last-child { border-bottom: none; }
.produto-busca-item:hover { background: var(--surface-2); }

.venda-secao {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.venda-secao-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.venda-secao-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.venda-divisor { border: none; border-top: 1px solid var(--border-soft); margin: 14px 0; }

.chip-toggle { display: flex; gap: 6px; flex: none; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 12.5px; font-weight: 600;
  padding: 7px 12px; border-radius: 20px; cursor: pointer;
}
.chip-btn svg { width: 13px; height: 13px; }
.chip-btn.on { background: var(--green); color: #fff; border-color: transparent; }
.chip-btn-desabilitado { opacity: .4; pointer-events: none; }

.link-adicionar {
  background: none; border: none; color: var(--green-dark); font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; padding: 0;
}
.link-adicionar svg { width: 14px; height: 14px; }

#venda-cliente-digitado {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px;
  background: var(--surface); color: var(--text); font-size: 14px;
}

.item-entrada-row { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; margin-top: 10px; }
.item-entrada-row input[type="number"] {
  width: 54px; flex: none; border: 1px solid var(--border); border-radius: 9px; padding: 9px; text-align: center;
  background: var(--surface); color: var(--text);
}
.item-entrada-rs { font-size: 13px; color: var(--text-muted); font-weight: 600; flex: none; }
.item-entrada-row .input-moeda { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 9px; padding: 9px; background: var(--surface); color: var(--text); }
.item-entrada-row strong { font-family: var(--font-num); font-size: 14px; white-space: nowrap; flex: none; }

.picker-trigger {
  width: 100%; box-sizing: border-box;
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 14px;
  color: var(--text-faint); font-size: 14px; cursor: pointer; text-align: left;
}
.picker-trigger svg { width: 16px; height: 16px; flex: none; }
.picker-trigger #cliente-selecionado-label:not(.muted) { color: var(--text); font-weight: 600; }

.item-desc-row { display: flex; gap: 8px; margin-bottom: 0; }
.item-desc-row input { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px; background: var(--surface); color: var(--text); }
.item-desc-row .btn-secondary { flex: none; padding: 9px 12px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; }
.item-desc-row .btn-secondary svg { width: 14px; height: 14px; }

.picker-view { display: flex; flex-direction: column; }
.picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.picker-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; }
.picker-head h2 svg { width: 19px; height: 19px; color: var(--green-dark); }
.picker-lista { margin-top: 14px; max-height: 50vh; overflow-y: auto; }
.picker-item {
  padding: 12px 4px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
}
.picker-item:hover { background: var(--surface-2); }
.picker-item strong { font-size: 14.5px; }
.picker-item-produto { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
.picker-item-produto > div { display: flex; flex-direction: column; gap: 2px; }
.picker-item-preco { color: var(--green-dark); font-weight: 700; font-family: var(--font-num); flex: none; }
.picker-vazio { text-align: center; padding: 24px 0; }
.check-field { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; }
.totalizador { display: flex; justify-content: space-between; align-items: center; font-size: 15px; padding: 12px 0 4px; border-top: 1px dashed var(--border); }
.totalizador strong { font-family: var(--font-num); font-size: 18px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,20,35,.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 22px 18px 26px;
  position: relative;
  animation: slideUp .18s ease-out;
  box-shadow: var(--shadow-lg);
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 50%;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--text-muted);
}
.modal-sheet h2 { margin: 0 24px 16px 0; font-size: 19px; font-weight: 700; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%; bottom: 88px;
  transform: translate(-50%, 10px);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity .18s, transform .18s;
  z-index: 200;
  pointer-events: none;
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .modal-sheet { animation: none; }
}

/* =========================================================
   RESPONSIVO — desktop com sidebar, mobile com bottom nav
   ========================================================= */
@media (min-width: 960px) {
  #sidebar { display: flex; }
  #bottom-nav { display: none; }
  #main-col { padding-bottom: 0; }
  .hdr-brand { display: none; }
  .hdr-title { display: block; }
  .hdr-brand strong { max-width: none; }
  #app-header { padding: 18px 32px 0; }
  #app { padding: 24px 32px 40px; }
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal-sheet { border-radius: 20px; max-height: 84vh; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .content-grid { grid-template-columns: 1.35fr 1fr; align-items: start; }
  .alert-strip { margin: 0 -32px; padding-left: 32px; }
}

@media (min-width: 640px) and (max-width: 959.98px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
