/* ==========================================================================
   Sales Conecta — Painel (CRM, admin e área do cliente)
   ========================================================================== */

:root {
  --bg: #0b1120;
  --surface: #111a2e;
  --surface-2: #16213a;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e2e8f0;
  --text-strong: #ffffff;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  /* Paleta categórica de gráficos (versão validada p/ fundo escuro) */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: #a5b4fc; }
h1, h2, h3, h4 { font-family: 'Plus Jakarta Sans', 'Inter', sans-serif; color: var(--text-strong); line-height: 1.25; }
h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }
h3 { font-size: 0.95rem; margin-bottom: 0.5rem; }
small, .muted { color: var(--muted); }
code { background: var(--surface-2); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.85em; }

/* Layout ----------------------------------------------------------------- */
.panel { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: #080d19; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-logo { padding: 1.25rem 1.25rem 1rem; display: block; }
.sidebar-logo img { height: 32px; }
.sidebar nav { flex: 1; padding: 0 0.75rem; }
.nav-group { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: #64748b; padding: 1rem 0.5rem 0.4rem; font-weight: 700; }
.nav-link {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.04); }
.nav-link.active { background: rgba(99, 102, 241, 0.16); color: #fff; }
.nav-icon { width: 18px; text-align: center; opacity: 0.8; }
.sidebar-foot { padding: 0.75rem; border-top: 1px solid var(--border); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: 0.9rem 1.5rem; border-bottom: 1px solid var(--border);
  background: rgba(11, 17, 32, 0.9); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(8px);
}
.page-title { font-size: 1.15rem; flex: 1; }
.menu-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; }
.client-picker { display: flex; align-items: center; gap: 0.5rem; }
.client-picker label { color: var(--muted); font-size: 0.8rem; }
.client-picker select { min-width: 190px; }
.user-chip { display: flex; align-items: center; gap: 0.6rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #10b981);
  display: grid; place-items: center; font-weight: 700; color: #fff;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { font-size: 0.75rem; }
.content { padding: 1.5rem; max-width: 1400px; width: 100%; }

/* Componentes ------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.kpi-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.kpi-value { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1.6rem; font-weight: 800; color: #fff; margin-top: 0.25rem; }
.kpi-sub { font-size: 0.78rem; color: var(--muted); }
.chart-box { position: relative; height: 280px; }

.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.alert-success { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.35); color: #6ee7b7; }
.alert-error { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.35); color: #fca5a5; }
.alert-warning { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.35); color: #fcd34d; }
.alert-info { background: rgba(99, 102, 241, 0.1); border-color: rgba(99, 102, 241, 0.35); color: #c7d2fe; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.5rem 0.95rem;
  border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap; font-size: 0.85rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: #059669; color: #fff; }
.btn-danger { background: transparent; border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.12); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* Formulários */
input, select, textarea {
  font: inherit; color: var(--text); background: #0d1526; border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px; padding: 0.5rem 0.7rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(99, 102, 241, 0.6); border-color: transparent; }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 0.82rem; color: #cbd5e1; font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 0.3rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-stack { display: flex; flex-direction: column; gap: 0.9rem; }
.form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 0.5rem; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.4rem; }
.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters > * { width: auto; }
.filters input[type=search] { min-width: 220px; }
.hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }

/* Tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; white-space: nowrap; }
tr:hover td { background: rgba(255, 255, 255, 0.015); }
td .sub { display: block; font-size: 0.78rem; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 2rem; }

.tag { display: inline-block; padding: 0.12rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; border: 1px solid; }
.tag-neutral { color: #cbd5e1; border-color: rgba(203, 213, 225, 0.25); }
.tag-blue { color: #93c5fd; border-color: rgba(147, 197, 253, 0.35); }
.tag-purple { color: #c4b5fd; border-color: rgba(196, 181, 253, 0.35); }
.tag-green { color: #6ee7b7; border-color: rgba(110, 231, 183, 0.35); }
.tag-red { color: #fca5a5; border-color: rgba(252, 165, 165, 0.35); }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.score-high { color: #6ee7b7; } .score-mid { color: #fcd34d; } .score-low { color: #94a3b8; }

.pagination { display: flex; gap: 0.3rem; margin-top: 1rem; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 0.3rem 0.65rem; border-radius: 6px; border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.pagination a.active { background: var(--primary); border-color: var(--primary); }

/* Timeline */
.timeline { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.timeline li { border-left: 2px solid rgba(99, 102, 241, 0.4); padding-left: 0.85rem; }
.timeline .meta { font-size: 0.75rem; color: var(--muted); }

/* Pipeline (kanban) */
.kanban { display: flex; gap: 0.9rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.kanban-col { flex: 0 0 260px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.kanban-col.won { border-color: rgba(16, 185, 129, 0.4); }
.kanban-col.lost { border-color: rgba(239, 68, 68, 0.3); }
.kanban-head { padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--border); }
.kanban-head strong { color: #fff; }
.kanban-head small { display: block; }
.kanban-list { padding: 0.6rem; display: flex; flex-direction: column; gap: 0.5rem; overflow-y: auto; min-height: 80px; flex: 1; }
.kanban-list.drag-over { background: rgba(99, 102, 241, 0.08); }
.deal-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 0.65rem 0.75rem; cursor: grab; }
.deal-card:active { cursor: grabbing; }
.deal-card a { color: #fff; text-decoration: none; font-weight: 600; }
.deal-card .value { color: #6ee7b7; font-weight: 700; font-size: 0.85rem; }

/* Tarefas */
.task { display: grid; grid-template-columns: 1fr auto; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task-msg { background: #0d1526; border: 1px dashed rgba(255, 255, 255, 0.12); border-radius: 8px; padding: 0.6rem 0.75rem; margin-top: 0.5rem; white-space: pre-wrap; font-size: 0.85rem; }
.task-actions { display: flex; flex-direction: column; gap: 0.4rem; min-width: 170px; }

.steps { list-style: none; counter-reset: step; }
.steps > li { position: relative; padding: 0.9rem 0 0.9rem 2.6rem; border-bottom: 1px solid var(--border); }
.steps > li::before {
  counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0.9rem;
  width: 1.8rem; height: 1.8rem; border-radius: 50%; background: rgba(99, 102, 241, 0.2); color: #c7d2fe;
  display: grid; place-items: center; font-weight: 700; font-size: 0.8rem;
}
details summary { cursor: pointer; color: #a5b4fc; font-weight: 600; }
details[open] summary { margin-bottom: 0.75rem; }

.integration { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.integration h3 { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(circle at 20% 10%, rgba(99, 102, 241, 0.18), transparent 45%), radial-gradient(circle at 80% 90%, rgba(16, 185, 129, 0.12), transparent 45%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 2rem; }
.auth-logo img { height: 36px; margin-bottom: 1.25rem; }
.auth-card h1 { font-size: 1.35rem; margin-bottom: 1rem; }
.auth-card .muted { margin-bottom: 1rem; }
.auth-links { text-align: center; font-size: 0.85rem; }

/* Responsivo */
@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left 0.2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0, 0, 0, 0.6); }
  .menu-toggle { display: block; }
  .topbar { flex-wrap: wrap; padding: 0.75rem 1rem; }
  .user-meta { display: none; }
  .client-picker { order: 5; width: 100%; }
  .client-picker select { flex: 1; min-width: 0; }
  .content { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .task { grid-template-columns: 1fr; }
  .task-actions { flex-direction: row; flex-wrap: wrap; min-width: 0; }
}
.deal-card .stage-move { margin-top: 0.5rem; padding: 0.25rem 0.4rem; font-size: 0.75rem; background: transparent; }
