/* ============ tokens (paleta de referência, modo claro) ============ */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-dark: #1c5cab;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(11, 11, 11, 0.07), 0 1px 2px rgba(11, 11, 11, 0.04);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--page); color: var(--ink); font-size: 14px; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }

/* ============ layout ============ */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 210px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--grid); display: flex; flex-direction: column; padding: 16px 10px;
}
.logo { font-size: 17px; font-weight: 700; padding: 4px 12px 18px; letter-spacing: -0.2px; }
.logo span { color: var(--accent); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; margin-bottom: 2px; border: none; background: none;
  width: 100%; text-align: left; font-size: 14px;
}
.nav-item:hover { background: var(--page); color: var(--ink); }
.nav-item.active { background: #eaf2fc; color: var(--accent-dark); font-weight: 600; }
.nav-item .icon { width: 18px; text-align: center; }
.nav-badge {
  margin-left: auto; background: var(--critical); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 99px; padding: 1px 7px; min-width: 18px; text-align: center;
}
.sidebar-user {
  margin-top: auto; display: flex; align-items: center; gap: 6px;
  padding: 10px 12px 2px; border-top: 1px solid var(--grid);
}
.sidebar-user span {
  flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============ login ============ */
.auth-wrap {
  position: fixed; inset: 0; background: var(--page); z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.auth-card { width: 100%; max-width: 380px; padding: 28px; }
.auth-card .logo { padding: 0 0 18px; text-align: center; font-size: 20px; }
.user-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--grid); }
.user-row:last-child { border-bottom: none; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--grid);
}
.topbar h1 { font-size: 17px; font-weight: 700; flex: 1; }
.content { flex: 1; overflow: auto; padding: 20px 24px; }

