/* ============================================================
   CONTEC · Sistema financeiro multi-tenant
   Design System — mobile-first · identidade Contec
   ============================================================ */

:root {
  /* Paleta oficial Contec */
  --ink:        #181B2E;   /* texto/superfícies escuras */
  --ink-2:      #20233A;   /* superfície escura elevada */
  --ink-3:      #2B2F49;   /* borda/linha em fundo escuro */
  --brand:      #00207D;   /* navy — cor primária */
  --brand-2:    #123099;   /* navy médio (hover) */
  --accent:     #3F6BD6;   /* azul de apoio (destaque) */
  --paper:      #FBFDFF;   /* off-white / cream */
  --black:      #0B0D17;

  /* Neutros derivados */
  --bg:         #FBFDFF;   /* fundo do app (cream) */
  --surface:    #FFFFFF;   /* cartões */
  --surface-2:  #F3F6FC;
  --line:       #CFE2F5;   /* bordas */
  --text:       #181B2E;   /* texto principal */
  --muted:      #767A93;   /* texto secundário */
  --muted-2:    #9BA0B8;
  --navy-soft:  #E9ECFA;   /* tinta clara da marca (badges/fundos) */

  /* Semânticos */
  --pos:        #1E7A4C;   /* positivo / receita */
  --neg:        #C0392B;   /* negativo / despesa */
  --warn:       #B5810A;

  /* Gradiente da marca */
  --grad: linear-gradient(135deg, #00207D 0%, #123099 55%, #3F6BD6 100%);
  --grad-lime: linear-gradient(135deg, #00207D 0%, #3F6BD6 100%);

  /* Ritmo */
  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(24,27,46,.06), 0 1px 3px rgba(24,27,46,.05);
  --shadow:    0 4px 16px rgba(24,27,46,.08);
  --shadow-lg: 0 18px 40px rgba(24,27,46,.16);

  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --display: "Plus Jakarta Sans", var(--font);

  --header-h: 60px;
  --nav-h: 64px;          /* bottom nav mobile */
  --sidebar-w: 250px;

  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
img { max-width: 100%; display: block; }
svg:not([width]) { width: 1.15em; height: 1.15em; flex: none; vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--brand); color: #fff; }
[hidden] { display: none !important; }

h1,h2,h3,h4 { font-family: var(--display); font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
.display { font-family: var(--display); }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ---------- Utilitários ---------- */
.eyebrow { font-size: .68rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-1 { gap: .4rem; } .gap-2 { gap: .8rem; } .gap-3 { gap: 1.2rem; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { align-items: center; justify-content: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.txt-sm { font-size: .82rem; } .txt-xs { font-size: .72rem; }
.mt-1{margin-top:.4rem}.mt-2{margin-top:.8rem}.mt-3{margin-top:1.2rem}.mt-4{margin-top:1.8rem}

/* ---------- Wordmark (sem logo-imagem) ---------- */
.wordmark { font-family: var(--display); font-weight: 800; letter-spacing: .06em; color: var(--brand); }
.wordmark.on-dark { color: #fff; }
.wordmark .dot { color: var(--accent); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  height: 46px; padding: 0 1.15rem; border-radius: var(--r-sm);
  font-weight: 600; font-size: .92rem; letter-spacing: .01em;
  transition: transform .12s ease, background .2s, box-shadow .2s, border-color .2s, opacity .2s;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-2); }
.btn-grad { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(0,32,125,.35); }
.btn-grad:hover { filter: brightness(1.08); }
.btn-dark { background: var(--ink); color: var(--paper); }
.btn-dark:hover { background: #10121f; }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-block { width: 100%; }
.btn-lg { height: 54px; font-size: 1rem; }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: var(--r-sm); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field > label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.input, .select, textarea.input {
  width: 100%; height: 48px; padding: 0 .9rem;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--r-sm); font-size: .95rem; transition: border-color .18s, box-shadow .18s;
}
textarea.input { height: auto; padding: .7rem .9rem; min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,32,125,.15);
}
.input::placeholder { color: var(--muted-2); }
.input-group { position: relative; }
.input-group .input { padding-left: 2.6rem; }
.input-group .ig-icon { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }

/* ---------- Combo (dropdown próprio p/ inputs — funciona no celular) ---------- */
.combo-pop {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 5px; z-index: 60;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-sm);
  box-shadow: 0 14px 34px rgba(0,0,0,.16); max-height: 260px; overflow-y: auto;
  padding: 5px; -webkit-overflow-scrolling: touch;
}
.combo-opt {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: .72rem .8rem; border-radius: 8px; font-size: .95rem; color: inherit; cursor: pointer;
}
.combo-opt:hover, .combo-opt:active { background: var(--surface-2); }

/* ---------- Cartão ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 1.1rem; }
.card-h { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.card-h h3 { font-size: 1rem; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; height: 24px; padding: 0 .55rem; border-radius: 999px; font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.badge-fixo { background: var(--navy-soft); color: var(--brand); }
.badge-var  { background: #FDF1DC; color: #8A6100; }
.badge-pos  { background: #E3F3EA; color: var(--pos); }
.badge-neg  { background: #FBE7E4; color: var(--neg); }
.badge-role { background: var(--ink); color: #fff; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-ov {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(24,27,46,.55); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 1.2rem;
}
.modal-card {
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
.modal-card .card-h { position: sticky; top: 0; background: var(--surface); }

/* ============================================================
   LOGIN
   ============================================================ */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(63,107,214,.28), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(0,32,125,.22), transparent 55%),
    var(--ink);
  position: relative; overflow: hidden;
}
.login::after {
  content:""; position:absolute; inset:0; pointer-events:none;
  background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(circle at 50% 30%, #000, transparent 75%);
}
.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 400px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--r-lg); padding: 2rem 1.6rem; backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg); color: var(--paper);
}
.login-card .wordmark { display: block; text-align: center; font-size: 1.6rem; margin: 0 auto 1.4rem; }
.login-card h1 { font-size: 1.5rem; text-align: center; }
.login-card .sub { text-align: center; color: rgba(251,253,255,.6); font-size: .88rem; margin-top: .25rem; margin-bottom: 1.6rem; }
.login-card .field > label { color: rgba(251,253,255,.7); }
.login-card .input {
  background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.16); color: var(--paper);
}
.login-card .input::placeholder { color: rgba(251,253,255,.4); }
.login-card .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63,107,214,.3); }
.login-err { background: rgba(192,57,43,.16); border: 1px solid rgba(192,57,43,.4); color: #ffb4ad; font-size: .84rem; padding: .6rem .8rem; border-radius: var(--r-sm); }
.login-foot { text-align: center; margin-top: 1.4rem; font-size: .74rem; color: rgba(251,253,255,.4); }

/* ============================================================
   "Atuando como" — banner de impersonação (equipe Contec no cliente)
   ============================================================ */
.acting-banner {
  background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: space-between;
  gap: .8rem; padding: .55rem 1rem; font-size: .84rem; flex-wrap: wrap;
}
.acting-banner b { color: #fff; }
.acting-banner .btn { height: 32px; padding: 0 .8rem; font-size: .78rem; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { min-height: 100dvh; }

/* Sidebar (desktop) */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: var(--ink); color: var(--paper);
  display: none; flex-direction: column; padding: 1.1rem .8rem;
}
.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem 1.2rem; }
.side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; }
.side-nav::-webkit-scrollbar { width: 0; height: 0; display: none; }
.side-nav a {
  display: flex; align-items: center; gap: .8rem; padding: .7rem .7rem; border-radius: var(--r-sm);
  color: rgba(251,253,255,.72); font-weight: 500; font-size: .92rem; transition: background .16s, color .16s;
}
.side-nav a svg { width: 20px; height: 20px; flex: none; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: var(--paper); }
.side-nav a.active { background: var(--grad); color: #fff; font-weight: 600; }
.side-sep { font-size: .64rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: rgba(251,253,255,.35); padding: 1rem .7rem .4rem; }
.side-foot { margin-top: auto; border-top: 1px solid var(--ink-3); padding-top: .8rem; }
.side-user { display: flex; align-items: center; gap: .6rem; padding: .5rem; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--grad); color:#fff; display: grid; place-items: center; font-family: var(--display); font-weight: 700; flex: none; }

/* Topbar (mobile) */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--header-h);
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; gap: .6rem; padding: 0 1rem;
}
.topbar .tb-title { font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.topbar .btn-icon { color: var(--paper); }

/* Conteúdo */
.main { padding: 1rem 1rem calc(var(--nav-h) + var(--safe-b) + 1rem); max-width: 1200px; margin: 0 auto; }
.page-head { margin: .3rem 0 1rem; }
.page-head h1 { font-size: 1.5rem; }
.page-head p { color: var(--muted); font-size: .9rem; margin-top: .15rem; }

/* Bottom nav (mobile) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; align-items: stretch; box-shadow: 0 -6px 20px rgba(24,27,46,.06);
}
.bottom-nav a {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: .64rem; font-weight: 600; letter-spacing: .02em; position: relative;
}
.bottom-nav a svg { width: 23px; height: 23px; }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav a.active::before { content:""; position:absolute; top:0; width:32px; height:3px; border-radius:0 0 4px 4px; background: var(--grad); }

/* ---------- KPIs / métricas ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem; box-shadow: var(--shadow-sm); }
.kpi .kpi-label { font-size: .74rem; color: var(--muted); font-weight: 600; }
.kpi .kpi-val { font-family: var(--display); font-weight: 700; font-size: 1.5rem; margin-top: .2rem; line-height: 1; }
.kpi .kpi-sub { font-size: .72rem; margin-top: .3rem; }

/* menu mobile (drawer) reaproveita side-nav */
.drawer-scrim { position: fixed; inset: 0; background: rgba(24,27,46,.5); z-index: 49; opacity: 0; pointer-events: none; transition: opacity .25s; }
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: 82%; max-width: 300px; z-index: 50; background: var(--ink); color: var(--paper); transform: translateX(-100%); transition: transform .28s cubic-bezier(.4,0,.2,1); display: flex; flex-direction: column; padding: 1.1rem .8rem; }
.drawer.open { transform: none; }

