/* Funil CRM — estilos globais */

:root {
  --ink-950: #0E1016;
  --ink-900: #161923;
  --ink-800: #1F2330;
  --ink-700: #2A2F3F;
  --ink-500: #565D73;
  --ink-300: #9AA0B4;
  --paper-50: #FBFBFA;
  --paper-100: #F3F4F6;
  --paper-200: #E8E9ED;
  --signal: #FF5A36;
  --signal-50: #FFF1EC;
  --signal-600: #E64A28;
  --teal: #0EA5A0;
  --teal-50: #E7F8F7;
  --amber: #E8A93B;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper-100);
  color: var(--ink-950);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; }
p { margin: 0; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; font-size: 14px; }

.muted { color: var(--ink-500); font-size: 13px; }
.muted.small { font-size: 12px; margin-top: 4px; margin-bottom: 20px; }
.text-signal { color: var(--signal); font-weight: 500; }
.text-teal { color: var(--teal); }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-body { background: var(--paper-100); }
.login-grid { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
@media (max-width: 960px) { .login-grid { grid-template-columns: 1fr; } .login-brand { display: none; } }

.login-brand {
  background: var(--ink-950);
  color: var(--paper-50);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-brand-copy { max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.login-brand-copy h1 { font-size: 34px; line-height: 1.25; font-weight: 700; }
.login-brand .eyebrow { color: var(--signal); }
.login-brand .muted { color: var(--ink-300); line-height: 1.6; }
.foot-note { color: var(--ink-500); font-size: 12px; }

.brand-mark { display: flex; align-items: center; gap: 8px; }
.logo-box {
  width: 32px; height: 32px; border-radius: 10px; background: var(--signal);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; color: white;
}
.logo-text { font-family: var(--font-display); font-size: 18px; }

.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 18px; }
.login-form h2 { font-size: 24px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-700); }
.login-form input {
  border: 1px solid rgba(31,35,48,0.1); border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none;
}
.login-form input:focus { border-color: var(--signal); box-shadow: 0 0 0 3px rgba(255,90,54,0.15); }
.hint { font-size: 12px; color: var(--ink-500); text-align: center; }

.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--signal); font-weight: 600; margin-bottom: 6px; }

.alert-error {
  font-size: 13px; color: var(--signal-600); background: var(--signal-50);
  border: 1px solid rgba(255,90,54,0.3); border-radius: 8px; padding: 8px 12px;
  margin-bottom: 4px;
}

.btn { border-radius: 8px; padding: 10px 16px; font-size: 14px; font-weight: 500; transition: background 0.15s; }
.btn-primary { background: var(--ink-950); color: white; }
.btn-primary:hover { background: var(--signal); }
.btn-block { width: 100%; text-align: center; }

