/* Modal Importar — overlay + caixa */

.imp-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.imp-overlay.on { display: flex }

/* ── Drawer: painel deslizando da direita (fácil reverter: DRAWER=false no JS) ── */
.imp-overlay.imp-drawer { align-items: stretch; justify-content: flex-end; }
.imp-overlay.imp-drawer .imp-modal {
  max-width: 480px; width: 100%; height: 100vh; max-height: 100vh;
  border-radius: 0; border: none; border-left: 1px solid var(--border);
  box-shadow: -18px 0 50px rgba(0,0,0,.32);
  transform: translateX(100%); transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}
.imp-overlay.imp-drawer.on .imp-modal { transform: translateX(0); }
@media (max-width: 540px) { .imp-overlay.imp-drawer .imp-modal { max-width: 100%; } }

.imp-modal {
  background: var(--surface);
  border-radius: .8rem;
  max-width: 640px;
  width: calc(100% - 2rem);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,.4);
  border: 1px solid var(--border);
}

.imp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.imp-header-title { font-size: .92rem; font-weight: 700; color: var(--text) }
.imp-header-sub   { font-size: .68rem; color: var(--text-mut); margin-top: .15rem }

.imp-close {
  background: transparent; border: none; cursor: pointer;
  font-size: .65rem; font-weight: 700;
  color: var(--text-mut); text-transform: uppercase; letter-spacing: .05em;
}
.imp-close:hover { color: var(--text) }

.imp-body { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 1.1rem }

.imp-block-title {
  font-size: .58rem; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 700; color: var(--text-dim);
  margin-bottom: .5rem;
}

