/* ============================================================
   ESTILO COMPARTILHADO — FinTracker
   ============================================================ */

:root {
  /* Identidade FinTracker: verde profundo (vida, estabilidade, confiança) como
     cor primária, dourado sóbrio como destaque raríssimo (só nos pontos de
     marca), verde secundário mais vivo pra valores positivos — um verde
     escuro de botão fica ilegível demais pra número pequeno de "entrada". */
  --navy: #202421;
  --navy-soft: #363B37;
  --primary: #18352F;
  --primary-soft: #E4ECE6;
  /* Variante clara do primary, só pra texto/ícone sobre fundo escuro (sidebar,
     barra mobile) — o primary normal quase some em cima do navy (contraste
     1.2:1); esse aqui garante leitura (6:1+). */
  --primary-on-dark: #4FB386;
  --sucesso: #2E7D52;
  --accent: #B5965A;
  --accent-soft: #F3EADA;
  --white: #FFFFFF;
  --stone: #66706B;
  --stone-soft: #E7EBE7;
  --bordeaux: #E86A6A;
  --bordeaux-soft: #FBEAEA;
  --warning: #F2C94C;
  --warning-soft: #FCF3D9;
  --bg: #F7F4EC;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  font-family: 'Inter', sans-serif;
  color: var(--navy);
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.glow {
  position: absolute;
  width: 560px; height: 560px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(32,36,34,0.06) 0%, rgba(32,36,34,0) 70%);
  top: -180px; right: -180px;
  pointer-events: none;
}

.card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border: 1px solid var(--stone-soft);
  border-radius: var(--radius);
  padding: 40px 32px 32px;
  position: relative;
  z-index: 1;
  box-shadow: 0 1px 2px rgba(32,36,34,0.04), 0 12px 32px -16px rgba(32,36,34,0.12);
  text-align: left;
}

.mark { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.mark .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; margin-right: 2px; }
.brand {
  font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 13px;
  letter-spacing: 0.08em; color: var(--stone); text-transform: uppercase;
}

h1 { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 27px; line-height: 1.25; margin: 18px 0 6px; color: var(--navy); }
.sub { color: var(--stone); font-size: 14px; margin: 0 0 28px; line-height: 1.5; }

label {
  display: block; font-size: 11px; font-weight: 600; color: var(--stone);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em;
}
.field { margin-bottom: 18px; }

input {
  width: 100%; background: var(--white); border: 1.5px solid var(--stone-soft); border-radius: 8px;
  padding: 12px 14px; color: var(--navy); font-size: 15px; font-family: 'Inter', sans-serif;
  transition: border-color 0.15s ease;
}
input:focus { outline: none; border-color: var(--primary); }
input::placeholder { color: #A9B3BC; }

button.submit, a.submit, .submit {
  width: 100%; background: var(--primary); color: var(--white); border: none; border-radius: 8px;
  padding: 13px 14px; font-size: 15px; font-weight: 600; font-family: 'Inter', sans-serif;
  cursor: pointer; margin-top: 8px; transition: filter 0.15s ease, transform 0.1s ease;
  display: inline-block; text-align: center; box-sizing: border-box;
}
.submit:hover { filter: brightness(1.15); }
.submit:active { transform: scale(0.99); }
.submit:disabled { opacity: 0.6; cursor: not-allowed; }

.msg { font-size: 13px; margin-top: 14px; padding: 10px 12px; border-radius: 6px; display: none; line-height: 1.5; }
.msg.error { display: block; background: var(--bordeaux-soft); color: var(--bordeaux); border: 1px solid rgba(232,106,106,0.18); }
.msg.info { display: block; background: var(--primary-soft); color: var(--primary); border: 1px solid rgba(24,53,47,0.25); }

.foot { margin-top: 26px; font-size: 12px; color: var(--stone); text-align: center; }

/* ============================================================
   MODAL (pop-up)
   ============================================================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(32,36,34,0.45); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-card { width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; background: var(--white); border-radius: var(--radius); padding: 28px 28px 24px; box-shadow: 0 24px 64px -24px rgba(32,36,34,0.35); text-align: left; }
.modal-card-wide { max-width: 560px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h2 { font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 20px; color: var(--navy); margin: 0; }
.modal-close { background: none; border: none; font-size: 22px; line-height: 1; color: var(--stone); cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--navy); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

select, textarea {
  width: 100%; background: var(--white); border: 1.5px solid var(--stone-soft); border-radius: 8px;
  padding: 12px 14px; color: var(--navy); font-size: 15px; font-family: 'Inter', sans-serif;
  transition: border-color 0.15s ease;
}
select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; }

.link-voltar {
  background: none; border: none; color: var(--stone); font-size: 13px; cursor: pointer;
  padding: 0; margin-bottom: 16px; display: inline-flex; align-items: center; gap: 4px; font-family: 'Inter', sans-serif;
}
.link-voltar:hover { color: var(--navy); }

/* ============================================================
   APP SHELL — SIDEBAR (com suporte a colapsar)
   ============================================================ */
body.app-body { display: block; padding: 0; overflow: visible; align-items: initial; justify-content: initial; }
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0; background: var(--navy); color: var(--white);
  display: flex; flex-direction: column; padding: 28px 20px;
  position: sticky; top: 0; height: 100vh;
  transition: width 0.18s ease, padding 0.18s ease;
  overflow: hidden;
}
.sidebar.colapsada { width: 76px; padding-left: 16px; padding-right: 16px; }