/* ---------- App shell (estilo Pipedrive: rail estreita + topbar) ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar-rail {
  width: 60px; flex-shrink: 0; background: var(--paper-50); border-right: 1px solid var(--paper-200);
  display: flex; flex-direction: column; align-items: center; position: sticky; top: 0; height: 100vh;
  padding: 14px 0;
}
.rail-brand { margin-bottom: 12px; }
.rail-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; align-items: center; width: 100%; }
.rail-bottom { display: flex; flex-direction: column; align-items: center; padding-top: 8px; }

.rail-item {
  width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-500); transition: background 0.15s, color 0.15s;
}
.rail-item .material-symbols-outlined { font-size: 22px; }
.rail-item:hover { background: var(--paper-200); color: var(--ink-950); }
.rail-item.active { background: var(--signal-50); color: var(--signal); }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 500; flex-shrink: 0;
}
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 20px; padding: 0 24px;
  background: white; border-bottom: 1px solid var(--paper-200); position: sticky; top: 0; z-index: 10;
}
.topbar-crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.topbar-app-name { font-family: var(--font-display); font-weight: 700; color: var(--ink-950); }
.topbar-sep { color: var(--ink-300); }
.topbar-page { color: var(--ink-500); }
.topbar-search {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: 6px; background: var(--paper-100);
  border-radius: 8px; padding: 7px 12px;
}
.topbar-search-icon { font-size: 18px; color: var(--ink-300); }
.topbar-search input { border: none; background: none; outline: none; font-size: 13px; width: 100%; color: var(--ink-950); }
.topbar-search input::placeholder { color: var(--ink-300); }
.topbar-user { margin-left: auto; }

.main-content { flex: 1; min-width: 0; }
.page-wrap { padding: 32px; max-width: 960px; }
.page-wrap-wide { max-width: 1180px; }

.data-table-wrap {
  background: white; border-radius: 14px; border: 1px solid rgba(31,35,48,0.04);
  box-shadow: 0 1px 2px rgba(14,16,22,0.06); overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-500);
  font-weight: 600; padding: 12px 16px; background: var(--paper-100); border-bottom: 1px solid var(--paper-200);
}
.data-table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--paper-200); color: var(--ink-950); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--paper-100); }
.data-table-name { font-weight: 500; }
.page-wrap-fluid { max-width: none; height: calc(100vh - 56px); display: flex; flex-direction: column; }
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 30px; }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-header-row h1 { margin-bottom: 4px; }
.page-header-row .muted { margin-top: 4px; max-width: 480px; }

/* ---------- Dashboard ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
@media (max-width: 800px) { .metric-grid { grid-template-columns: repeat(2, 1fr); } }

.metric-card {
  background: white; border-radius: 14px; border: 1px solid rgba(31,35,48,0.04);
  box-shadow: 0 1px 2px rgba(14,16,22,0.06); padding: 16px;
}
.metric-icon {
  width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; color: white; font-size: 14px;
}
.metric-icon.ink { background: var(--ink-950); }
.metric-icon.teal { background: var(--teal); }
.metric-icon.amber { background: var(--amber); }
.metric-icon.signal { background: var(--signal); }
.metric-label { font-size: 12px; color: var(--ink-500); margin-bottom: 4px; }
.metric-value { font-family: var(--font-display); font-size: 22px; }
.metric-sub { font-size: 11px; color: var(--ink-500); margin-top: 2px; }

.panel {
  background: white; border-radius: 14px; border: 1px solid rgba(31,35,48,0.04);
  box-shadow: 0 1px 2px rgba(14,16,22,0.06); padding: 24px;
}
.panel h2 { font-size: 18px; margin-bottom: 4px; }

.bar-chart { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 90px; align-items: center; gap: 12px; }
.bar-label { font-size: 12px; color: var(--ink-500); }
.bar-track { background: var(--paper-200); border-radius: 6px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width 0.4s ease; }
.bar-signal { background: var(--signal); }
.bar-teal { background: var(--teal); }
.bar-ink { background: var(--ink-500); }
.bar-value { font-family: var(--font-mono); font-size: 11px; text-align: right; color: var(--ink-950); }

/* ---------- Pipeline / Kanban ---------- */
.pipeline-tabs { display: flex; gap: 16px; margin-top: 4px; }
.pipeline-tab { font-family: var(--font-display); font-size: 24px; color: var(--ink-300); }
.pipeline-tab.active { color: var(--ink-950); }
.pipeline-tab:hover { color: var(--ink-500); }

.kanban-board { flex: 1; display: flex; gap: 20px; overflow-x: auto; padding: 0 32px 24px; }
.stage-column { width: 280px; flex-shrink: 0; display: flex; flex-direction: column; }
.stage-bar { height: 4px; border-radius: 4px; margin-bottom: 12px; }
.stage-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.stage-head h3 { font-size: 14px; font-weight: 500; }
.stage-count { font-size: 12px; color: var(--ink-500); }
.stage-total { font-family: var(--font-mono); font-size: 11px; color: var(--ink-500); margin-bottom: 12px; }
.stage-drop { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 120px; border-radius: 14px; padding: 6px; transition: background 0.15s; }
.stage-drop.drag-over { background: rgba(255,90,54,0.1); }

.deal-card {
  background: white; border-radius: 10px; border: 1px solid rgba(31,35,48,0.05);
  box-shadow: 0 1px 2px rgba(14,16,22,0.06); padding: 12px; cursor: grab;
}
.deal-card.dragging { opacity: 0.5; }
.deal-card:hover { border-color: rgba(255,90,54,0.4); }
.deal-title { font-size: 14px; font-weight: 500; margin-bottom: 8px; line-height: 1.35; }
.deal-subtitle { font-size: 11px; color: var(--ink-500); margin-bottom: 8px; }
.deal-foot { display: flex; align-items: center; justify-content: space-between; }
.deal-value { font-family: var(--font-mono); font-size: 12px; font-weight: 500; }