.imp-drop {
  display: block;
  border: 2px dashed var(--border-2);
  border-radius: .55rem;
  padding: 1.4rem 1rem;
  text-align: center;
  color: var(--text-mut);
  transition: all .12s;
  cursor: pointer;
}
.imp-drop:hover, .imp-drop.drag { border-color: #2563eb; background: var(--bg-2) }
.imp-drop-title { font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: .3rem }
.imp-drop-hint  { font-size: .68rem; color: var(--text-mut) }

.imp-row {
  display: flex; gap: .8rem; align-items: flex-end;
}
.imp-row > * { flex: 1; min-width: 0 }

.imp-radio-group { display: flex; gap: .7rem; padding-top: .5rem }
.imp-radio-group label {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .75rem; color: var(--text);
}

.imp-field {
  display: flex; flex-direction: column; gap: .3rem;
}
.imp-field-label {
  font-size: .58rem; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 700; color: var(--text-dim);
}
.imp-field-input, .imp-field select {
  padding: .4rem .55rem;
  font-size: .75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: .35rem;
}

.imp-result {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .7rem .85rem;
  font-size: .75rem;
  color: var(--text);
}
.imp-result-ok  { border-color: #10b981 }
.imp-result-err { border-color: #ef4444; color: #b91c1c }

.imp-footer {
  display: flex; justify-content: flex-end; gap: .5rem;
  padding: .8rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}

/* seletor de período do Pluggy */
.imp-period { display: flex; gap: .35rem; flex-wrap: wrap; }
.imp-period button {
  font-size: .72rem; padding: .3rem .6rem; border-radius: .35rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); cursor: pointer;
}
.imp-period button.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.imp-period-custom { margin-top: .45rem; font-size: .72rem; }
.imp-period-custom[hidden] { display: none; }
.imp-period-custom input { font-size: .72rem; padding: .25rem .35rem; border: 1px solid var(--border); border-radius: .35rem; background: var(--surface); color: var(--text); }

/* histórico de importações dentro do modal */
.imp-hist-link { font-size: .7rem; color: var(--accent, #4f46e5); cursor: pointer; font-weight: 600; }
.imp-hist { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: .3rem; }
.imp-hist-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: .4rem; background: var(--bg-2); }
.imp-hist-info { font-size: .7rem; color: var(--text); }
.imp-hist-dt { color: var(--text-mut); margin-left: .25rem; }
.imp-hist-undo { font-size: .66rem; font-weight: 700; padding: .2rem .5rem; border-radius: .35rem; border: 1px solid rgba(244,63,94,.4); background: rgba(244,63,94,.08); color: #e11d48; cursor: pointer; }
.imp-hist-undo:hover { background: rgba(244,63,94,.18); }
.imp-hist-undone { font-size: .64rem; color: var(--text-mut); font-style: italic; }

/* calendário de intervalo (início/fim) */
.rcal { border: 1px solid var(--border); border-radius: .6rem; padding: .45rem .5rem; background: var(--surface); max-width: 248px; }
.rcal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .3rem; }
.rcal-title { font-size: .76rem; font-weight: 700; color: var(--text); text-transform: capitalize; }
.rcal-nav { width: 1.5rem; height: 1.5rem; border-radius: .35rem; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: .9rem; line-height: 1; }
.rcal-nav:hover { background: var(--bg-2); }
.rcal-dow, .rcal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.rcal-dow span { text-align: center; font-size: .54rem; font-weight: 700; color: var(--text-dim); padding: .15rem 0; }
.rcal-empty { aspect-ratio: 1; }
.rcal-day {
  aspect-ratio: 1; border: none; background: transparent; color: var(--text); cursor: pointer;
  font-size: .66rem; border-radius: .35rem; font-variant-numeric: tabular-nums;
}
.rcal-day:hover { background: var(--bg-2); }
.rcal-day.in { background: rgba(99,102,241,.14); border-radius: 0; color: #4338ca; }
.rcal-day.ini, .rcal-day.fim { background: linear-gradient(135deg,#6366f1,#4f46e5); color: #fff; font-weight: 700; }
.rcal-day.ini { border-radius: .4rem 0 0 .4rem; }
.rcal-day.fim { border-radius: 0 .4rem .4rem 0; }
.rcal-foot { display: flex; gap: .8rem; margin-top: .5rem; font-size: .68rem; color: var(--text-mut); }
.rcal-tag b { color: var(--text); margin-left: .25rem; }
.imp-cal-quick { display: flex; gap: .4rem; margin-bottom: .5rem; }
.imp-cal-quick button { font-size: .66rem; padding: .2rem .5rem; border-radius: .35rem; border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); cursor: pointer; }
.imp-cal-quick button:hover { background: var(--bg-2); color: var(--text); }

/* ── Redesign import: superfície única + acessórios demovidos ───────────── */
.imp-modal-import { max-width: 440px; }
.imp-body-import { gap: .75rem; }
.imp-cta { width: 100%; }
.imp-actions-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: -.25rem; }
.imp-link { background: transparent; border: none; cursor: pointer; padding: 0; font-size: .72rem; font-weight: 600; color: #4f46e5; }
.imp-link:hover { text-decoration: underline; }
.imp-colar[hidden] { display: none; }
.imp-colar textarea { width: 100%; box-sizing: border-box; resize: vertical; font-size: .72rem; padding: .5rem; border: 1px solid var(--border); border-radius: .45rem; background: var(--surface); color: var(--text); }
.imp-secondary { display: flex; align-items: center; gap: .5rem; justify-content: center; padding-top: .65rem; border-top: 1px solid var(--border); }
.imp-secondary .imp-sep { color: var(--text-mut); }
/* sub-modal Conferir fatura — duas opções equilibradas */
.imp-conf-dest { display: flex; gap: .4rem; margin-bottom: .7rem; }
.imp-conf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; align-items: stretch; }
.imp-conf-card { display: flex; flex-direction: column; gap: .45rem; padding: .75rem .8rem; border: 1px solid var(--border); border-radius: .55rem; background: var(--bg-2); }
.imp-conf-card-t { font-size: .76rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .4rem; }
.imp-conf-tag { font-size: .54rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #fff; background: #4f46e5; border-radius: 5px; padding: .08rem .32rem; }
.imp-conf-tag.alt { background: #0ea5e9; }
.imp-conf-card-d { font-size: .68rem; color: var(--text-mut); margin: 0 0 .15rem; line-height: 1.35; flex: 1; }
.imp-conf-cta { width: 100%; justify-content: center; text-align: center; cursor: pointer; margin-top: auto; }
@media (max-width: 520px) { .imp-conf-grid { grid-template-columns: 1fr; } }

/* modal de importação em abas (legado) */
.imp-modal-tabs { max-width: 420px; }
/* calendário como popover flutuante do botão "Período" (fixed → não é cortado pelo modal) */
#plCal {
  position: fixed; z-index: 9000; padding: .4rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: .6rem;
  box-shadow: 0 14px 34px rgba(15,23,42,.28);
}
#plCal .rcal { border: 0; padding: 0; width: 232px; max-width: 232px; box-shadow: none; }
.imp-modal-tabs .imp-footer { padding: .8rem 1.1rem; border-top: 1px solid var(--border); }
.imp-modal-tabs .imp-body { overflow: visible; }   /* deixa o popover do calendário aparecer inteiro */
/* conta agora vive DENTRO do corpo (abaixo das sub-abas) — sem padding próprio,
   com um divisor sutil separando do conteúdo da aba */
.imp-conta { display: flex; flex-direction: column; gap: .3rem; padding: 0 0 .75rem; margin: 0 0 .75rem; border-bottom: 1px solid var(--border); }
.imp-conta select { font-size: .8rem; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: .45rem; background: var(--surface); color: var(--text); }
.imp-tabs { display: flex; flex-wrap: nowrap; gap: .15rem; border-bottom: 1px solid var(--border); margin: 0; padding: 0 1.1rem; overflow-x: auto; scrollbar-width: thin; }
.imp-tab {
  font-size: .78rem; font-weight: 600; padding: .45rem .6rem;
  border: none; background: transparent; color: var(--text-dim); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap; flex: 0 0 auto;        /* não quebra; rola horizontal se faltar espaço */
}
.imp-tab:hover { color: var(--text); }
.imp-tab.on { color: #4338ca; border-bottom-color: #4f46e5; }
.imp-pane { display: none; padding-top: .4rem; }
.imp-pane.on { display: block; }

.imp-cal-resumo { font-size: .76rem; font-weight: 600; color: var(--text); margin: .45rem 0 .2rem; }
.imp-cal-quick button.on { background: var(--text); color: var(--surface); border-color: var(--text); }
#plCal[hidden] { display: none; }

/* modal de desfazer seletivo */
.df-row { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem; border-bottom: 1px solid var(--border); font-size: .76rem; cursor: pointer; }
.df-row:hover { background: var(--bg-2); }
.df-chk { cursor: pointer; }
.df-data { color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 2.6rem; }
.df-desc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.df-desc i { color: var(--text-mut); font-size: .68rem; }
.df-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.df-val.neg { color: #dc2626; } .df-val.pos { color: #059669; }

/* botão em loading (busca Pluggy) */
.btn-page.loading { opacity: .9; cursor: progress; position: relative; padding-left: 1.9rem; }
.btn-page.loading::before {
  content: ''; position: absolute; left: .65rem; top: 50%; width: .85rem; height: .85rem; margin-top: -.43rem;
  border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%;
  animation: imp-spin .7s linear infinite;
}
@keyframes imp-spin { to { transform: rotate(360deg); } }

/* Vincular linha do extrato a um lançamento que já existe (conta fixa variável) */
.conc-vinc { font-size: .6rem; font-weight: 700; background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; border-radius: .35rem; padding: .05rem .3rem; cursor: pointer; margin-left: .2rem; line-height: 1.3; }
.conc-vinc:hover { background: #e0e7ff; }
.conc-row.is-vinc { background: rgba(79, 70, 229, .07); }
.conc-vinc-chip { font-size: .6rem; font-weight: 600; background: #dcfce7; color: #166534; border: 1px solid #86efac; border-radius: .35rem; padding: .05rem .3rem; margin-left: .25rem; display: inline-flex; gap: .25rem; align-items: center; }
.conc-vinc-x { border: none; background: transparent; color: #166534; cursor: pointer; font-size: .58rem; padding: 0; line-height: 1; }
.conc-vinc-pop { z-index: 400; width: 266px; background: var(--surface); border: 1px solid var(--border); border-radius: .5rem; box-shadow: 0 10px 28px rgba(0,0,0,.2); padding: .45rem; }
.conc-vinc-q { width: 100%; box-sizing: border-box; font-size: .72rem; padding: .4rem; border: 1px solid var(--border); border-radius: .35rem; background: var(--surface); color: var(--text); }
.conc-vinc-res { max-height: 184px; overflow-y: auto; margin-top: .35rem; }
.conc-vinc-item { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; background: transparent; border: none; border-bottom: 1px solid var(--border); padding: .35rem .25rem; cursor: pointer; gap: .05rem; }
.conc-vinc-item:hover { background: rgba(79, 70, 229, .08); }
.conc-vinc-nome { font-size: .7rem; font-weight: 600; color: var(--text); }
.conc-vinc-meta { font-size: .6rem; color: var(--text-mut); }
.conc-vinc-empty { font-size: .66rem; color: var(--text-mut); padding: .35rem; }

/* picker de vincular: abas (Esta conta / Outras contas) + ícone de filtro */
.conc-vinc-pop { width: 304px; }
.conc-vinc-head { display: flex; align-items: stretch; gap: .3rem; margin-bottom: .4rem; border-bottom: 1px solid var(--border); }
.conc-vinc-tabs { display: flex; gap: .15rem; flex: 1; }
.conc-vinc-tabs button { flex: 1; font-size: .64rem; font-weight: 600; padding: .28rem .2rem; border: none; background: transparent; color: var(--text-dim); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.conc-vinc-tabs button:hover { color: var(--text); }
.conc-vinc-tabs button.on { color: #4338ca; border-bottom-color: #4f46e5; }
/* dois ícone-botões iguais: filtrar (lupa) e realizados (check) */
.conc-vinc-iconbtn { display: flex; align-items: center; justify-content: center; align-self: center; width: 1.55rem; height: 1.55rem; padding: 0; border: 1px solid transparent; border-radius: .35rem; background: transparent; color: var(--text-dim); cursor: pointer; }
.conc-vinc-iconbtn:hover { color: var(--text); background: var(--bg-2); }
.conc-vinc-iconbtn.on { color: #4338ca; background: rgba(99,102,241,.12); border-color: #c7d2fe; }
.conc-vinc-filter { width: 100%; box-sizing: border-box; font-size: .72rem; padding: .35rem .45rem; border: 1px solid var(--border); border-radius: .35rem; background: var(--surface); color: var(--text); margin-bottom: .35rem; }
.conc-vinc-filter[hidden] { display: none; }
.conc-vinc-pane[hidden] { display: none; }
.conc-vinc-list { max-height: 230px; overflow-y: auto; }
.conc-vinc-grp { font-size: .56rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-mut); font-weight: 700; padding: .4rem .25rem .15rem; position: sticky; top: 0; background: var(--surface); }
.conc-vinc-item.ref { cursor: default; opacity: .8; }
.conc-vinc-item.ref:hover { background: transparent; }

/* Atrelar saída do banco a uma fatura de cartão (mesmo aberta) */
.conc-fat { font-size: .6rem; font-weight: 700; background: #fef3c7; color: #92400e; border: 1px solid #fde68a; border-radius: .35rem; padding: .05rem .3rem; cursor: pointer; margin-left: .2rem; line-height: 1.3; }
.conc-fat:hover { background: #fde68a; }
.conc-row.is-fat { background: rgba(245, 158, 11, .08); }
.conc-fat-chip { font-size: .6rem; font-weight: 600; background: #fef3c7; color: #92400e; border: 1px solid #fde68a; border-radius: .35rem; padding: .05rem .3rem; margin-left: .25rem; display: inline-flex; gap: .25rem; align-items: center; }
.conc-fat-x { border: none; background: transparent; color: #92400e; cursor: pointer; font-size: .58rem; padding: 0; line-height: 1; }

/* Grupo de ações da linha — botões de ícone alinhados [ ↔ | cartão | ↻ ] */
.conc-actgrp { display: inline-flex; align-items: center; vertical-align: middle; margin-left: .25rem; border: 1px solid var(--border); border-radius: .4rem; overflow: hidden; }
.conc-act { display: inline-flex; align-items: center; justify-content: center; padding: .16rem .34rem; background: var(--surface); color: var(--text-mut); border: none; border-left: 1px solid var(--border); cursor: pointer; line-height: 0; }
.conc-act:first-child { border-left: none; }
.conc-act:hover { background: var(--bg-2); color: var(--text); }
.conc-act.on { background: #eef2ff; color: #4338ca; }

/* "aplicar a +N parecidas" — propaga nome/classificação pras linhas iguais do mês */
.conc-parecidas { display: inline-block; margin-top: .15rem; font-size: .6rem; font-weight: 600; color: #4338ca; background: #eef2ff; border: 1px dashed #c7d2fe; border-radius: .35rem; padding: .05rem .35rem; cursor: pointer; line-height: 1.3; }
.conc-parecidas:hover { background: #e0e7ff; }

/* Badge "realiza planejado" + legenda intuitiva da conciliação */
.conc-badge.realizar { background: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; }
/* Vinculado → o chip "✓ Nome" já diz tudo; esconde o badge de status (sem redundância) */
.conc-row.is-vinc .conc-badge { display: none; }
.conc-legenda { display: flex; flex-wrap: wrap; gap: .35rem .9rem; padding: .5rem 1.1rem; font-size: .68rem; color: var(--text-mut); border-bottom: 1px solid var(--border); background: var(--bg-2); }
.conc-legenda .conc-badge { font-size: .58rem; margin-right: .25rem; vertical-align: middle; }
.conc-leg { display: inline-flex; align-items: center; }

/* Banner do ciclo da fatura na conciliação (cartão CSV) */
.conc-fatura-banner { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .5rem .9rem; background: rgba(245,158,11,.1); border-bottom: 1px solid #fde68a; font-size: .74rem; color: #92400e; }
.conc-fatura-lbl { font-weight: 700; }
.conc-fatura-banner select { font-size: .74rem; font-weight: 600; padding: .25rem .5rem; border: 1px solid #f59e0b; border-radius: .35rem; background: var(--surface); color: var(--text); }
.conc-fatura-hint { font-size: .66rem; color: var(--text-mut); }

/* Aba "Como importar" */
.imp-ajuda { font-size: .76rem; color: var(--text); line-height: 1.45; }
.imp-ajuda-intro { margin: 0 0 .7rem; padding: .55rem .7rem; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; }
.imp-ajuda-tbl { width: 100%; border-collapse: collapse; margin-bottom: .7rem; }
.imp-ajuda-tbl th, .imp-ajuda-tbl td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.imp-ajuda-tbl th { font-size: .66rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-mut); }
.imp-ajuda-tbl td:first-child { white-space: nowrap; }
.imp-ajuda-tag { display: inline-block; font-size: .58rem; font-weight: 700; color: #fff; background: var(--accent, #6d28d9); border-radius: 5px; padding: .05rem .3rem; margin-left: .3rem; vertical-align: middle; }
.imp-ajuda-dim { font-size: .7rem; color: var(--text-mut); margin: 0; }
