/* ============================================================
   Controle de Investimentos de Marketing — identidade própria
   (indigo/slate + verde/âmbar para status confirmado/previsto)
   ============================================================ */
:root {
  --indigo: #2c7a7d;
  --indigo-dark: #205c5e;
  --indigo-50: #eaf6f6;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --red: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--slate-50);
  color: var(--slate-900);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--indigo); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 16px; }
h4 { font-size: 13px; color: var(--slate-700); margin-top: 14px; }
.muted { color: var(--slate-500); font-size: 12.5px; margin: 0; }
.empty { color: var(--slate-500); padding: 18px; text-align: center; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar {
  background: #000; color: #e2e8f0; padding: 20px 14px;
  display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand__mark { width: 32px; height: 32px; object-fit: contain; flex: none; background: #fff; border-radius: 8px; padding: 4px; }
.brand__txt { font-weight: 700; font-size: 13px; line-height: 1.3; }
.brand__txt small { font-weight: 500; font-size: 10.5px; color: #94a3b8; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: #cbd5e1; font-size: 13.5px; font-weight: 500;
}
.nav__item:hover { background: rgba(255, 255, 255, .06); }
.nav__item.is-active { background: var(--indigo); color: #fff; }
.sidebar__foot { margin-top: auto; font-size: 11px; color: #64748b; display: flex; flex-direction: column; gap: 8px; }
.content { padding: 26px 32px 60px; min-width: 0; }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar__actions { display: flex; gap: 8px; align-items: center; }
.back { font-size: 12.5px; color: var(--slate-500); display: inline-block; margin-bottom: 4px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--slate-300); background: #fff; color: var(--slate-700);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--slate-100); }
.btn--primary { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.btn--primary:hover { background: var(--indigo-dark); }
.btn--danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn--danger:hover { background: #fef2f2; }
.btn--sm { padding: 6px 10px; font-size: 12.5px; }
.btn--xs { padding: 3px 7px; font-size: 12px; line-height: 1; }

/* ---------- kpis ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi-box__label { font-size: 11.5px; color: var(--slate-500); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi-box__value { font-size: 20px; font-weight: 800; }
.kpi-box--green .kpi-box__value { color: var(--green); }
.kpi-box--amber .kpi-box__value { color: var(--amber); }

/* ---------- panels / cards ---------- */
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.panel__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; }
.panel__body { padding: 0 16px 16px; }
.panel__body--center { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 8px 16px 20px; }
.panel--total .panel__body { padding-top: 6px; }

.section-title { margin: 22px 0 10px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: block; color: inherit; }
.card:hover { box-shadow: 0 4px 14px rgba(15, 23, 42, .1); }
.card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card__kpi { margin: 10px 0 4px; }
.kpi__label { display: block; font-size: 11px; color: var(--slate-500); }
.kpi__value { font-size: 18px; font-weight: 800; }

/* ---------- badges / tags ---------- */
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge--ok { background: var(--green-bg); color: #15803d; }
.badge--pendente { background: var(--slate-100); color: var(--slate-500); }
.b-ativo { background: var(--green-bg); color: var(--green); }
.b-inativo { background: var(--slate-100); color: var(--slate-500); }
.tag { font-size: 10.5px; color: var(--slate-500); font-weight: 500; }
.alert-banner { background: var(--amber-bg); border: 1px solid var(--amber); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 13.5px; color: #92400e; }
.alert-banner ul { margin: 6px 0 0; padding-left: 20px; }
.alert-banner li { margin-bottom: 2px; }

/* ---------- tabs ---------- */
.tabs-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs-label { font-size: 12px; font-weight: 700; color: var(--slate-500); text-transform: uppercase; letter-spacing: .03em; }
.tabs-wrap .tabs { margin-bottom: 0; flex: 1; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--slate-300); }
.tab { background: none; border: none; padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--slate-500); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.is-active { color: var(--indigo); border-color: var(--indigo); }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 760px; }
.table th, .table td { padding: 7px 9px; text-align: right; border-bottom: 1px solid var(--slate-100); white-space: nowrap; }
.table th:first-child, .table td:first-child { text-align: left; white-space: normal; min-width: 160px; }
.table thead th { color: var(--slate-500); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .02em; }
.table .row-total td { font-weight: 700; background: var(--slate-50); border-top: 1px solid var(--slate-300); }
.table .row-grandtotal td { font-weight: 800; color: var(--indigo-dark); }
.table--totais { min-width: 700px; }
.row-inativa td { opacity: .55; }
.cell-lanc { cursor: pointer; border-radius: 4px; }
.cell-lanc:hover { outline: 2px solid var(--indigo); outline-offset: -2px; }
.cell-confirmado { background: var(--green-bg); color: #166534; }
.cell-previsto { background: var(--amber-bg); color: #92400e; }
.cell-total { font-weight: 700; }
.td-item { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.td-item__actions { display: inline-flex; gap: 2px; }
.td-item__actions .btn { padding: 1px 6px; font-size: 11px; }

/* ---------- fields / forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--slate-700); margin-bottom: 5px; }
.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--slate-300); border-radius: 8px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--slate-900);
}
.input:focus { outline: 2px solid var(--indigo); outline-offset: -1px; }
.input--sm { width: auto; padding: 7px 9px; font-size: 12.5px; }
.radio-group { display: flex; gap: 16px; }
.radio-group label { display: flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13px; }

/* ---------- sugestões de melhoria ---------- */
textarea.input { resize: vertical; font-family: inherit; }
.sugestao-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sugestao-item { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.sugestao-item p { margin: 0; white-space: pre-wrap; }
.sugestao-item__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }

/* ---------- chart legend ---------- */
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { display: block; max-width: 100%; height: auto; flex: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--slate-900); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 100; }
.modal.open { display: flex; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .5); }
.modal__box { position: relative; background: #fff; border-radius: 12px; width: 420px; max-width: calc(100vw - 32px); max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal__box.wide { width: 640px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--slate-100); }
.modal__x { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--slate-500); }
.modal__body { padding: 18px; }
.modal__foot { padding: 14px 18px; border-top: 1px solid var(--slate-100); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- relatório / impressão ---------- */
.rel-toolbar { display: flex; gap: 10px; align-items: center; padding: 16px 32px; }
/* 900px era largura de texto corrido; este documento carrega uma tabela de 14 colunas
   (rótulo + 12 meses + Total), então o limite subiu pra 1360px — com 900px os valores
   não cabiam e a tabela vazava do container (2026-10-01). 1360 - 64 de padding = 1296px
   de conteúdo, ou seja, acima do piso de 1280px da tabela: numa janela de 1440px não
   sobra barra de rolagem nem valor quebrado. */
.rel-doc { max-width: 1360px; margin: 0 auto; padding: 40px 32px 60px; }
.rel-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 14px; border-bottom: 2px solid var(--slate-900); margin-bottom: 20px; }
.rel-header__brand { display: flex; align-items: center; gap: 10px; }
.rel-header__mark { width: 34px; height: 34px; object-fit: contain; flex: none; }
.rel-header__brandtxt { display: flex; flex-direction: column; line-height: 1.3; }
.rel-header__brandtxt strong { font-size: 14px; }
.rel-header__brandtxt .muted { font-size: 11px; }
.rel-header__data { font-size: 11.5px; white-space: nowrap; }
.rel-titulo { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--slate-300); }
.rel-titulo h1 { margin-bottom: 2px; }
.rel-resumo { background: var(--indigo-50); border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.rel-secao { margin-top: 22px; }
/* 2026-10-01 (sugestão sgmuq0x51tjatx): `table-layout: fixed` e a largura da 1ª coluna
   viviam SÓ dentro do @media print — o PDF alinhava e a tela não, e é na tela que o
   cliente confere lançamento. Agora valem nos dois, junto com o colgroup compartilhado
   que o app.js emite nas 3 tabelas (ver COLGROUP_REL lá). `white-space: normal` é o par
   obrigatório do layout fixo: com o `nowrap` herdado de `.table`, uma célula apertada
   derramava o texto por cima da vizinha em vez de quebrar em duas linhas. */
/* piso de 1280px: medido em Chromium e Firefox, o maior valor plausível em negrito
   ("R$ 99.999,99") ocupa 75px e a coluna de mês fica com 1280 x 6,846% - 12 de padding
   = 75,6px de texto. Abaixo desse piso o container abaixo rola; nada quebra nem colide. */
.table--print { table-layout: fixed; width: 100%; min-width: 1280px; font-size: 11px; }
/* na tela: 11% no rótulo cabe "Valores totais agrupados" (133px medidos) em uma linha,
   e os 13 restantes (12 meses + Total) dividem os 89% em partes iguais */
.table--print col { width: 6.846%; }
.table--print col.col-rotulo { width: 11%; }
.table--print th, .table--print td { padding: 5px 6px; white-space: normal; overflow-wrap: break-word; }
/* um único container de rolagem por seção: as 3 tabelas rolam juntas e continuam
   alinhadas em tela estreita, e a PÁGINA deixa de rolar de lado (ela rolava já em
   1440px, arrastando cabeçalho e rodapé junto) */
.rel-tabelas { overflow-x: auto; }
.table--grand td { font-weight: 800; color: var(--indigo-dark); background: var(--indigo-50); }
.cell-previsto-print { color: var(--amber); font-style: italic; }
.rel-footer { margin-top: 30px; padding-top: 12px; border-top: 1px solid var(--slate-300); font-size: 11px; color: var(--slate-500); }

@media print {
  /* 2026-09-01: relatório tem 14 colunas (rótulo + 12 meses + total) — em retrato,
     o valor monetário formatado ("R$ X.XXX,XX") não cabia na largura da página e as
     últimas colunas (Dez/Total) saíam CORTADAS da impressão (reportado pelo cliente
     como "desalinhado e em 2 páginas"). Corrigido com paisagem (quase o dobro de
     largura útil) + table-layout:fixed (garante que a tabela nunca ultrapasse a
     largura da página, faz as colunas dividirem o espaço disponível em vez de
     crescer pro conteúdo). Espaçamento vertical também apertado só na impressão
     pra caber o relatório completo (com região) numa única página. */
  @page { size: A4 landscape; margin: 10mm 10mm; }
  .no-print, .sidebar { display: none !important; }
  body { background: #fff; }
  .rel-doc { max-width: none; padding: 0; margin: 0; }
  .rel-header { padding-top: 0; }
  /* 2026-10-01: `table-layout: fixed` e a largura da 1ª coluna saíram daqui pra regra
     geral (a tela precisava das duas); aqui sobrou só o que é específico do papel.
     `min-width: 0` desfaz o piso de 980px da tela — no papel quem limita é a página. */
  .table--print { page-break-inside: avoid; min-width: 0; font-size: 9.5px; }
  /* o papel volta ao `nowrap` de sempre: medido, a coluna Total tem 61,4px de espaço
     interno para um valor de 61px, e com quebra permitida os valores em negrito das
     linhas de total partiam no meio ("R$ 24.750,0" / "0"). Em nowrap eles invadem um
     pouco do padding e continuam inteiros dentro da célula — é o PDF que o cliente já
     aprovou, e esta sugestão é sobre a TELA, não sobre a impressão. */
  .table--print th, .table--print td { padding: 3px 4px; white-space: nowrap; }
  .table--print th:first-child, .table--print td:first-child { white-space: normal; }
  /* no papel a proporção é outra (página de ~1047px e fonte 9.5px): 14% no rótulo, que
     é o que o relatório já usava e cabe "Total Prestadores de Serviços" numa linha.
     Com 11% daqui a pouco "R$ 28.650,00" quebrava em duas linhas na coluna Total. */
  .table--print col { width: 6.615%; }
  .table--print col.col-rotulo { width: 14%; }
  .rel-tabelas { overflow: visible; }
  .rel-titulo { margin-bottom: 8px; padding-bottom: 6px; }
  .rel-resumo { padding: 6px 14px; }
  .rel-secao h3 { margin: 0 0 4px; }
  .rel-secao h4 { margin: 6px 0 2px; }
  .rel-secao { margin-top: 8px; page-break-inside: avoid; }
  .rel-footer { margin-top: 6px; padding-top: 5px; }
  .rel-footer p { margin: 2px 0; }
}

/* ---------- login ---------- */
.boot-loading { display: flex; align-items: center; justify-content: center; height: 100vh; color: var(--slate-500); font-size: 14px; }
.login-screen { display: flex; min-height: 100vh; }
.login-hero {
  flex: 1.15; display: flex; align-items: center; padding: 60px; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--slate-900) 100%);
  color: #fff;
}
.login-hero::before {
  content: ""; position: absolute; width: 460px; height: 460px; border-radius: 50%;
  background: rgba(255, 255, 255, .06); top: -140px; right: -140px;
}
.login-hero::after {
  content: ""; position: absolute; width: 300px; height: 300px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .12); bottom: -100px; left: -60px;
}
.login-hero__inner { position: relative; max-width: 440px; }
.login-hero__eyebrow { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #a7e0e0; margin-bottom: 14px; }
.login-hero h1 { font-size: 32px; line-height: 1.2; margin-bottom: 16px; }
.login-hero p { font-size: 14px; line-height: 1.6; color: rgba(255, 255, 255, .78); margin: 0; }
.login-panel { flex: 1; display: flex; align-items: center; justify-content: center; background: var(--slate-50); padding: 40px 24px; }
.login-card { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 36px 32px; width: 100%; max-width: 340px; }
.login-logo { display: block; height: 30px; width: auto; margin: 0 auto 22px; }
.login-title { text-align: center; margin-bottom: 2px; }
.login-sub { text-align: center; margin-bottom: 20px; }
.login-erro { color: var(--red); font-size: 12.5px; margin: -6px 0 14px; }
.login-btn { width: 100%; }

@media (max-width: 840px) {
  .login-hero { display: none; }
  .login-panel { background: var(--slate-900); }
  .login-card { box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
}

/* ---------- sidebar user/logout ---------- */
.sidebar__user { font-size: 12px; color: #cbd5e1; margin-bottom: 8px; }
.sidebar__logout { width: 100%; }

/* ---------- responsivo ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar__foot { margin-top: 0; display: flex; align-items: center; gap: 8px; }
  .sidebar__user { margin-bottom: 0; }
  .sidebar__logout { width: auto; }
  .content { padding: 18px; }
}

/* 2026-09-23 — composição das somas no lançamento (sugestão sgmu5um290eqkn):
   o valor digitado como "1176+500" guarda as parcelas pra conferência. */
.composicao-box { background: var(--slate-50, #f8fafc); border: 1px solid var(--line, #e2e8f0); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.composicao-box__tit { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted, #64748b); font-weight: 700; margin-bottom: 8px; }
.composicao-box__lista { list-style: none; margin: 0; padding: 0; }
.composicao-box__lista li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 13px; border-bottom: 1px dashed var(--line, #e2e8f0); }
.composicao-box__lista li span { color: var(--muted, #64748b); }
.composicao-box__total { display: flex; justify-content: space-between; gap: 12px; padding-top: 8px; font-size: 13.5px; font-weight: 700; }
.composicao-box code { background: #fff; border: 1px solid var(--line, #e2e8f0); border-radius: 5px; padding: 1px 5px; font-size: 12px; }
.cell-comp { display: inline-block; margin-left: 5px; font-size: 9.5px; font-weight: 700; color: var(--primary, #2c7a7d); vertical-align: super; letter-spacing: .02em; }
@media print { .cell-comp { display: none; } }
