/* =========================================================
   Descomplica TI — Gestão de Leads
   Tokens: navy #0B1F3A / #0F2A4A · cyan #00C2CC / #0891A8
   Type: Inter (UI) + JetBrains Mono (dados técnicos)
   ========================================================= */

:root {
  --navy-950: #071427;
  --navy-900: #0b1f3a;
  --navy-800: #0f2a4a;
  --navy-700: #16375c;
  --cyan: #00c2cc;
  --cyan-dim: #4fb8c4;
  --cyan-deep: #0891a8;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --line: #e3e9ee;
  --text: #16232f;
  --text-dim: #55697a;
  --text-faint: #8496a4;
  --success: #1a9c6b;
  --success-bg: #e5f7ef;
  --warning: #d97706;
  --warning-bg: #fef3e2;
  --danger: #dc4c4c;
  --danger-bg: #fdeaea;
  --neutral-bg: #eef1f4;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(11, 31, 58, 0.06);
  --shadow-md: 0 8px 24px rgba(11, 31, 58, 0.10);
  --shadow-lg: 0 24px 60px rgba(7, 20, 39, 0.22);
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- Layout shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 22px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 18px;
}

.brand-mark {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 194, 204, 0.12);
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; font-weight: 700; letter-spacing: 0.2px; }
.brand-text span { font-size: 12px; color: var(--cyan-dim); font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none;
  color: rgba(255,255,255,0.72);
  padding: 11px 12px;
  border-radius: 9px;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.is-active {
  background: rgba(0, 194, 204, 0.14);
  color: #fff;
}
.nav-item.is-active svg { color: var(--cyan); opacity: 1; }

.sidebar-footer { padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-actions { display: flex; flex-direction: column; gap: 8px; }
.sidebar-hint { font-size: 11.5px; color: rgba(255,255,255,0.42); margin: 8px 2px 0; line-height: 1.4; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; border-radius: 9px;
  padding: 10px 16px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-cyan { background: var(--cyan); color: #04262a; }
.btn-cyan:hover { background: #12d0da; }
.btn-navy { background: var(--navy-800); color: #fff; }
.btn-navy:hover { background: var(--navy-700); }
.btn-ghost { background: var(--neutral-bg); color: var(--text-dim); }
.btn-ghost:hover { background: #e3e8ec; color: var(--text); }
.btn-outline-cyan {
  background: rgba(0, 194, 204, 0.08);
  color: var(--cyan);
  border: 1px solid rgba(0, 194, 204, 0.4);
}
.btn-outline-cyan:hover {
  background: rgba(0, 194, 204, 0.18);
  border-color: var(--cyan);
  color: #fff;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ---------- Main / topbar ---------- */
.main { min-width: 0; padding: 26px 32px 60px; }

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px; margin-bottom: 24px; flex-wrap: wrap;
}
.topbar-title h1 { font-size: 22px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.2px; }
.topbar-title p { font-size: 13.5px; color: var(--text-dim); margin: 0; }

.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px;
  min-width: 300px;
  box-shadow: var(--shadow-sm);
  color: var(--text-faint);
}
.topbar-search input {
  border: none; outline: none; background: transparent;
  width: 100%; font-size: 13.5px; color: var(--text);
}
.topbar-search input::placeholder { color: var(--text-faint); }

/* ---------- Views ---------- */
.view { display: none; }
.view.is-active { display: block; }

/* ---------- Stat grid ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-faint); margin-bottom: 8px; display: block;
}
.stat-card .stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.stat-card .stat-foot { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.stat-card.accent { border-color: rgba(0,194,204,0.35); background: linear-gradient(180deg, #f2fdfe, #ffffff); }
.stat-card.accent .stat-value { color: var(--cyan-deep); }

/* ---------- Panels ---------- */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { font-size: 14.5px; font-weight: 700; margin: 0; }
.panel-sub { font-size: 11.5px; color: var(--text-faint); }

.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 128px 1fr 34px; align-items: center; gap: 10px; }
.bar-row .bar-label {
  font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-row .bar-track { background: var(--neutral-bg); border-radius: 6px; height: 9px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--cyan-deep), var(--cyan)); }
.bar-row .bar-value { font-size: 12px; font-weight: 700; color: var(--text-dim); text-align: right; }

.activity-list { display: flex; flex-direction: column; }
.activity-row {
  display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.activity-row:last-child { border-bottom: none; }
.activity-row .a-date { color: var(--text-faint); font-size: 11.5px; }
.activity-row .a-company { font-weight: 600; }
.activity-row .a-detail { color: var(--text-dim); font-size: 12.5px; }
.activity-empty { color: var(--text-faint); font-size: 13px; padding: 8px 4px; }

/* ---------- Filters ---------- */
.filters {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.filters select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; font-size: 13px; color: var(--text); min-width: 150px;
  box-shadow: var(--shadow-sm);
}
.filters-count { margin-left: auto; font-size: 12.5px; color: var(--text-faint); font-weight: 600; }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.leads-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.leads-table thead th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-faint); background: var(--surface-2);
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.leads-table thead th:hover { color: var(--cyan-deep); }
.leads-table tbody tr { cursor: pointer; transition: background 0.1s ease; }
.leads-table tbody tr:hover { background: var(--surface-2); }
.leads-table tbody tr:not(:last-child) td { border-bottom: 1px solid var(--line); }
.leads-table td { padding: 12px 16px; vertical-align: middle; }
.leads-table td.company-cell { font-weight: 600; }
.leads-table td.company-cell .sub { font-weight: 400; color: var(--text-faint); font-size: 11.5px; display: block; margin-top: 2px; }
.leads-table td.contact-cell { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-dim); }
.tentativas-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--neutral-bg); color: var(--text-dim);
  font-size: 11.5px; font-weight: 700;
}
.tentativas-pill.has-activity { background: rgba(0,194,204,0.14); color: var(--cyan-deep); }

.empty-state { text-align: center; padding: 40px 0; color: var(--text-faint); font-size: 13.5px; }

/* ---------- Status badges ---------- */
.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-nao-contatado { background: var(--neutral-bg); color: var(--text-dim); }
.status-tentativa-1, .status-tentativa-2, .status-tentativa-3 { background: var(--warning-bg); color: var(--warning); }
.status-em-conversa, .status-reuniao-agendada, .status-proposta-enviada { background: rgba(0,194,204,0.14); color: var(--cyan-deep); }
.status-convertido { background: var(--success-bg); color: var(--success); }
.status-nao-interessado, .status-numero-contato-invalido { background: var(--danger-bg); color: var(--danger); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(7, 20, 39, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto; z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 980px;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modal-in 0.18s ease;
}
.modal.modal-md { max-width: 620px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: var(--neutral-bg); border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 18px; line-height: 1; cursor: pointer;
  color: var(--text-dim);
}
.modal-close:hover { background: #e3e8ec; }

.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 24px 56px 18px 28px;
  border-bottom: 1px solid var(--line);
}
.modal-header h2 { margin: 0 0 4px; font-size: 19px; font-weight: 800; }
.modal-meta { margin: 0; font-size: 12.5px; color: var(--text-faint); }

.modal-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
}
.modal-body-single {
  padding: 24px 28px;
}
.modal-col { padding: 20px 28px; }
.modal-col:first-child { border-right: 1px solid var(--line); }

.modal-section { margin-bottom: 24px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section h3 {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-faint); margin: 0 0 10px;
}

.info-list { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0; font-size: 13px; }
.info-list div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.info-list dt { color: var(--text-faint); flex-shrink: 0; }
.info-list dd { margin: 0; text-align: right; font-weight: 500; word-break: break-word; }
.info-list a { color: var(--cyan-deep); text-decoration: none; }
.info-list a:hover { text-decoration: underline; }

.diagnostico-text { font-size: 13px; color: var(--text-dim); line-height: 1.55; margin: 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-dim); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
  font-size: 13px; font-weight: 400; color: var(--text); background: var(--surface-2);
  resize: vertical;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: 2px solid var(--cyan); outline-offset: 1px; background: #fff;
}

