:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-alt: #faf9f6;
  --border: #e5e1d8;
  --text: #292520;
  --text-muted: #837b6d;
  --accent: #3ba6f1;
  --accent-dark: #2586cc;
  --success: #4caf7d;
  --warning: #e0a83e;
  --danger: #d9534f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(41, 37, 32, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  padding: 0 8px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.brand-name {
  font-weight: 600;
  font-size: 16px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-item:hover {
  background: var(--surface-alt);
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
}

/* Content */
.content {
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
}

.view.hidden { display: none; }

.view-header { margin-bottom: 24px; }
.view-header h1 { margin: 0 0 4px; font-size: 24px; }
.subtitle { margin: 0; color: var(--text-muted); font-size: 14px; }

/* Cards grid (dashboard) */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-dark);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

/* Funil grid */
.funil-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.funil-item {
  text-align: center;
  padding: 14px 8px;
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.funil-item .count { font-size: 22px; font-weight: 700; }
.funil-item .label { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }

/* Filtros */
.filtros {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.filtros input[type="text"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

.checkbox-inline {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  overflow-x: auto;
}

.kanban-col {
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
}

.kanban-col h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.lead-card:hover { box-shadow: var(--shadow); }

.lead-card .nome { font-weight: 600; font-size: 13px; }
.lead-card .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.score-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 6px;
}

.score-alto { background: #e5f6ec; color: var(--success); }
.score-medio { background: #fdf3e0; color: var(--warning); }
.score-baixo { background: #f4f2ee; color: var(--text-muted); }

/* Forms */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 480px;
  margin-bottom: 20px;
}

.form-row { margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.form-row input, .form-row select, .form-row textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}

.btn {
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.resultado-importacao {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
}

.resultado-importacao.ok { background: #e5f6ec; color: #2d6b48; }
.resultado-importacao.erro { background: #fbe9e8; color: #a33330; }
.resultado-importacao.hidden { display: none; }

/* Templates grid */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.template-card .canal-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-alt);
  color: var(--text-muted);
  margin-bottom: 8px;
}

.template-card h3 { margin: 0 0 8px; font-size: 15px; }
.template-card p { font-size: 13px; color: var(--text-muted); white-space: pre-wrap; }

.template-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(41, 37, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
}

.lead-detail h2 { margin: 0 0 4px; }
.lead-detail .meta-line { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; }

.lead-detail .info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 18px;
}

.lead-detail .info-grid div span { color: var(--text-muted); display: block; font-size: 11px; }

.interacoes-list {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
}

.interacao-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.interacao-item .tipo-tag {
  font-weight: 700;
  text-transform: capitalize;
  color: var(--accent-dark);
}

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; display: flex; align-items: center; }
  .nav { flex-direction: row; }
  .kanban { grid-template-columns: 1fr; }
  .content { padding: 20px; }
}