/* ---------- Responsivo ---------- */
@media (min-width: 900px) {
  .sidebar { display: flex; }
  .topbar, .bottom-nav, .menu-btn { display: none; }
  .app { padding-left: var(--sidebar-w); }
  .main { padding: 1.8rem 2rem 2.4rem; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 1rem; }
  .page-head h1 { font-size: 1.9rem; }
}
@media (min-width: 700px) and (max-width: 899px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

/* utils grid */
.grid { display: grid; gap: 1rem; }
@media (min-width: 900px){ .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3,1fr);} }

/* ---------- Cards-resumo (Painel) ---------- */
.summary-card { display: block; transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease; }
.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.summary-card .card-h h3 { display: flex; align-items: center; gap: .5rem; }
.summary-card .ver { display: inline-flex; align-items: center; gap: .3rem; color: var(--brand); font-weight: 600; font-size: .8rem; margin-top: .9rem; }
.summary-card:hover .ver { gap: .5rem; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem 0; border-bottom: 1px dashed var(--line); font-size: .86rem; }
.mini-row:last-child { border-bottom: none; }
.big-num { font-family: var(--display); font-weight: 700; font-size: 1.9rem; line-height: 1; }

/* ---------- Tabelas ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th { text-align: left; font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: .6rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-2); }

/* ---------- Acordeão de categorias (Despesas) ---------- */
.cat-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); margin-bottom: .7rem; overflow: hidden; }
.cat-block > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .9rem 1.1rem; font-size: .95rem; }
.cat-block > summary::-webkit-details-marker { display: none; }
.cat-block > summary::after { content: "⌄"; color: var(--muted-2); font-size: 1.1rem; transition: transform .2s; margin-left: .3rem; }
.cat-block[open] > summary::after { transform: rotate(180deg); }
.cat-block > summary:hover { background: var(--surface-2); }
.cat-block .tbl { border-top: 1px solid var(--line); }
.cat-block .tbl th { background: var(--surface-2); }
.cat-dot { width: 11px; height: 11px; border-radius: 3px; flex: none; }

