/* CRM Fazlo
   Layout: ferramenta de trabalho — listas priorizadas em coluna única; ficha do lead em gaveta à direita (tela cheia no celular). */
:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #F0F2F5;
  --line: #E3E6EB;
  --line-strong: #CDD2DA;
  --fg: #16181D;
  --fg-2: #555C69;
  --fg-3: #858C99;
  --accent: #3B5BFD;
  --accent-ink: #FFFFFF;
  --accent-soft: #ECEFFF;
  --ok: #0B7F57;   --ok-soft: #E3F4EC;
  --warn: #9A5B00; --warn-soft: #FFF2DB;
  --bad: #C2312F;  --bad-soft: #FDEBEA;
  --shadow: 0 1px 2px rgba(22, 24, 29, .05), 0 8px 24px rgba(22, 24, 29, .06);
  --shadow-lg: 0 12px 48px rgba(22, 24, 29, .18);
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 10px;
  --r-sm: 7px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --surface: #181C21; --surface-2: #20252C; --line: #2A3038; --line-strong: #3A414B;
    --fg: #ECEEF2; --fg-2: #A6ACB8; --fg-3: #737A87;
    --accent: #7088FF; --accent-ink: #0D1020; --accent-soft: #1D2547;
    --ok: #45D19F; --ok-soft: #10291F; --warn: #F0B455; --warn-soft: #2D2310; --bad: #FF8079; --bad-soft: #321817;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    --shadow-lg: 0 12px 48px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; letter-spacing: -0.015em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--fg-2); }
