:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --text: #17201b;
  --muted: #66736c;
  --line: #dfe5e1;
  --soft: #eef3f0;
  --primary: #177245;
  --primary-2: #1e8f57;
  --wa: #22c55e;
  --hot: #e5484d;
  --warm: #f59e0b;
  --cold: #7c8b93;
  --done: #16a34a;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1412;
  --panel: #161d1a;
  --text: #e6ece8;
  --muted: #93a19a;
  --line: #27322d;
  --soft: #1d2622;
  --primary: #1f9d60;
  --primary-2: #27b56f;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-2); }
.muted { color: var(--muted); }

.app { display: grid; grid-template-columns: 360px 1fr; height: 100vh; }

/* ---------- barra lateral ---------- */
.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: -.2px; }
.brand p { margin: 0; font-size: 11px; color: var(--muted); }
.icon-btn { border: 1px solid var(--line); background: var(--soft); border-radius: 10px; width: 34px; height: 34px; cursor: pointer; }

.block { padding: 4px 14px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.row input[type=range] { flex: 1; accent-color: var(--primary); }
#radiusLabel { min-width: 48px; }

input:not([type=checkbox]):not([type=range]), select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 9px;
  padding: 8px 10px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary-2); }
.row select { width: auto; flex: 1; }

.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 0; border-radius: 9px; padding: 9px 12px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-weight: 500; }
.btn.ghost:hover { border-color: var(--primary-2); color: var(--text); }
.btn.wa { background: var(--wa); color: #fff; }
.btn.wa:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.line { background: var(--soft); border: 1px solid var(--line); font-weight: 500; }

.check { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px 14px 4px; }
.tab { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 7px; cursor: pointer; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.tools { flex-direction: row; }
.tools .btn { flex: 1; font-size: 12px; }

.summary { padding: 6px 14px 2px; font-size: 12px; }
.summary b { color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.chip:hover { border-color: var(--primary-2); }
.chip.toggle input { display: none; }
.chip.toggle:has(input:checked) { background: var(--soft); border-color: var(--primary-2); color: var(--primary-2); font-weight: 600; }
.chip.warn:has(input:checked) { border-color: var(--warm); color: var(--warm); }
.filters { padding-bottom: 8px; border-bottom: 1px solid var(--line); }

.list { flex: 1 0 auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.card {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel);
  box-shadow: var(--shadow); cursor: pointer; transition: border-color .15s;
}
.card:hover, .card.sel { border-color: var(--primary-2); }
.card.sel { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-2) 25%, transparent); }
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-name { font-weight: 700; flex: 1; }
.card-addr { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status-pill { font-size: 11px; background: var(--soft); border-radius: 999px; padding: 2px 8px; color: var(--muted); }

.temp { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.temp.quente { background: color-mix(in srgb, var(--hot) 15%, transparent); color: var(--hot); }
.temp.morno { background: color-mix(in srgb, var(--warm) 18%, transparent); color: #b45309; }
:root[data-theme="dark"] .temp.morno { color: var(--warm); }
.temp.frio { background: color-mix(in srgb, var(--cold) 18%, transparent); color: var(--cold); }
.score { font-size: 11px; color: var(--muted); font-weight: 600; }

.foot { font-size: 11px; padding: 8px 14px; border-top: 1px solid var(--line); }

/* ---------- área principal ---------- */
.main { position: relative; overflow: hidden; }
.view { display: none; height: 100%; }
.view.active { display: block; }
#map { height: 100%; width: 100%; }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }
.leaflet-popup-content { font-size: 13px; }
.leaflet-popup-content b { font-size: 14px; }
.popup-actions { display: flex; gap: 6px; margin-top: 8px; }

/* Kanban */
.kanban { display: flex; gap: 12px; padding: 16px; height: 100%; overflow-x: auto; }
.col { background: var(--soft); border: 1px solid var(--line); border-radius: 12px; min-width: 250px; width: 250px; display: flex; flex-direction: column; max-height: 100%; }
.col h3 { margin: 0; padding: 10px 12px; font-size: 13px; display: flex; justify-content: space-between; }
.col-body { padding: 0 10px 10px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col.over { outline: 2px dashed var(--primary-2); }
.kcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: grab; font-size: 13px; }
.kcard .card-addr { margin-bottom: 4px; }
.kcard.dragging { opacity: .5; }

/* Painel */
.panel { padding: 24px; overflow-y: auto; height: 100%; }
.panel h2 { margin: 0 0 16px; }
.panel h3 { margin: 28px 0 10px; font-size: 15px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.kpi .v { font-size: 26px; font-weight: 700; }
.kpi .l { font-size: 12px; color: var(--muted); }
.funnel { display: flex; flex-direction: column; gap: 8px; max-width: 700px; }
.fbar { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 10px; font-size: 13px; }
.fbar .track { background: var(--soft); border-radius: 6px; height: 20px; overflow: hidden; }
.fbar .fill { background: var(--primary-2); height: 100%; border-radius: 6px; }
table.simple { border-collapse: collapse; width: 100%; max-width: 800px; font-size: 13px; }
table.simple th, table.simple td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.simple th { color: var(--muted); font-weight: 600; }

/* Modal */
dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(560px, 94vw);
  background: var(--panel); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
.m-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.m-head h2 { margin: 0; font-size: 16px; }
.m-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow-y: auto; }
.m-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.close { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
textarea { resize: vertical; min-height: 110px; }
.preview { background: #e7fbe9; color: #0f2a17; border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; font-size: 13px; }
:root[data-theme="dark"] .preview { background: #173323; color: #dff5e5; }
.hint { font-size: 12px; color: var(--muted); }
.hist-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--panel); padding: 10px 16px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 9999; font-size: 13px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 60vh; height: auto; }
  .side { max-height: none; overflow: visible; }
  .list { max-height: 60vh; }
  .main { height: 60vh; }
}

/* Respostas prontas nos Detalhes */
.followups { display: flex; flex-direction: column; gap: 6px; }
.fu { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.fu summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.fu[open] summary { margin-bottom: 8px; }
.fu .btn { margin-top: 8px; }

/* Trava de WhatsApp no modo disparo */
.btn.blocked { opacity: .45; }
.warnbox { background: color-mix(in srgb, var(--warm) 14%, transparent); border-radius: 8px; padding: 8px 10px; }

/* Instagram */
.btn.ig { background: linear-gradient(45deg, #f09433, #dc2743 50%, #bc1888); color: #fff; }
#igBatchBtn { margin-top: 6px; font-size: 12px; }

/* Análise do site */
.sitecheck { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.sitecheck ul { margin: 4px 0 8px; padding-left: 18px; }
.sitecheck li { margin-bottom: 4px; }

/* Passo a passo do Instagram */
.steps { margin: 0 0 6px; padding-left: 20px; font-size: 13px; }
.steps li { margin-bottom: 4px; }

/* Site demo */
.sitecheck.demo a { word-break: break-all; }

/* Projeção do mês */
.proj-sub{margin:-4px 0 16px;font-size:14px}
.kpi .v small{font-size:14px;color:var(--muted);font-weight:500;margin-left:2px}
.goal{margin:18px 0 6px;max-width:700px}
.goal-top{display:flex;justify-content:space-between;gap:10px;font-size:14px;margin-bottom:8px}
.goal .track{background:var(--soft);border-radius:8px;height:14px;overflow:hidden}
.goal .fill{background:var(--primary-2);height:100%;border-radius:8px;min-width:4px}
table.proj{margin-top:16px}
table.proj tr.pace td{background:var(--soft);font-weight:600}

/* Meta do mês */
.goal-card{background:linear-gradient(135deg,color-mix(in srgb,var(--primary) 14%,var(--panel)),var(--panel));border:1px solid color-mix(in srgb,var(--primary) 30%,var(--line));border-radius:18px;padding:22px 24px;margin:4px 0 26px;max-width:920px;box-shadow:var(--shadow)}
.goal-card.won{border-color:#E0B341;background:linear-gradient(135deg,rgba(224,179,65,.18),var(--panel))}
.goal-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px}
.goal-eye{font-size:12px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--primary-2)}
.goal-head h3{margin:6px 0 0;font-size:22px}
.goal-pct{text-align:right}
.goal-pct b{display:block;font-size:40px;line-height:1;font-weight:800;color:var(--primary-2)}
.goal-card.won .goal-pct b{color:#E0B341}
.goal-pct span{font-size:13px;color:var(--muted);font-weight:600}
.goal-bar{position:relative;height:22px;border-radius:999px;background:var(--soft);overflow:hidden;margin:18px 0 10px;display:flex}
.goal-fill{height:100%;background:linear-gradient(90deg,var(--primary),var(--primary-2));border-radius:999px;transition:width 1s cubic-bezier(.2,.7,.1,1);min-width:6px}
.goal-extra{position:absolute;right:0;top:0;bottom:0;background:repeating-linear-gradient(45deg,#E0B341 0 10px,#F2CF6B 10px 20px);opacity:.9}
.goal-bar i{position:absolute;top:4px;bottom:4px;width:2px;background:rgba(255,255,255,.55);border-radius:2px}
.goal-levels{display:flex;justify-content:space-between;gap:6px;font-size:11.5px;color:var(--muted);flex-wrap:wrap}
.goal-levels span{opacity:.45}
.goal-levels span.on{opacity:1;font-weight:700;color:var(--text)}
.goal-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:18px}
.goal-stats div{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px 14px}
.goal-stats b{display:block;font-size:22px}
.goal-stats small{color:var(--muted);font-size:12.5px}
.goal-pace{margin:14px 0 0;font-size:14px;color:var(--muted)}
.goal-pace b{color:var(--text)}
@media (max-width:640px){.goal-stats{grid-template-columns:1fr}.goal-pct b{font-size:32px}.goal-levels span:not(.on){display:none}}

.hint.hot,.hot{color:#16a34a;font-weight:600}
.hint.due{color:#d97706;font-weight:600}