/* ---------- Upload / Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--r); background: var(--surface-2);
  padding: 1.6rem 1rem; text-align: center; cursor: pointer; transition: border-color .18s, background .18s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--navy-soft); }
.dropzone .dz-ic { width: 46px; height: 46px; border-radius: 14px; margin: 0 auto .6rem; display: grid; place-items: center; background: var(--grad); color: #fff; }
.dropzone .dz-ic svg { width: 24px; height: 24px; }
.dropzone b { font-size: .95rem; }
.dropzone p { color: var(--muted); font-size: .8rem; margin-top: .2rem; }

/* miniaturas de fotos */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .6rem; }
.thumb { position: relative; aspect-ratio: 3/4; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .thumb-n { position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 6px; background: rgba(24,27,46,.72); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; }
.thumb .thumb-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 6px; background: rgba(192,57,43,.92); color: #fff; display: grid; place-items: center; }
.thumb .thumb-x svg { width: 13px; height: 13px; }

/* lista de documentos/envios */
.doc-item { display: flex; align-items: center; gap: .8rem; padding: .8rem; border-bottom: 1px solid var(--line); }
.doc-item:last-child { border-bottom: none; }
.doc-ic { width: 42px; height: 42px; border-radius: 11px; flex: none; display: grid; place-items: center; }
.doc-ic.nf { background: var(--navy-soft); color: var(--brand); }
.doc-meta { flex: 1 1 auto; min-width: 0; }
.doc-meta b { font-size: .9rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta span { font-size: .74rem; color: var(--muted); }

/* toast */
.toast-wrap { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: .5rem; align-items: center; width: max-content; max-width: 90vw; }
@media (min-width:900px){ .toast-wrap { bottom: 24px; } }
.toast { background: var(--ink); color: var(--paper); padding: .7rem 1rem; border-radius: 999px; font-size: .86rem; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: .5rem; animation: toast-in .25s ease; }
.toast.ok { background: #1D5B37; } .toast.err { background: #8E2A20; }
.toast svg { width: 17px; height: 17px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* form de recebimentos */
.rec-grid { display: grid; grid-template-columns: 1.5fr .9fr .9fr; gap: .8rem; align-items: end; }
.rec-actions { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: .9rem; flex-wrap: wrap; }
.rec-pago { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; cursor: pointer; color: var(--text); user-select: none; }
.rec-pago input { width: 18px; height: 18px; accent-color: var(--brand); }
.rec-actions .btn { min-width: 130px; }
@media (max-width: 680px) {
  .rec-grid { grid-template-columns: 1fr 1fr; }
  .rec-grid .field:first-child { grid-column: 1 / -1; }
  .rec-actions { flex-direction: column-reverse; align-items: stretch; }
  .rec-actions .btn { width: 100%; }
  .rec-pago { justify-content: center; padding: .3rem 0; }
}

/* Assistente IA — chat */
.chat-card { display: flex; flex-direction: column; height: calc(100dvh - 230px); min-height: 400px; padding: 0; overflow: hidden; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 1rem; }
.chat-bubble { max-width: 84%; padding: .7rem .9rem; border-radius: 14px; margin-bottom: .7rem; font-size: .92rem; line-height: 1.45; word-wrap: break-word; }
.chat-bubble.bot { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-top-left-radius: 4px; }
.chat-bubble.me { background: var(--grad); color: #fff; margin-left: auto; border-top-right-radius: 4px; font-weight: 500; }
.chat-bubble.bot svg { width: 16px; height: 16px; vertical-align: -3px; color: var(--brand); }
.chat-bubble.err { background: #FBE7E4; color: #8E2A20; border-color: #F2C4BC; }
.chat-sugs { display: flex; flex-wrap: wrap; gap: .5rem; margin: .2rem 0 .3rem; }
.chat-sug { text-align: left; font-size: .82rem; padding: .5rem .75rem; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; cursor: pointer; color: var(--text); transition: .15s; }
.chat-sug:hover { border-color: var(--brand); background: var(--surface-2); }
.chat-input { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--line); background: var(--surface); }
.chat-input .input { flex: 1; }
.chat-input .btn { width: 48px; padding: 0; flex: none; }
.chat-input .btn svg { width: 18px; height: 18px; }
.typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); animation: typing 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%,60%,100% { opacity: .3; } 30% { opacity: 1; } }

/* CONTEC IA — widget flutuante (chatbox no canto) */
.milen-fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 75; width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--grad); color: #fff; box-shadow: var(--shadow-lg); cursor: pointer; display: grid; place-items: center; transition: transform .15s ease; }
.milen-fab:hover { transform: scale(1.06); }
.milen-fab:active { transform: scale(.96); }
.milen-fab svg { width: 27px; height: 27px; }
.milen-fab.active { transform: scale(.9); opacity: .85; }
@media (min-width: 900px) { .milen-fab { right: 24px; bottom: 24px; width: 60px; height: 60px; } }

.milen-panel { position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 80px); z-index: 76; width: min(384px, calc(100vw - 32px)); height: min(560px, calc(100dvh - var(--nav-h) - 130px)); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: milen-in .18s ease; }
@media (min-width: 900px) { .milen-panel { right: 24px; bottom: 96px; height: min(600px, calc(100dvh - 140px)); } }
@keyframes milen-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.milen-head { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; background: var(--ink); color: var(--paper); flex: none; }
.milen-title { display: flex; align-items: center; gap: .5rem; font-family: var(--display); font-size: 1.1rem; }
.milen-title svg { width: 19px; height: 19px; color: var(--accent); }
.milen-close { background: none; border: none; color: var(--paper); cursor: pointer; opacity: .75; padding: 4px; }
.milen-close:hover { opacity: 1; }
.milen-close svg { width: 18px; height: 18px; }
.milen-scroll { flex: 1; overflow-y: auto; padding: .9rem; background: var(--bg); }
.milen-input { display: flex; gap: .5rem; padding: .6rem; border-top: 1px solid var(--line); background: var(--surface); flex: none; }
.milen-input .input { flex: 1; }
.milen-input .btn { width: 46px; flex: none; padding: 0; }
.milen-input .btn svg { width: 18px; height: 18px; }

/* filtros de documentos */
.doc-filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.doc-selects { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.doc-selects .select { max-width: 170px; height: 40px; }
.doc-selects #docQ { min-width: 190px; height: 40px; }
@media (max-width: 780px) {
  .doc-filters { flex-direction: column; align-items: stretch; }
  .doc-selects { width: 100%; }
  .doc-selects > * { flex: 1 1 130px; max-width: none; }
}

/* adicionar despesa (Lançamentos) */
.desp-add { display: grid; grid-template-columns: 2fr 1.2fr .9fr .7fr 1.1fr auto; gap: .7rem; align-items: end; }
.desp-add .btn { height: 44px; white-space: nowrap; }
@media (max-width: 780px) {
  .desp-add { grid-template-columns: 1fr 1fr; }
  .desp-add .field:first-child { grid-column: 1 / -1; }
  .desp-add .btn { grid-column: 1 / -1; width: 100%; }
}

/* gráficos — altura travada (Chart.js com maintainAspectRatio:false) */
.chartbox { position: relative; width: 100%; height: clamp(220px, 30vw, 300px); }
.chartbox.sm { height: 130px; }
.chartbox.mini { width: 108px; height: 108px; flex: none; }
.chartbox canvas { display: block; }

/* spinner */
.spin { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-screen { min-height: 100dvh; display: grid; place-items: center; background: var(--ink); }
.loading-screen .spin { width: 30px; height: 30px; border-color: rgba(63,107,214,.3); border-top-color: var(--accent); }

/* ---------- Folha de Pagamento — abas por CNPJ ---------- */
.pp-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin: .2rem 0 1rem; }
.pp-tabs .tab-btn {
  padding: .55rem 1rem; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: .82rem; transition: all .15s;
}
.pp-tabs .tab-btn:hover { border-color: var(--brand); color: var(--brand); }
.pp-tabs .tab-btn.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(0,32,125,.3); }

/* ---------- Painel mãe (Contec) ---------- */
.tenant-row { display: flex; align-items: center; gap: .8rem; padding: .85rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tenant-row:last-child { border-bottom: none; }
.tenant-ic { width: 42px; height: 42px; border-radius: 11px; flex: none; display: grid; place-items: center; background: var(--navy-soft); color: var(--brand); font-family: var(--display); font-weight: 700; }