.faint { color: var(--fg-3); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- marca ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); font-weight: 650; font-size: 16px; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand em { font-style: normal; font-weight: 500; color: var(--fg-3); font-family: var(--mono); font-size: 12px; letter-spacing: 0; padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--fg); position: relative; }
.brand-mark::after { content: ""; position: absolute; right: -3px; bottom: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.brand-lg { font-size: 20px; }

/* ---------- acesso ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 380px; display: grid; gap: 18px; }
.gate-card h1 { margin-top: 18px; }
.req { margin: 0; padding-left: 18px; color: var(--bad); }

/* ---------- topo ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1120px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 24px; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tabs a { display: flex; align-items: center; padding: 0 12px; color: var(--fg-2); font-weight: 500; position: relative; }
.tabs a:hover { color: var(--fg); text-decoration: none; }
.tabs a.on { color: var(--fg); }
.tabs a.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--fg); border-radius: 2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; position: relative; }
.usage-pill { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px; font: 500 12px/1.4 var(--mono); color: var(--fg-2); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.usage-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.usage-pill.warn .dot { background: var(--warn); }
.usage-pill.bad .dot { background: var(--bad); }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 8px; color: var(--fg-2); cursor: pointer; fill: currentColor; }
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }
.menu { position: absolute; right: 0; top: 44px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px; min-width: 210px; display: grid; }
.menu button, .menu a { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; color: var(--fg); cursor: pointer; font-size: 14px; }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu form { margin: 0; }

/* ---------- página ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 16px 80px; display: grid; gap: 28px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .sub { margin-top: 4px; color: var(--fg-2); }
.section { display: grid; gap: 10px; }
.section-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.section-head .count { font: 500 12px var(--mono); color: var(--fg-3); }
.section-head .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; color: var(--fg-2); font-weight: 500; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- botões e campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn-primary:hover { background: color-mix(in srgb, var(--fg) 86%, var(--bg)); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--fg-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn-danger { color: var(--bad); }
.btn-block { width: 100%; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 550; color: var(--fg-2); letter-spacing: .01em; }
input[type=text], input[type=password], input[type=date], input[type=url], input[type=tel], input[type=search], select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 96px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--fg-3) 50%), linear-gradient(135deg, var(--fg-3) 50%, transparent 50%); background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
.stack { display: grid; gap: 12px; }
.form-error { color: var(--bad); font-size: 13px; }
.check { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; margin: 0; }

.search-form { display: grid; grid-template-columns: minmax(0, 1fr) 96px auto auto; gap: 10px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.research-form { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 96px auto; }
@media (max-width: 720px) {
  .search-form { grid-template-columns: 96px minmax(0, 1fr); }
  .research-form { grid-template-columns: minmax(0, 1fr) 96px; }
  .search-form .field-wide { grid-column: 1 / -1; }
  .search-form .btn { grid-column: 1 / -1; }
}

/* ---------- pílulas ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--surface-2); color: var(--fg-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.line { background: transparent; border: 1px solid var(--line-strong); }
.pill .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag { font: 500 11px var(--mono); color: var(--fg-3); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- listas ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.row:first-child { border-top: 0; }
.row:hover { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.row-main { min-width: 0; display: grid; gap: 3px; }
.row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.row-title .name { overflow: hidden; text-overflow: ellipsis; }
.row-meta { display: flex; gap: 2px 14px; flex-wrap: wrap; color: var(--fg-2); font-size: 13px; }
.row-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.row-side .quick { display: flex; gap: 6px; }
.due { font: 500 12px var(--mono); }
.due.late { color: var(--bad); }
.due.today { color: var(--warn); }
@media (max-width: 720px) {
  .row { grid-template-columns: 1fr; }
  .row-side { justify-content: flex-start; }
}

.empty { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r); padding: 26px 20px; display: grid; gap: 8px; justify-items: start; }
.empty h3 { font-size: 15px; }
.empty p { color: var(--fg-2); max-width: 60ch; }

/* filtros */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: 13px; font-weight: 500; color: var(--fg-2); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip .n { font: 500 11.5px var(--mono); color: var(--fg-3); }
.chip.on { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.chip.on .n { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.filters input[type=search] { width: 240px; height: 32px; border-radius: 999px; }
@media (max-width: 720px) { .filters input[type=search] { width: 100%; } }

/* ---------- resultados da busca ---------- */
.result-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0; border-bottom: 0; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 56px); z-index: 5; }
.result-bar .spacer { flex: 1; }
.result-bar + .list { border-radius: 0 0 var(--r) var(--r); }
.res-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--line); }
.res-row:first-child { border-top: 0; }
.res-row.dim { opacity: .55; }
.res-row .row-main { cursor: default; }
.res-links { display: flex; gap: 4px; }
.link-ico { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; color: var(--fg-2); border: 1px solid var(--line); background: var(--surface); }
.link-ico:hover { color: var(--fg); background: var(--surface-2); text-decoration: none; }
.link-ico svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.link-ico.off { opacity: .35; pointer-events: none; }
.stars { font: 500 12.5px var(--mono); color: var(--fg-2); }
@media (max-width: 720px) {
  .res-row { grid-template-columns: 22px minmax(0, 1fr); }
  .res-row .row-side { grid-column: 2; justify-content: flex-start; }
}

