*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-h: #4f46e5;
  --radius: 8px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.header h1 { font-size: 18px; font-weight: 700; }
.header .subtitle { color: var(--muted); font-size: 13px; }

.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

/* Filtros */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.filters input, .filters select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}
.filters input:focus, .filters select:focus { border-color: var(--accent); }
.filters input[type="search"] { flex: 1; min-width: 220px; }

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text); opacity: 1; }

/* Tabela */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg3); }
th { padding: 10px 14px; text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
td { padding: 10px 14px; border-top: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: rgba(255,255,255,.03); }

.truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Badge de status */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

/* Paginação */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination .active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* Stats */
.stats { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }

.stat-divider {
  width: 1px;
  background: var(--border);
  margin: 0 4px;
  align-self: stretch;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 110px;
  text-decoration: none;
  position: relative;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.stat-card:hover { border-color: var(--card-color, var(--accent)); text-decoration: none; }
.stat-card .val { font-size: 22px; font-weight: 700; color: var(--card-color, var(--text)); }
.stat-card .lbl { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat-card.stat-active {
  border-color: var(--card-color, var(--accent));
  background: color-mix(in srgb, var(--card-color, var(--accent)) 12%, var(--bg2));
}
.stat-x {
  position: absolute; top: 6px; right: 8px;
  font-size: 10px; color: var(--muted);
}

/* Detalhe do lead */
.lead-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.field-group { margin-bottom: 4px; }
.field-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.field-value { word-break: break-word; white-space: pre-wrap; }
.field-value a { color: var(--accent); }

/* Select inline */
select.status-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 4px 8px;
  font-size: 13px;
}

textarea.notes {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px;
  font-size: 14px;
  resize: vertical;
  min-height: 100px;
  margin-top: 6px;
}
textarea.notes:focus { outline: none; border-color: var(--accent); }

.back-link { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 4px; margin-bottom: 16px; }
.back-link:hover { color: var(--text); text-decoration: none; }

.tag { display: inline-block; background: var(--bg3); padding: 2px 8px; border-radius: 4px; font-size: 12px; margin: 2px 2px 0 0; }

/* Checkboxes */
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

code { background: var(--bg3); border-radius: 4px; padding: 1px 5px; font-size: 11px; color: #a5b4fc; }

/* Modal overlay */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 17px; }
.modal-body { overflow-y: auto; flex: 1; padding: 0 24px; }
.modal-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 10px;
}

/* Seções do modal */
.modal-section { padding: 18px 0; border-bottom: 1px solid var(--border); }
.modal-section:last-child { border-bottom: none; }
.modal-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 12px; }

.modal-row { display: flex; align-items: center; gap: 8px; }
.modal-input {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  padding: 8px 12px; font-size: 14px; width: 100%;
}
.modal-input:focus { outline: none; border-color: var(--accent); }

.modal-textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  padding: 10px; font-size: 14px; resize: vertical; min-height: 100px;
}
.modal-textarea:focus { outline: none; border-color: var(--accent); }

select.modal-input, .modal-section select {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  padding: 8px 12px; font-size: 14px;
}
.modal-vars { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* Arquivo */
.radio-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.radio-label input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; }

.file-label { cursor: pointer; }
.file-status { font-size: 12px; margin-left: 8px; }

.setor-upload-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.setor-upload-row:last-child { border-bottom: none; }
.setor-name { flex: 1; font-size: 13px; min-width: 140px; }

@media (max-width: 640px) {
  .container { padding: 12px; }
  .filters { flex-direction: column; }
}