.add-deal-btn { text-align: left; font-size: 12px; color: var(--ink-500); padding: 8px; border-radius: 8px; }
.add-deal-btn:hover { color: var(--signal); background: white; }

/* ---------- Listas (contatos, atividades, automações) ---------- */
.list-panel {
  background: white; border-radius: 14px; border: 1px solid rgba(31,35,48,0.04);
  box-shadow: 0 1px 2px rgba(14,16,22,0.06);
}
.list-row { padding: 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(31,35,48,0.04); }
.list-row:last-child { border-bottom: none; }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-size: 14px; font-weight: 500; }
.list-row-meta { display: flex; gap: 12px; margin-top: 4px; font-size: 12px; color: var(--ink-500); flex-wrap: wrap; }
.list-row-meta-line { font-size: 11px; color: var(--ink-500); margin-top: 2px; }
.list-row-badge { font-size: 12px; color: var(--ink-500); flex-shrink: 0; }

.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-row {
  background: white; border-radius: 10px; border: 1px solid rgba(31,35,48,0.05);
  box-shadow: 0 1px 2px rgba(14,16,22,0.06); padding: 14px; display: flex; align-items: center; gap: 12px;
}
.activity-row.overdue { border-color: rgba(255,90,54,0.4); }
.check-btn {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid rgba(31,35,48,0.15);
  color: transparent; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0;
}
.check-btn:hover { border-color: var(--teal); background: var(--teal-50); color: var(--teal); }
.activity-icon {
  width: 28px; height: 28px; border-radius: 8px; background: var(--paper-100); color: var(--ink-500);
  display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0;
}
.activity-body { flex: 1; min-width: 0; }
.activity-subject { font-size: 14px; }
.activity-meta { display: flex; gap: 8px; font-size: 11px; color: var(--ink-500); margin-top: 3px; flex-wrap: wrap; }

.rule-row { align-items: center; }
.rule-icon {
  width: 32px; height: 32px; border-radius: 8px; background: var(--paper-100); color: var(--ink-500);
  display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
}
.rule-icon.active { background: var(--teal-50); color: var(--teal); }
.pill-toggle { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(31,35,48,0.05); color: var(--ink-500); font-weight: 500; flex-shrink: 0; }
.pill-toggle.pill-active { background: var(--teal-50); color: var(--teal); }
.icon-btn-danger { color: var(--ink-300); flex-shrink: 0; font-size: 14px; }
.icon-btn-danger:hover { color: var(--signal); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.picked-product-row {
  display: grid; grid-template-columns: 1fr 56px 70px 20px; align-items: center; gap: 8px;
  font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--paper-200);
}
.picked-product-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked-product-qty { width: 56px; padding: 4px 6px; border: 1px solid rgba(31,35,48,0.1); border-radius: 6px; font-size: 12px; }
.picked-product-price { font-family: var(--font-mono); text-align: right; }
.picked-product-remove { color: var(--ink-300); font-size: 16px; line-height: 1; }
.picked-product-remove:hover { color: var(--signal); }

.entity-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.entity-tab {
  font-size: 13px; padding: 6px 14px; border-radius: 999px; background: white;
  border: 1px solid rgba(31,35,48,0.08); color: var(--ink-500);
}
.entity-tab.active { background: var(--ink-950); color: white; border-color: var(--ink-950); }
.entity-tab:hover:not(.active) { border-color: var(--signal); color: var(--ink-950); }
/* ---------- Detalhe do negócio ---------- */
.back-link { font-size: 12px; color: var(--ink-500); display: inline-block; margin-bottom: 4px; }
.back-link:hover { color: var(--signal); }

.inline-title-input {
  font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--ink-950);
  border: none; background: none; padding: 2px 0; width: 100%; outline: none;
}
.inline-title-input:focus { border-bottom: 2px solid var(--signal); }

.deal-detail-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.deal-detail-actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn-ghost { background: white; border: 1px solid rgba(31,35,48,0.1); color: var(--ink-700); font-size: 12px; padding: 8px 14px; border-radius: 8px; }
.btn-ghost:hover { border-color: var(--signal); color: var(--signal); }