.coverage { display: grid; gap: 6px; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.coverage ul { margin: 0; padding-left: 18px; color: var(--fg-2); }
.coverage-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stat-line { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 13px; color: var(--fg-2); }
.stat-line b { font: 600 13px var(--mono); color: var(--fg); }

.recent { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- progresso ---------- */
.progress { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { padding: 14px 16px; border-radius: var(--r); background: var(--bad-soft); color: var(--bad); display: grid; gap: 4px; }
.error-box .detail { font: 12px var(--mono); opacity: .8; word-break: break-word; }
.notice { padding: 12px 14px; border-radius: var(--r); background: var(--accent-soft); color: var(--fg); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- pesquisa ---------- */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.report-head { padding: 18px 20px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.report-title { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.report-title h2 { font-size: 19px; font-weight: 650; }
.decision { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; padding: 14px 16px; border-radius: 9px; background: var(--surface-2); }
.decision .verdict { font: 600 12.5px var(--mono); letter-spacing: .04em; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.verdict.prospectar { background: var(--ok); color: var(--surface); }
.verdict.validar { background: var(--warn); color: var(--surface); }
.verdict.nao { background: var(--fg-3); color: var(--surface); }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fact { padding: 16px 20px; border-left: 1px solid var(--line); display: grid; gap: 6px; align-content: start; min-width: 0; }
.fact:first-child { border-left: 0; }
.fact .tag { margin-bottom: 2px; }
.fact .val { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fact .basis { color: var(--fg-2); font-size: 13px; }
.fact a { word-break: break-all; }
@media (max-width: 900px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fact:nth-child(3) { border-left: 0; }
  .fact:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 520px) {
  .facts { grid-template-columns: 1fr; }
  .fact { border-left: 0; border-top: 1px solid var(--line); }
  .fact:first-child { border-top: 0; }
}
.report-body { padding: 16px 20px 20px; display: grid; gap: 18px; border-top: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--fg-3); }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; } }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.reasons { margin: 0; padding-left: 18px; color: var(--fg-2); display: grid; gap: 2px; }
.cands { display: grid; gap: 6px; }
.cands button { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.cands button:hover { border-color: var(--accent); }
.rules { color: var(--fg-3); font-size: 12.5px; }
.rules summary { cursor: pointer; color: var(--fg-2); }
.rules ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 3px; }

/* ---------- gaveta (ficha do lead) ---------- */
.drawer-scrim, .modal-scrim { position: fixed; inset: 0; background: rgba(10, 12, 16, .38); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--bg); z-index: 41; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } }
.drawer-head { padding: calc(env(safe-area-inset-top, 0px) + 16px) 20px 14px; border-bottom: 1px solid var(--line); background: var(--surface); display: grid; gap: 10px; }
.drawer-head .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.drawer-head h2 { font-size: 18px; font-weight: 650; }
.drawer-body { overflow-y: auto; padding: 18px 20px calc(env(safe-area-inset-bottom, 0px) + 28px); display: grid; gap: 22px; align-content: start; }
.panel { display: grid; gap: 10px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }
.contact-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.copy { border: 0; background: none; color: var(--fg-3); cursor: pointer; padding: 2px 4px; border-radius: 4px; font-size: 12px; }
.copy:hover { color: var(--fg); background: var(--surface-2); }
.timeline { display: grid; gap: 0; border-left: 1px solid var(--line-strong); margin-left: 6px; }
.tl-item { position: relative; padding: 0 0 14px 18px; display: grid; gap: 2px; }
.tl-item::before { content: ""; position: absolute; left: -5px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--fg-3); }
.tl-item:first-child::before { border-color: var(--accent); }
.tl-item .when { font: 500 12px var(--mono); color: var(--fg-3); display: flex; gap: 8px; align-items: center; }
.tl-item .del { margin-left: auto; opacity: 0; }
.tl-item:hover .del { opacity: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; }
.save-hint { font-size: 12px; color: var(--fg-3); }

/* ---------- modal e toast ---------- */
.modal-scrim { display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px; display: grid; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.usage-table th, .usage-table td { padding: 7px 4px; border-top: 1px solid var(--line); text-align: left; }
.usage-table td.n { font-family: var(--mono); text-align: right; white-space: nowrap; }
.bar { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow-lg); font-weight: 500; max-width: calc(100% - 32px); }

@media (max-width: 420px) {
  .brand > span:not(.brand-mark) { display: none; }
}
@media (max-width: 600px) {
  .topbar-in { gap: 6px; }
  .brand em { display: none; }
  .tabs { gap: 0; }
  .tabs a { padding: 0 7px; }
  .tabs a.on::after { left: 7px; right: 7px; }
  .usage-pill { padding: 4px 8px; }
  .usage-pill .txt, .usage-pill .cnt { display: none; }
  .hide-sm { display: none; }
  .wrap { padding-top: 20px; gap: 22px; }
}
