/* ============================================================
   Vilareal Cérebro — estilo
   Base no design-guide FAVA: minimalista, preto + roxo + branco,
   sem serifa, bordas finas, radius baixo, sombras mínimas.
   Mesmo DNA do ATS (vilareal-talentos) — sistemas irmãos.
   ============================================================ */
:root {
  --roxo: #6B2ED6;
  --roxo-claro: #8A57E6;
  --roxo-bg: #F3EEFC;
  --preto: #0D0D0D;
  --branco: #FFFFFF;
  --cinza-1: #F6F6F7;
  --cinza-2: #ECECEE;
  --cinza-3: #D9D9DE;
  --cinza-txt: #6B6B72;
  --verde: #1E9E5A;
  --verde-bg: #E7F6EE;
  --vermelho: #C0392B;
  --vermelho-bg: #FDECEA;
  --amarelo: #C99A0C;
  --amarelo-bg: #FBF3DD;
  --azul: #2D6CDF;
  --shadow: 0 1px 2px rgba(13,13,13,.06);
  --r: 6px;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--preto);
  background: var(--cinza-1);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--preto);
  color: #fff;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  padding: 22px 0;
  z-index: 20;
}
.brand {
  padding: 0 22px 22px;
  display: flex;
  align-items: baseline;
  gap: 2px;
  border-bottom: 1px solid #232323;
  margin-bottom: 14px;
}
.brand .b1 { font-weight: 800; font-size: 19px; letter-spacing: -.5px; }
.brand .dot { width: 6px; height: 6px; background: var(--roxo-claro); border-radius: 50%; transform: translateY(-2px); margin-left: 2px; }
.brand small { display: block; width: 100%; font-size: 10px; letter-spacing: 3px; color: #8a8a8a; text-transform: uppercase; margin-top: 4px; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.nav button {
  display: flex; align-items: center; gap: 11px;
  background: none; border: 0; color: #c7c7cc;
  padding: 10px 12px; border-radius: var(--r); text-align: left;
  font-size: 14px; width: 100%; transition: .12s;
}
.nav button .ico { width: 18px; text-align: center; opacity: .9; font-size: 15px; }
.nav button:hover { background: #1d1d1d; color: #fff; }
.nav button.active { background: var(--roxo); color: #fff; }

.sidebar-foot { margin-top: auto; padding: 14px 18px 0; border-top: 1px solid #232323; }
.sidebar-foot button { background: none; border: 0; color: #8a8a8a; font-size: 12px; padding: 6px 0; display: block; }
.sidebar-foot button:hover { color: #fff; }
.sidebar-foot .status { font-size: 11px; color: #6b6b72; margin-bottom: 8px; }
.sidebar-foot .status b { color: var(--amarelo); }
.sidebar-foot .byline { font-size: 10px; color: #5a5a5f; letter-spacing: .5px; margin-top: 12px; }
.sidebar-foot .byline b { color: #8a8a8a; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--cinza-3);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.topbar .sub { font-size: 12px; color: var(--cinza-txt); margin-top: 1px; }

.content { padding: 26px 28px 60px; flex: 1; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--roxo); color: #fff; border: 0;
  padding: 9px 15px; border-radius: var(--r); font-size: 13px; font-weight: 600;
  transition: .12s; text-decoration: none;
}
.btn:hover { background: var(--roxo-claro); }
.btn.ghost { background: #fff; color: var(--preto); border: 1px solid var(--cinza-3); }
.btn.ghost:hover { background: var(--cinza-2); }
.btn.danger { background: #fff; color: var(--vermelho); border: 1px solid var(--cinza-3); }
.btn.danger:hover { background: var(--vermelho-bg); }
.btn.sm { padding: 6px 10px; font-size: 12px; }

/* ---------- Cards / KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.kpi {
  background: #fff; border: 1px solid var(--cinza-3); border-radius: var(--r);
  padding: 18px 18px 16px; box-shadow: var(--shadow);
}
.kpi .label { font-size: 12px; color: var(--cinza-txt); text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 28px; font-weight: 800; letter-spacing: -1px; margin-top: 6px; line-height: 1; }
.kpi .value small { font-size: 14px; font-weight: 600; color: var(--cinza-txt); }
.kpi .value .cur { font-size: 15px; font-weight: 700; color: var(--cinza-txt); margin-right: 2px; }
.kpi .foot { font-size: 12px; color: var(--cinza-txt); margin-top: 8px; }
.kpi.accent { border-left: 3px solid var(--roxo); }
.kpi.pos .value { color: var(--verde); }
.kpi.neg .value { color: var(--vermelho); }

.panel { background: #fff; border: 1px solid var(--cinza-3); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 22px; }
.panel-head { padding: 16px 18px; border-bottom: 1px solid var(--cinza-3); display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { font-size: 15px; font-weight: 700; }
.panel-body { padding: 18px; }

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--cinza-txt); margin: 4px 0 12px; }

/* ---------- Barras (funil / por cliente) ---------- */
.funil { display: flex; flex-direction: column; gap: 10px; }
.funil-row { display: grid; grid-template-columns: 130px 1fr 70px; align-items: center; gap: 12px; }
.funil-row .nm { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funil-bar { height: 26px; background: var(--cinza-1); border-radius: 4px; overflow: hidden; }
.funil-bar > span { display: block; height: 100%; background: var(--roxo); border-radius: 4px; transition: width .4s; min-width: 2px; }
.funil-row .qt { font-size: 13px; font-weight: 700; text-align: right; }

/* ---------- Gráfico de barras (6 meses) ---------- */
.chart { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding: 8px 4px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 100%; width: 100%; justify-content: center; }
.chart-bars .b { width: 16px; border-radius: 3px 3px 0 0; min-height: 2px; transition: height .4s; }
.chart-bars .b.ent { background: var(--verde); }
.chart-bars .b.sai { background: var(--cinza-3); }
.chart-col .lbl { font-size: 11px; color: var(--cinza-txt); text-transform: capitalize; }
.chart-legend { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--cinza-txt); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ---------- Tabelas ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px; background: #fff;
  border: 1px solid var(--cinza-3); border-radius: var(--r); padding: 8px 12px; min-width: 240px;
}
.search input { border: 0; outline: 0; width: 100%; background: none; }
.select { padding: 8px 12px; border: 1px solid var(--cinza-3); border-radius: var(--r); background: #fff; }

table { width: 100%; border-collapse: collapse; background: #fff; }
.table-wrap { background: #fff; border: 1px solid var(--cinza-3); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--cinza-txt); padding: 12px 16px; border-bottom: 1px solid var(--cinza-3); font-weight: 700; }
td { padding: 13px 16px; border-bottom: 1px solid var(--cinza-1); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable:hover { background: var(--cinza-1); cursor: pointer; }
td .nome { font-weight: 600; }
td .muted { color: var(--cinza-txt); font-size: 12.5px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.val-pos { color: var(--verde); font-weight: 700; }
.val-neg { color: var(--vermelho); font-weight: 700; }
tfoot td { font-weight: 800; border-top: 2px solid var(--cinza-3); background: var(--cinza-1); }

/* ---------- Badges / tags ---------- */
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; letter-spacing: .2px; }
.badge.ok    { background: var(--verde-bg); color: var(--verde); }
.badge.warn  { background: var(--amarelo-bg); color: var(--amarelo); }
.badge.off   { background: var(--cinza-2); color: var(--cinza-txt); }
.badge.bad   { background: var(--vermelho-bg); color: var(--vermelho); }
.badge.dot::before { content: '●'; font-size: 8px; vertical-align: 1px; margin-right: 5px; }
.tag { display: inline-block; background: var(--roxo-bg); color: var(--roxo); font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 4px; margin: 0 4px 4px 0; }
.tag.gray { background: var(--cinza-2); color: var(--cinza-txt); }
.pill { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; }
.col {
  flex: 0 0 256px; background: var(--cinza-1); border: 1px solid var(--cinza-3);
  border-radius: var(--r); display: flex; flex-direction: column; max-height: calc(100vh - 220px);
}
.col-head { padding: 11px 13px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--cinza-3); position: sticky; top: 0; }
.col-head .ct { font-size: 13px; font-weight: 700; }
.col-head .qt { font-size: 11px; font-weight: 700; color: var(--cinza-txt); }
.col-head .tot { font-size: 11px; font-weight: 700; color: var(--roxo); display: block; }
.col[data-etapa="Fechado"] .col-head { border-bottom-color: var(--verde); }
.col[data-etapa="Fechado"] .col-head .tot { color: var(--verde); }
.col[data-etapa="Perdido"] { opacity: .8; }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; min-height: 60px; flex: 1; }
.col-body.dragover { background: var(--roxo-bg); outline: 2px dashed var(--roxo); outline-offset: -4px; }

.card-lead {
  background: #fff; border: 1px solid var(--cinza-3); border-radius: var(--r);
  padding: 11px 12px; box-shadow: var(--shadow); cursor: grab; transition: .1s;
}
.card-lead:hover { border-color: var(--roxo); }
.card-lead.dragging { opacity: .45; }
.card-lead .cn { font-weight: 700; font-size: 13.5px; }
.card-lead .ch { font-size: 12px; color: var(--cinza-txt); margin-top: 1px; }
.card-lead .meta { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; }
.card-lead .vl { font-size: 13px; font-weight: 800; color: var(--roxo); }
.card-lead .src { font-size: 10px; color: var(--cinza-txt); text-transform: uppercase; letter-spacing: .4px; }

/* avatar */
.av { width: 30px; height: 30px; border-radius: 50%; background: var(--roxo); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.av.lg { width: 46px; height: 46px; font-size: 17px; }
.cell-person { display: flex; align-items: center; gap: 10px; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--cinza-txt); }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .35; }
.empty p { margin-bottom: 16px; }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(13,13,13,.45); display: none; align-items: flex-start; justify-content: center; z-index: 50; padding: 40px 16px; overflow-y: auto; }
.overlay.open { display: flex; }
.modal { background: #fff; border-radius: 8px; width: 100%; max-width: 560px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal.wide { max-width: 720px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--cinza-3); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-head .x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--cinza-txt); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--cinza-3); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--cinza-txt); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--cinza-3); border-radius: var(--r); outline: 0; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--roxo); }
.field textarea { min-height: 70px; resize: vertical; }
.field .hint { font-size: 11px; color: var(--cinza-txt); margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* seletor de tipo (entrada/saída) */
.tipo-toggle { display: flex; gap: 10px; margin-bottom: 16px; }
.tipo-toggle button { flex: 1; padding: 12px; border: 1px solid var(--cinza-3); background: #fff; border-radius: var(--r); font-weight: 700; font-size: 13px; color: var(--cinza-txt); }
.tipo-toggle button.on-ent { border-color: var(--verde); background: var(--verde-bg); color: var(--verde); }
.tipo-toggle button.on-sai { border-color: var(--vermelho); background: var(--vermelho-bg); color: var(--vermelho); }

/* detalhe */
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.detail-head .cn { font-size: 18px; font-weight: 800; }
.detail-head .ch { font-size: 13px; color: var(--cinza-txt); }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 13.5px; margin-bottom: 6px; }
.dl dt { color: var(--cinza-txt); font-weight: 600; }
.hist { list-style: none; border-left: 2px solid var(--cinza-3); margin-left: 6px; padding-left: 16px; }
.hist li { position: relative; padding: 5px 0; font-size: 13px; }
.hist li::before { content: ''; position: absolute; left: -22px; top: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--roxo); border: 2px solid #fff; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--preto); color: #fff; padding: 11px 18px; border-radius: var(--r);
  font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* ---------- Dashboard 2 colunas ---------- */
.row2-dash { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 22px; }

@media (max-width: 720px) {
  .row2-dash { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .row2, .row3 { grid-template-columns: 1fr; }
}