/* ============ generic ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; border: 1px solid var(--border);
  padding: 7px 14px; background: var(--surface); color: var(--ink); font-weight: 500;
}
.btn:hover { background: var(--page); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 6px; }
.btn-ghost { border: none; background: none; color: var(--ink-2); padding: 4px 8px; border-radius: 6px; }
.btn-ghost:hover { background: var(--page); color: var(--ink); }
.btn-danger { color: var(--critical); }
.btn-danger:hover { background: #fbeaea; }
.input, select.input, textarea.input {
  border: 1px solid var(--baseline); border-radius: 8px; padding: 7px 10px; background: var(--surface); width: 100%;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea.input { resize: vertical; min-height: 64px; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--grid); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: 99px; background: var(--page); border: 1px solid var(--grid); color: var(--ink-2);
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.overdue-text { color: var(--critical); font-weight: 600; }
.today-text { color: var(--good-text); font-weight: 600; }

/* ============ dashboard ============ */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { padding: 14px 16px; }
.kpi .kpi-label { font-size: 12px; color: var(--ink-2); font-weight: 600; margin-bottom: 6px; }
.kpi .kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.kpi .kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }
.panel { padding: 16px 18px; }
.panel h2 { font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 90px; align-items: center; gap: 10px; margin-bottom: 10px; }
.funnel-name { font-size: 13px; color: var(--ink-2); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel-track { height: 22px; position: relative; }
.funnel-bar { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.funnel-val { font-size: 13px; color: var(--ink); font-weight: 600; white-space: nowrap; }
.funnel-val .small { font-weight: 400; }
.rate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rate { padding: 12px 14px; border: 1px solid var(--grid); border-radius: 8px; }
.rate .rate-label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.rate .rate-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.rate .rate-sub { font-size: 12px; color: var(--muted); }
.list-plain { list-style: none; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--grid); display: flex; gap: 10px; align-items: center; }
.list-plain li:last-child { border-bottom: none; }

/* ============ pipeline (kanban) ============ */
.board { display: flex; gap: 12px; align-items: flex-start; min-height: calc(100vh - 160px); }
.col { width: 250px; flex-shrink: 0; background: #f3f3f0; border-radius: var(--radius); padding: 10px; }
.col-header { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.col-header .col-name { font-weight: 700; font-size: 13px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-header .col-count { font-size: 12px; color: var(--muted); }
.col-sum { font-size: 12px; color: var(--ink-2); padding: 0 4px 8px; }
.col.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.lead-card {
  background: var(--surface); border: 1px solid var(--grid); border-radius: 8px; padding: 10px 12px;
  margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow);
}
.lead-card:hover { border-color: var(--baseline); }
.lead-card .lc-name { font-weight: 600; margin-bottom: 4px; }
.lead-card .lc-value { font-size: 13px; color: var(--ink-2); }
.lead-card .lc-next { font-size: 12px; margin-top: 6px; display: flex; align-items: center; gap: 5px; }

/* ============ tables ============ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--page); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============ atividades ============ */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--grid); background: var(--surface); border-radius: 99px; padding: 6px 14px;
  color: var(--ink-2); font-size: 13px; font-weight: 500;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab .dot { display: inline-block; vertical-align: middle; margin-right: 6px; }

/* ============ relatórios ============ */
.report-filter { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.report-filter .field { flex: 0 0 160px; }
.report-title { font-size: 14px; font-weight: 700; margin: 4px 0 12px; color: var(--ink-2); }
.act-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--grid); }
.act-row:last-child { border-bottom: none; }
.act-icon {
  width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0; background: var(--page); border: 1px solid var(--grid);
}
.act-main { flex: 1; min-width: 0; }
.act-title { font-weight: 600; }
.act-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.act-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.outcome-pill { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; }
.outcome-good { background: #e6f4e6; color: var(--good-text); }
.outcome-bad { background: #fbeaea; color: var(--critical); }
.outcome-neutral { background: var(--page); color: var(--ink-2); border: 1px solid var(--grid); }

/* ============ modal ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 11, 11, 0.35); display: flex;
  align-items: flex-start; justify-content: center; padding: 4vh 16px; z-index: 50; overflow: auto;
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px;
  box-shadow: 0 20px 50px rgba(11, 11, 11, 0.25); padding: 22px; max-height: 92vh; overflow: auto;
}
.modal.modal-lg { max-width: 980px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.modal-head h2 { font-size: 17px; flex: 1; }
.lead-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 24px; }
@media (max-width: 860px) { .lead-grid { grid-template-columns: 1fr; } }
.timeline { list-style: none; margin-top: 8px; }
.timeline li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--grid); font-size: 13px; white-space: pre-line; }
.timeline li:last-child { border-bottom: none; }
.timeline .tl-time { color: var(--muted); font-size: 12px; white-space: nowrap; flex-shrink: 0; width: 110px; }
.act-open-item {
  display: flex; gap: 8px; align-items: center; border: 1px solid var(--grid);
  border-radius: 8px; padding: 8px 10px; margin-bottom: 6px;
}
.section-title { font-size: 13px; font-weight: 700; margin: 16px 0 8px; color: var(--ink-2); }
details.utm { margin-bottom: 10px; }
details.utm summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 4px 0; }

/* ============ definições / automatizações ============ */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .settings-grid { grid-template-columns: 1fr; } }
.stage-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--grid); }
.stage-row:last-child { border-bottom: none; }
.stage-row input[type="color"] { width: 30px; height: 30px; border: none; background: none; padding: 0; cursor: pointer; }
.copy-box {
  display: flex; gap: 6px; align-items: center; background: var(--page); border: 1px solid var(--grid);
  border-radius: 8px; padding: 8px 10px; margin: 6px 0 14px;
}
.copy-box code { font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auto-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--grid); }
.auto-row:last-child { border-bottom: none; }
.switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--baseline); border-radius: 99px; transition: 0.15s; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: 0.15s;
}
.switch input:checked + .slider { background: var(--good); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* ============ toast ============ */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; border-radius: 8px; padding: 10px 16px; font-size: 13px;
  box-shadow: var(--shadow); animation: toast-in 0.2s ease;
}
.toast.error { background: var(--critical); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