.feedback { font-size: 12px; margin-left: 10px; font-weight: 600; }
.feedback.ok { color: var(--success); }
.feedback.err { color: var(--danger); }

/* ---------- Drop Zone (Import) ---------- */
.drop-zone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: var(--surface-2);
}
.drop-zone:hover, .drop-zone.is-dragover {
  border-color: var(--cyan);
  background: rgba(0, 194, 204, 0.04);
}
.drop-zone-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(0, 194, 204, 0.12); color: var(--cyan-deep);
  margin-bottom: 12px;
}
.drop-zone-title { margin: 0 0 4px; font-size: 14px; color: var(--text); }
.drop-zone-sub { margin: 0; font-size: 12px; color: var(--text-faint); }
.drop-zone-sub code {
  background: var(--neutral-bg); padding: 2px 5px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
}

.file-selected-box {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.file-info { display: flex; align-items: center; gap: 12px; text-align: left; }
.file-meta { display: flex; flex-direction: column; }
.file-meta strong { font-size: 13.5px; color: var(--text); word-break: break-all; }
.file-meta span { font-size: 11.5px; color: var(--text-faint); }

.import-section { margin-top: 20px; }
.import-section-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-faint); margin-bottom: 10px; display: block;
}
.import-modes { display: flex; flex-direction: column; gap: 8px; }
.mode-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease;
  background: var(--surface);
}
.mode-card:hover { border-color: var(--cyan-dim); background: var(--surface-2); }
.mode-card input[type="radio"] { margin-top: 3px; accent-color: var(--cyan-deep); cursor: pointer; }
.mode-content { display: flex; flex-direction: column; gap: 2px; }
.mode-content strong { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.mode-content span { font-size: 12px; color: var(--text-dim); line-height: 1.35; }
.badge-rec {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
  background: rgba(0, 194, 204, 0.15); color: var(--cyan-deep); letter-spacing: 0.3px;
}
.mode-card-danger:hover { border-color: rgba(220, 76, 76, 0.4); }

.import-result {
  margin-top: 18px; padding: 14px 16px; border-radius: var(--radius);
  font-size: 13px; line-height: 1.45;
}
.import-result.success { background: var(--success-bg); border: 1px solid rgba(26, 156, 107, 0.3); color: #0f5132; }
.import-result.error { background: var(--danger-bg); border: 1px solid rgba(220, 76, 76, 0.3); color: var(--danger); }
.import-stat-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.stat-badge-item {
  font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px;
  background: #ffffff; border: 1px solid rgba(0,0,0,0.08); color: var(--text);
}

.modal-footer {
  display: flex; justify-content: flex-end; align-items: center; gap: 10px;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line);
}

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 0; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.timeline-item { display: grid; grid-template-columns: 20px 1fr; gap: 12px; }
.timeline-rail { display: flex; flex-direction: column; align-items: center; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); margin-top: 4px; flex-shrink: 0; }
.timeline-line { flex: 1; width: 2px; background: var(--line); margin-top: 2px; }
.timeline-item:last-child .timeline-line { display: none; }
.timeline-content { padding-bottom: 18px; }
.timeline-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.timeline-type { font-size: 12.5px; font-weight: 700; }
.timeline-date { font-size: 11px; color: var(--text-faint); }
.timeline-result { font-size: 13px; color: var(--text); margin: 0 0 2px; }
.timeline-obs { font-size: 12px; color: var(--text-dim); margin: 0; }
.timeline-status-chip {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: rgba(0,194,204,0.14); color: var(--cyan-deep);
}
.timeline-empty { color: var(--text-faint); font-size: 13px; padding: 4px 0 0; }
.timeline-del {
  background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 11px;
  padding: 0; margin-top: 2px; text-decoration: underline;
}
.timeline-del:hover { color: var(--danger); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--navy-900); color: #fff;
  padding: 12px 20px; border-radius: 10px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 200;
}
.toast.err { background: var(--danger); }
.toast[hidden] { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .modal-body { grid-template-columns: 1fr; }
  .modal-col:first-child { border-right: none; border-bottom: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; align-items: center; gap: 16px; padding: 14px 16px; }
  .brand { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
  .nav { flex-direction: row; flex: none; }
  .sidebar-footer { border-top: none; padding-top: 0; display: flex; align-items: center; gap: 10px; }
  .sidebar-actions { flex-direction: row; }
  .sidebar-hint { display: none; }
  .main { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 96px 1fr 30px; }
}