.deal-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .deal-detail-grid { grid-template-columns: 1fr; } }
.deal-detail-col { display: flex; flex-direction: column; gap: 20px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row label, .panel label {
  display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-700); margin-bottom: 10px;
}
.field-row input, .field-row select, .panel input, .panel select {
  border: 1px solid rgba(31,35,48,0.1); border-radius: 8px; padding: 8px 10px; font-size: 14px; outline: none; text-transform: none;
}
.field-row input:focus, .field-row select:focus, .panel input:focus, .panel select:focus { border-color: var(--signal); }

.products-total { font-size: 12px; color: var(--ink-950); margin-top: 8px; text-align: right; }

.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input[type="text"] { flex: 1; border: 1px solid rgba(31,35,48,0.1); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.inline-form input[type="date"] { border: 1px solid rgba(31,35,48,0.1); border-radius: 8px; padding: 8px 10px; font-size: 13px; }

.mini-activity-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--paper-200); }
.mini-activity-row.done .mini-activity-subject { text-decoration: line-through; color: var(--ink-500); }
.mini-activity-subject { flex: 1; font-size: 13px; }
.mini-activity-date { font-size: 11px; color: var(--ink-500); }
.check-btn.checked { border-color: var(--teal); background: var(--teal-50); color: var(--teal); }

.note-row { padding: 10px 0; border-bottom: 1px solid var(--paper-200); }
.note-content { font-size: 13px; margin-bottom: 4px; }
.note-meta { font-size: 11px; color: var(--ink-500); }

/* ---------- Modal largo (duas colunas, estilo Pipedrive) ---------- */
.modal-wide { max-width: 720px; }
.modal-two-col { display: grid; grid-template-columns: 1fr 220px; gap: 24px; align-items: start; }
@media (max-width: 640px) { .modal-two-col { grid-template-columns: 1fr; } }
.modal-col label { margin-bottom: 12px; }
.modal-col-side {
  background: var(--paper-100); border-radius: 10px; padding: 14px; position: sticky; top: 0;
}
.side-panel-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-500); font-weight: 600; margin-bottom: 8px; }

.new-entity-fields { background: var(--teal-50); border-radius: 8px; padding: 10px 12px; margin: -6px 0 12px; }
.new-entity-badge { font-size: 11px; color: var(--teal); font-weight: 500; margin-bottom: 8px; text-transform: none; }
.new-entity-fields .field-row { margin-bottom: 0; }
.new-entity-fields .field-row label { margin-bottom: 0; }

.ac-wrap { position: relative; }
.ac-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid rgba(31,35,48,0.1);
  border-radius: 8px; box-shadow: 0 4px 16px rgba(14,16,22,0.12); z-index: 20; max-height: 220px; overflow-y: auto; margin-top: 4px;
}
.ac-item { padding: 8px 12px; cursor: pointer; text-transform: none; }
.ac-item:hover { background: var(--paper-100); }
.ac-item-title { font-size: 13px; color: var(--ink-950); }
.ac-item-sub { font-size: 11px; color: var(--ink-500); }
.ac-create { color: var(--signal); font-size: 13px; border-top: 1px solid var(--paper-200); }

.icon-btn-note { color: var(--ink-300); font-size: 13px; padding: 2px; flex-shrink: 0; }
.icon-btn-note:hover { color: var(--teal); }

.deal-label {
  display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--signal); background: var(--signal-50); border-radius: 4px; padding: 2px 6px; margin-bottom: 6px;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(14,16,22,0.4); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal { background: white; border-radius: 14px; box-shadow: 0 4px 24px rgba(14,16,22,0.15); width: 100%; max-width: 380px; padding: 24px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h3 { font-size: 18px; }
.modal-close { font-size: 20px; color: var(--ink-500); line-height: 1; }
.modal-close:hover { color: var(--ink-950); }
#rule-form, #deal-form, #contact-form, #activity-form { display: flex; flex-direction: column; gap: 14px; }
#rule-form label, #deal-form label, #contact-form label, #activity-form label {
  display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-700);
}
#rule-form input, #rule-form select, #deal-form input, #contact-form input, #activity-form input, #activity-form select {
  border: 1px solid rgba(31,35,48,0.1); border-radius: 8px; padding: 9px 12px; font-size: 14px; outline: none;
}
#rule-form input:focus, #rule-form select:focus, #deal-form input:focus,
#contact-form input:focus, #activity-form input:focus, #activity-form select:focus {
  border-color: var(--signal); box-shadow: 0 0 0 3px rgba(255,90,54,0.15);
}