.sidebar-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 28px; flex-shrink: 0; }
.sidebar-brand .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.sidebar-brand-text { font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: rgba(255,255,255,0.85); white-space: nowrap; }
.sidebar.colapsada .sidebar-brand-text { display: none; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow-y: auto; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 8px;
  color: rgba(255,255,255,0.65); text-decoration: none; font-size: 14px; font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease; white-space: nowrap;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.sidebar-link.active { background: rgba(79,179,134,0.15); color: var(--primary-on-dark); font-weight: 600; }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; display: block; }
.sidebar.colapsada .sidebar-link { justify-content: center; padding: 11px; }
.sidebar.colapsada .sidebar-link-texto { display: none; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.12); padding-top: 16px; margin-top: 16px; flex-shrink: 0; }
.sidebar-user { font-size: 13px; color: rgba(255,255,255,0.75); margin-bottom: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.colapsada .sidebar-user { display: none; }

.sidebar-logout {
  width: 100%; background: transparent; border: 1.5px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.75);
  border-radius: 8px; padding: 9px 12px; font-size: 13px; font-family: 'Inter', sans-serif; cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease; display: flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
}
.sidebar-logout:hover { border-color: var(--primary-on-dark); color: var(--primary-on-dark); }
.sidebar-logout svg { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; display: block; }
.sidebar.colapsada .sidebar-logout-texto { display: none; }

.sidebar-toggle {
  margin-left: auto; width: 28px; height: 28px; flex-shrink: 0; background: transparent;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; color: rgba(255,255,255,0.6);
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.sidebar-toggle:hover { color: var(--primary-on-dark); border-color: var(--primary-on-dark); }
.sidebar-toggle svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; display: block; transition: transform 0.18s ease; }
.sidebar.colapsada .sidebar-toggle svg { transform: rotate(180deg); }

.main-content { flex: 1; padding: 40px; min-width: 0; }
.page-header { margin-bottom: 28px; }
.page-header h1 { margin: 0 0 4px; }

/* ============================================================
   TABELA DE DADOS
   ============================================================ */
.filtro-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.filtro-bar label { margin-bottom: 0; white-space: nowrap; }
.filtro-bar select { max-width: 280px; }

.data-table-wrapper { background: var(--white); border: 1px solid var(--stone-soft); border-radius: var(--radius); overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th {
  text-align: left; font-family: 'Manrope', sans-serif; font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--stone); padding: 14px 16px;
  border-bottom: 1px solid var(--stone-soft); white-space: nowrap;
}
table.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--stone-soft); color: var(--navy); white-space: nowrap; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--bg); }

.th-ordenavel { cursor: pointer; user-select: none; }
.th-ordenavel:hover { color: var(--navy); }
.seta-ordenar { display: inline-block; width: 10px; }

.tabela-vazio { text-align: center; color: var(--stone); padding: 40px !important; white-space: normal !important; }

/* ============================================================
   CARDS DE KPI
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-card { background: var(--white); border: 1px solid var(--stone-soft); border-radius: var(--radius); padding: 20px; }
.kpi-card .kpi-label { font-family: 'Manrope', sans-serif; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--stone); margin-bottom: 8px; }
.kpi-card .kpi-valor { font-family: 'Manrope', sans-serif; font-size: 24px; font-weight: 700; color: var(--navy); }

/* ============================================================
   GRÁFICO DE FUNIL
   ============================================================ */
.chart-card { background: var(--white); border: 1px solid var(--stone-soft); border-radius: var(--radius); padding: 28px 32px; margin-top: 4px; }
.chart-card-title { font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 16px; color: var(--navy); margin: 0 0 20px; }
.funil-etapa { margin-bottom: 18px; }
.linha-clicavel { cursor: pointer; border-radius: 8px; transition: background 0.15s ease; }
.linha-clicavel:hover { background: var(--bg); }
.funil-etapa:last-child { margin-bottom: 0; }
.funil-etapa-header { display: flex; justify-content: space-between; font-size: 14px; color: var(--navy); margin-bottom: 6px; }
.funil-etapa-header small { color: var(--stone); font-weight: 500; }
.funil-barra-bg { background: var(--stone-soft); border-radius: 6px; height: 10px; overflow: hidden; }
.funil-barra { height: 100%; background: linear-gradient(90deg, var(--navy), var(--sucesso)); border-radius: 6px; transition: width 0.3s ease; }

/* ============================================================
   TABELAS ORDENÁVEIS + BOTÃO DE AMPLIAR
   ============================================================ */
.chart-card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.chart-card-header-row .chart-card-title { margin-bottom: 0; }
.btn-ampliar {
  background: none; border: 1px solid var(--stone-soft); border-radius: 6px; padding: 6px 12px; font-size: 12px;
  color: var(--stone); cursor: pointer; display: flex; align-items: center; gap: 4px; white-space: nowrap; font-family: 'Inter', sans-serif;
}
.btn-ampliar:hover { border-color: var(--primary); color: var(--navy); }
.fin-cell-clicavel { cursor: pointer; transition: background 0.15s ease; }
.fin-cell-clicavel:hover { background: var(--bg); text-decoration: underline; }
.link-voltar-geral { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--stone); text-decoration: none; margin-bottom: 16px; }
.link-voltar-geral:hover { color: var(--navy); }

.fin-dev-banner {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--warning); color: var(--navy);
  text-align: center; font: 600 12px/1.4 'Inter', sans-serif; padding: 8px; z-index: 99999;
}
