/* ═══════════════════════════════════════════════════════════
   MartINC CRM — painel interno de assessores
   Reaproveita a identidade do site (navy/dourado/Fraunces)
   em um layout funcional de dashboard.
   ═══════════════════════════════════════════════════════════ */

:root {
  --paper:   #F5F7FA;
  --card:    #FFFFFF;
  --navy:    #0E223F;
  --navy-2:  #16345A;
  --ink:     #14243F;
  --muted:   #5A6A85;
  --faint:   #8A96AA;
  --gold:    #B08D57;
  --gold-2:  #C6A96C;
  --hair:    #E2E8F1;
  --hair-2:  #EDF1F6;
  --danger:  #B3432E;
  --danger-bg: #FBEAE6;
  --ok:      #2F7A4F;
  --ok-bg:   #E9F5EE;
  --warn:    #9A7215;
  --warn-bg: #FBF3DE;
  --info:    #2E5F94;
  --info-bg: #EAF1FA;
  --font-h:  'Fraunces', Georgia, serif;
  --font-b:  'Inter', sans-serif;
  --radius:  10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-b);
  font-size: 14.5px;
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; }

.hidden { display: none !important; }

/* ════════ LOGIN ════════ */
#loginScreen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--navy);
  background-image: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(198,169,108,.12), transparent 60%);
  padding: 24px;
}
.login-card {
  background: var(--card); border-radius: 14px; padding: 44px 40px;
  width: 100%; max-width: 380px;
  box-shadow: 0 30px 70px rgba(0,0,0,.35);
}
.login-card img { height: 44px; margin: 0 auto 28px; mix-blend-mode: multiply; }
.login-card h1 {
  font-family: var(--font-h); font-size: 1.3rem; font-weight: 600; color: var(--navy);
  text-align: center; margin-bottom: 4px;
}
.login-card .sub { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 28px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field input, .field select, .field textarea {
  border: 1px solid var(--hair); border-radius: 8px; padding: 11px 14px;
  font-size: .92rem; color: var(--ink); background: var(--paper);
  transition: border-color .2s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold); background: #fff; }
.field textarea { resize: vertical; min-height: 70px; }
.login-error {
  background: var(--danger-bg); color: var(--danger); font-size: .84rem;
  border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; display: none;
}
.login-error.show { display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 8px; font-weight: 600; font-size: .88rem;
  padding: 11px 20px; transition: transform .15s, box-shadow .15s, background .15s;
}
.btn-primary { background: var(--navy); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--navy-2); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-2); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--hair); }
.btn-ghost:hover { background: var(--hair-2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #F5D9D2; }
.btn-sm { padding: 7px 13px; font-size: .8rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ════════ APP SHELL ════════ */
#app { min-height: 100vh; display: none; }
#app.active { display: flex; flex-direction: column; }

#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--card); border-bottom: 1px solid var(--hair);
  position: sticky; top: 0; z-index: 20;
}
.tb-left { display: flex; align-items: center; gap: 14px; }
.tb-left img { height: 34px; mix-blend-mode: multiply; }
.tb-tabs { display: flex; gap: 4px; margin-left: 18px; }
.tb-tab {
  background: transparent; border: none; padding: 9px 16px; border-radius: 7px;
  font-size: .86rem; font-weight: 600; color: var(--muted);
}
.tb-tab.active { background: var(--navy); color: #fff; }
.tb-right { display: flex; align-items: center; gap: 14px; }
.tb-user { text-align: right; }
.tb-user b { display: block; font-size: .86rem; color: var(--ink); }
.role-badge {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: 2px 9px; border-radius: 100px; margin-top: 2px;
}
.role-badge.admin { background: var(--gold); color: #fff; }
.role-badge.assessor { background: var(--info-bg); color: var(--info); }

main { flex: 1; padding: 28px; max-width: 1360px; width: 100%; margin: 0 auto; }

/* ════════ KPIs ════════ */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--card); border: 1px solid var(--hair); border-radius: var(--radius); padding: 20px 22px; }
.kpi b { font-family: var(--font-h); font-size: 1.7rem; font-weight: 600; color: var(--navy); display: block; }
.kpi span { font-size: .78rem; color: var(--muted); }

/* ════════ FILTROS ════════ */
.panel { background: var(--card); border: 1px solid var(--hair); border-radius: var(--radius); margin-bottom: 18px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--hair-2);
}
.panel-head h2 { font-family: var(--font-h); font-size: 1.05rem; font-weight: 600; color: var(--navy); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 22px; }
.filters .field { margin-bottom: 0; min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 200px; }
.filters input, .filters select { padding: 9px 12px; font-size: .85rem; }

/* ════════ TABELA ════════ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.data th {
  text-align: left; padding: 12px 22px; font-size: .72rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--faint);
  border-bottom: 1px solid var(--hair); white-space: nowrap;
}
table.data td { padding: 14px 22px; border-bottom: 1px solid var(--hair-2); vertical-align: middle; }
table.data tbody tr:hover { background: var(--hair-2); }
table.data .cli-nome { font-weight: 600; color: var(--ink); }
table.data .cli-sub { font-size: .78rem; color: var(--faint); }
.row-actions { display: flex; gap: 6px; }

.badge { display: inline-block; font-size: .74rem; font-weight: 700; padding: 4px 11px; border-radius: 100px; white-space: nowrap; }
.badge.lead { background: var(--warn-bg); color: var(--warn); }
.badge.em_analise { background: var(--info-bg); color: var(--info); }
.badge.ativo { background: var(--ok-bg); color: var(--ok); }
.badge.inativo { background: var(--hair-2); color: var(--faint); }

.empty-state { padding: 60px 24px; text-align: center; color: var(--faint); }
.empty-state svg { width: 40px; height: 40px; stroke: var(--faint); fill: none; stroke-width: 1.5; margin-bottom: 12px; }

/* ════════ MODAL ════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(14,34,63,.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 40px 90px rgba(0,0,0,.35);
}
.modal.modal-xl { max-width: 900px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 26px; border-bottom: 1px solid var(--hair-2);
}
.modal-head h3 { font-family: var(--font-h); font-size: 1.15rem; font-weight: 600; color: var(--navy); }
.modal-close { background: none; border: none; font-size: 1.3rem; color: var(--faint); line-height: 1; padding: 4px; }
.modal-body { padding: 22px 26px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 26px; border-top: 1px solid var(--hair-2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; margin-bottom: 18px; }
.detail-item span { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); margin-bottom: 3px; }
.detail-item b { font-size: .92rem; color: var(--ink); font-weight: 500; }
.detail-full { grid-column: 1 / -1; }

.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: var(--navy); color: #fff; padding: 13px 20px; border-radius: 9px;
  font-size: .86rem; box-shadow: 0 14px 34px rgba(0,0,0,.3);
  opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); }

/* ════════ FORMULÁRIO FP CLIENT (seções A–N) ════════ */
.fp-section { padding: 18px 0; border-bottom: 1px solid var(--hair-2); }
.fp-section:first-child { padding-top: 0; }
.fp-section:last-child { border-bottom: none; }
.fp-section h4 { font-family: var(--font-h); font-size: .92rem; font-weight: 600; color: var(--navy); margin-bottom: 12px; }
.fp-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.fp-section-head h4 { margin-bottom: 0; }
.fp-rows { display: flex; flex-direction: column; gap: 8px; }
.fp-row { display: grid; gap: 8px; align-items: center; }
.fp-row input, .fp-row select { border: 1px solid var(--hair); border-radius: 6px; padding: 8px 10px; font-size: .82rem; width: 100%; background: #fff; }
.fp-row-remove {
  background: var(--danger-bg); color: var(--danger); border: none; border-radius: 6px;
  width: 30px; height: 30px; font-size: 1rem; line-height: 1; justify-self: center;
}
.fp-empty { color: var(--faint); font-size: .84rem; font-style: italic; margin: 0; }
.fp-total {
  text-align: right; font-size: .86rem; font-weight: 700; color: var(--navy);
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--hair);
}
.fp-total:empty { display: none; }
.fp-checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; }
.fp-check { display: flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--ink); }
.fp-solucoes { display: flex; flex-direction: column; gap: 6px; }
.fp-sol-head, .fp-sol-row { display: grid; grid-template-columns: 1.7fr .75fr .75fr 1.4fr; gap: 8px; align-items: center; }
.fp-sol-head span { font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.fp-sol-row span { font-size: .84rem; color: var(--ink); }
.fp-sol-row select, .fp-sol-row input { border: 1px solid var(--hair); border-radius: 6px; padding: 7px 9px; font-size: .8rem; width: 100%; }
.field input:disabled, .field select:disabled, .field textarea:disabled,
.fp-row input:disabled, .fp-row select:disabled,
.fp-sol-row input:disabled, .fp-sol-row select:disabled,
.fp-check input:disabled {
  background: var(--hair-2); color: var(--muted); cursor: default; opacity: 1;
}

@media (max-width: 720px) {
  .fp-checks { grid-template-columns: 1fr; }
  .fp-sol-head { display: none; }
  .fp-sol-row { grid-template-columns: 1fr 1fr; }
  .fp-sol-row span { grid-column: 1 / -1; font-weight: 600; }
  .fp-row { grid-template-columns: 1fr !important; }
}

@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .form-row, .detail-grid { grid-template-columns: 1fr; }
  #topbar { flex-wrap: wrap; gap: 10px; }
  .tb-tabs { margin-left: 0; }
  main { padding: 16px; }
}
