/* Painel MEI - estilos do painel */
:root {
  --sidebar-w: 240px;
  --sidebar-bg: #16213a;
  --sidebar-fg: #b9c2d6;
  --surface: #ffffff;
  --page-bg: #f4f6fa;
  --c-com: #2a78d6;      /* entradas com NF */
  --c-sem: #1baf7a;      /* entradas sem NF */
  --c-saida: #eb6834;    /* saídas */
  --c-prev: #6250d6;     /* previsões */
  --c-ok: #198754;
  --c-bad: #dc3545;
}

body { background: var(--page-bg); font-size: .925rem; }
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-fg);
  display: flex; flex-direction: column; padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; z-index: 1040;
}
.sidebar .brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; padding: .25rem .75rem 1.25rem; display: block; }
.sidebar .brand i { color: var(--c-brand, var(--c-com)); }
.sidebar .brand-logo { max-width: 100%; max-height: 56px; object-fit: contain; display: block; }
.sidebar .nav-link { color: var(--sidebar-fg); border-radius: .5rem; padding: .55rem .75rem; margin-bottom: 2px; }
.sidebar .nav-link i { width: 1.4rem; display: inline-block; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: var(--c-brand, var(--c-com)); color: var(--c-brand-text, #fff); }
.sidebar-user { border-top: 1px solid rgba(255,255,255,.1); padding: 1rem .75rem 0; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid #e3e7ef; padding: .75rem 1.5rem;
  display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 1030;
}
.filtro-empresa select { min-width: 220px; max-width: 320px; }
.page { padding: 1.5rem; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .page { padding: 1rem; }
  .topbar { padding: .6rem 1rem; flex-wrap: wrap; }
  .filtro-empresa { width: 100%; }
  .filtro-empresa select { max-width: none; flex: 1; }
}

.card { border: 1px solid #e3e7ef; border-radius: .75rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: transparent; border-bottom-color: #eef1f6; }
.card-footer { background: #fafbfd; }

/* KPIs */
.kpi { border-left: 4px solid var(--kpi, var(--c-com)); height: 100%; }
.kpi .kpi-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #6b7385; }
.kpi .kpi-value { font-size: 1.35rem; font-weight: 700; color: #1d2433; white-space: nowrap; }
.kpi .kpi-sub { font-size: .78rem; color: #6b7385; margin-top: .15rem; }
.kpi-primary { --kpi: var(--c-com); }
.kpi-teal { --kpi: var(--c-sem); }
.kpi-danger { --kpi: var(--c-bad); }
.kpi-success { --kpi: var(--c-ok); }
.kpi-info { --kpi: var(--c-prev); }

.text-teal { color: #13875d !important; }
.text-info { color: #4f3fc0 !important; }
.badge-primary { background: #e3eefb; color: #1c5aa6; }
.badge-teal { background: #e0f5ec; color: #10704d; }
.badge-danger { background: #fde8e3; color: #b23c10; }
.badge-info { background: #ebe8fb; color: #4f3fc0; }
.btn-outline-teal { --bs-btn-color: #13875d; --bs-btn-border-color: #1baf7a; --bs-btn-hover-bg: #1baf7a; --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #1baf7a; --bs-btn-active-color: #fff; --bs-btn-active-border-color: #1baf7a; }

.livro-caixa td, .livro-caixa th { white-space: nowrap; }
.livro-caixa td:nth-child(2) { white-space: normal; min-width: 200px; }
.resumo-anual td, .resumo-anual th { white-space: nowrap; font-size: .85rem; }
.chart-box { position: relative; height: 320px; }

/* Autocompletar da descrição */
.ac-lista { position: absolute; z-index: 1060; max-height: 280px; overflow-y: auto; border-radius: .5rem; }
.ac-item { display: flex; justify-content: space-between; gap: .75rem; align-items: center; padding: .45rem .75rem; font-size: .875rem; }
.ac-item .ac-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item .ac-info { white-space: nowrap; font-weight: 600; }
.ac-item.active { background: #e3eefb; color: #1d2433; border-color: #c9dcf5; }
.ac-item.active .text-muted { color: #52514e !important; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: linear-gradient(135deg, #16213a 0%, #23406e 100%); }
.login-card { width: 100%; max-width: 420px; border: 0; }
.login-logo { width: 64px; height: 64px; border-radius: 1rem; background: var(--c-brand, var(--c-com)); color: var(--c-brand-text, #fff); font-size: 2rem;
  display: inline-flex; align-items: center; justify-content: center; }

/* Relatório oficial */
.relatorio-oficial { background: #fff; max-width: 820px; margin: 0 auto 1.5rem; padding: 1.5rem; border: 1px solid #d5dae3; }
.rel-titulo { text-align: center; font-size: 1.05rem; font-weight: 700; margin-bottom: 1rem; }
.rel-tabela { width: 100%; border-collapse: collapse; font-size: .88rem; }
.rel-tabela th, .rel-tabela td { border: 1px solid #333; padding: .4rem .55rem; vertical-align: top; }
.rel-cab { width: 32%; font-weight: 600; background: #f2f2f2; }
.rel-secao th { background: #d9e2f3; text-align: left; }
.rel-total td { font-weight: 600; background: #f7f7f7; }
.rel-geral td { font-weight: 700; background: #e2efda; }
.rel-valor { width: 22%; text-align: right; white-space: nowrap; }
.rel-assinatura td { height: 90px; }
.rel-linha-assinatura { border-bottom: 1px solid #333; margin-top: 3rem; }
.rel-anexos td { font-size: .8rem; }

.print-only { display: none; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 11pt; }
  .sidebar, .topbar, .d-print-none, .alert { display: none !important; }
  .page { padding: 0; }
  .print-only { display: block; }
  .card { border: 1px solid #bbb; box-shadow: none; break-inside: avoid; }
  .relatorio-oficial { border: 0; padding: 0; max-width: none; break-after: page; }
  .relatorios .relatorio-oficial:last-child { break-after: auto; }
  .page-break { break-after: page; }
  .table-responsive { overflow: visible !important; }
  .resumo-anual td, .resumo-anual th { font-size: 7.5pt; padding: 2px 3px; }
  a { text-decoration: none; color: inherit; }
}

/* Configurações e marca */
.marca-preview { min-height: 72px; border: 1px dashed #cfd5e1; border-radius: .5rem; display: flex; align-items: center; justify-content: center; padding: .5rem; background: repeating-conic-gradient(#f3f5f9 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.marca-preview img { max-height: 64px; max-width: 100%; object-fit: contain; }
.marca-preview-ico img { width: 32px; height: 32px; }
.login-marca { max-height: 72px; max-width: 100%; object-fit: contain; }
/* campo isca do captcha: invisível para pessoas, preenchido por robôs */
.campo-isca { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Cadastro da empresa */
.campo-importado { background-color: #eaf7ef !important; border-color: #6cc497 !important; }
.formas-atuacao.campo-importado { border: 1px solid; border-radius: .375rem; padding: .35rem .6rem; }
.botao-padrao-oculto { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Prévia do fundo da tela de login (Configurações) */
.previa-login { position: relative; aspect-ratio: 16 / 9; border-radius: .5rem; overflow: hidden; border: 1px solid #d5dae3; }
.previa-fundo { position: absolute; inset: 0; }
.previa-caixa { position: absolute; width: 26%; padding: 4% 3%; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.previa-caixa > div { border-radius: 3px; margin-bottom: 8%; }
.previa-logo { height: 14px; width: 40%; margin: 0 auto; background: #c9cfdb; }
.previa-linha { height: 10px; background: #e5e8ef; border: 1px solid #d5dae3; }
.previa-botao { height: 12px; margin-bottom: 0 !important; }
.marca-preview-escuro { background: var(--sidebar-bg); border-color: #2b3a5c; }
.icone-app-previa { width: 60px !important; height: 60px !important; border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.2); }

/* Botão flutuante do WhatsApp */
.whatsapp-flutuante { position: fixed; bottom: 20px; z-index: 1050; display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.whatsapp-direita { right: 20px; }
.whatsapp-esquerda { left: 20px; flex-direction: row-reverse; }
.whatsapp-icone { width: 58px; height: 58px; border-radius: 50%; background: #25d366; color: #fff; font-size: 30px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.25); transition: transform .2s; position: relative; }
.whatsapp-icone::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 0 rgba(37,211,102,.6); animation: whatsapp-pulso 2.2s infinite; }
.whatsapp-texto { background: #fff; color: #1d2433; font-size: .875rem; font-weight: 600; padding: .45rem .8rem; border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18); white-space: nowrap; }
.whatsapp-flutuante:hover .whatsapp-icone, .whatsapp-flutuante:focus-visible .whatsapp-icone { transform: scale(1.08); }
.whatsapp-flutuante:focus-visible { outline: none; }
.whatsapp-flutuante:focus-visible .whatsapp-icone { outline: 3px solid #1d2433; outline-offset: 3px; }
@keyframes whatsapp-pulso { 0% { box-shadow: 0 0 0 0 rgba(37,211,102,.55); } 70% { box-shadow: 0 0 0 14px rgba(37,211,102,0); } 100% { box-shadow: 0 0 0 0 rgba(37,211,102,0); } }
@media (prefers-reduced-motion: reduce) { .whatsapp-icone::after { animation: none; } .whatsapp-icone { transition: none; } }
@media (max-width: 575.98px) {
  .whatsapp-flutuante { bottom: 14px; }
  .whatsapp-direita { right: 14px; } .whatsapp-esquerda { left: 14px; }
  .whatsapp-texto { display: none; }
  .whatsapp-icone { width: 52px; height: 52px; font-size: 27px; }
}
@media print { .whatsapp-flutuante { display: none !important; } }
.page { padding-bottom: 5.5rem; } /* espaço para o botão flutuante não cobrir botões do fim da página */

/* Submenu de Configurações no menu lateral */
.sidebar .nav-link.aberto { color: #fff; background: rgba(255,255,255,.06); }
.sidebar .submenu { margin: 2px 0 6px 1.1rem; padding-left: .5rem; border-left: 1px solid rgba(255,255,255,.12); }
.sidebar .submenu .nav-link { padding: .35rem .65rem; font-size: .85rem; }
.sidebar .submenu .nav-link i { width: 1.25rem; }
.sidebar { overflow-y: auto; }
/* Abas das configurações (telas pequenas, onde o menu lateral fica escondido) */
.config-abas { flex-wrap: nowrap; overflow-x: auto; gap: .25rem; padding-bottom: .25rem; }
.config-abas .nav-link { white-space: nowrap; font-size: .875rem; padding: .4rem .7rem; }

/* Página Links */
.link-card { transition: border-color .15s, box-shadow .15s, transform .15s; }
.link-card:hover, .link-card:focus-visible { border-color: var(--c-brand, var(--c-com)); box-shadow: 0 4px 14px rgba(16,24,40,.08); transform: translateY(-1px); }
.link-icone { width: 42px; height: 42px; flex-shrink: 0; border-radius: .6rem; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.25rem; background: rgba(var(--bs-primary-rgb), .1); color: var(--c-brand-dark, var(--c-com)); }
.link-dominio { color: var(--c-brand-dark, #1c5aa6); }
.min-w-0 { min-width: 0; }
@media (prefers-reduced-motion: reduce) { .link-card { transition: none; } .link-card:hover { transform: none; } }

/* DAS-MEI */
.das-tabela td { padding-top: .6rem; padding-bottom: .6rem; }
.das-tabela tr.das-vencido { --bs-table-bg: #fff5f5; }
.das-linha { font-size: .78rem; color: #1d2433; white-space: nowrap; }
.das-composicao strong { color: #1d2433; }
.copia-aviso { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 2000; background: #1d2433; color: #fff;
  padding: .6rem 1rem; border-radius: .5rem; font-size: .875rem; max-width: calc(100% - 2rem); }
.arquivos-soltar { display: block; text-align: center; padding: 1.25rem 1rem; border: 2px dashed #c9d2e3; border-radius: .75rem; cursor: pointer;
  color: #3b4456; background: #fafbfd; transition: border-color .15s, background .15s; }
.arquivos-soltar:hover, .arquivos-soltar.ativo { border-color: var(--c-brand, var(--c-com)); background: rgba(var(--bs-primary-rgb), .05); }
.arquivos-soltar:focus-within { outline: 2px solid var(--c-brand, var(--c-com)); outline-offset: 2px; }
.das-colar { padding: .75rem; border: 1px dashed #c9d2e3; border-radius: .6rem; background: #fafbfd; }
.das-colar kbd { font-size: .75em; padding: .1rem .3rem; }
