/* Lead Extractor — direção "private banking": tinta azul-marinho, marfim quente, um único acento em latão. */
:root {
  --bg: #f3efe6;
  --surface: #fffdf8;
  --surface-2: #f8f4ea;
  --ink: #0e1726;
  --ink-2: #2b3648;
  --muted: #667085;
  --line: #e4ddcc;
  --line-strong: #d3cab3;
  --navy: #0a1220;
  --navy-2: #111b2f;
  --navy-line: #213049;
  --on-navy: #ede7d8;
  --on-navy-muted: #8f9bb0;
  --brass: #b08a3e;
  --brass-ink: #86661f;
  --brass-soft: rgba(176, 138, 62, 0.12);
  --primary-bg: #0a1220;
  --primary-ink: #f3ead3;
  --emerald: #1d7a58;
  --emerald-soft: rgba(29, 122, 88, 0.12);
  --danger: #b3261e;
  --danger-soft: rgba(179, 38, 30, 0.1);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 1px 2px rgba(20, 25, 40, 0.06), 0 12px 32px -18px rgba(20, 25, 40, 0.28);
  --radius: 14px;
  --radius-sm: 9px;
  --font-display: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-ui: 'Instrument Sans', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #080d17;
  --surface: #0f1829;
  --surface-2: #0b1322;
  --ink: #ece6d6;
  --ink-2: #c9c3b3;
  --muted: #8f9bb0;
  --line: #1c2840;
  --line-strong: #2a3a58;
  --navy: #060a13;
  --navy-2: #0c1424;
  --navy-line: #1a2740;
  --brass: #d4af63;
  --brass-ink: #dcbb78;
  --brass-soft: rgba(212, 175, 99, 0.13);
  --primary-bg: #d4af63;
  --primary-ink: #0a1220;
  --emerald: #4cc79a;
  --emerald-soft: rgba(76, 199, 154, 0.14);
  --danger: #ff8a80;
  --danger-soft: rgba(255, 138, 128, 0.13);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px -18px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font-ui);
  font-feature-settings: 'tnum' 1, 'cv11' 1;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--brass-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 1.15em; height: 1.15em; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ------------------------------------------------------------ topo */
.top {
  position: sticky; top: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 14px clamp(16px, 3vw, 36px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 60%),
    var(--navy);
  border-bottom: 1px solid var(--navy-line);
  color: var(--on-navy);
}
.top::after { /* fio de latão */
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass) 18%, var(--brass) 82%, transparent); opacity: 0.55;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  border: 1px solid var(--brass); color: var(--brass);
  font: italic 500 19px/1 var(--font-display);
  background: radial-gradient(circle at 30% 25%, rgba(212, 175, 99, 0.2), transparent 65%);
}
.wordmark { font: 500 21px/1 var(--font-display); letter-spacing: 0.005em; white-space: nowrap; }
.wordmark em { font-style: italic; color: var(--brass); font-weight: 400; }
.tagline { display: block; margin-top: 4px; font: 500 10px/1 var(--font-ui); letter-spacing: 0.2em; text-transform: uppercase; color: var(--on-navy-muted); }

.tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--navy-line); border-radius: 999px; background: rgba(255, 255, 255, 0.03); }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 8px 18px; border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--on-navy-muted); font-weight: 500; letter-spacing: 0.01em; transition: color .18s, background .18s;
}
.tab:hover { color: var(--on-navy); }
.tab[aria-selected='true'] { background: var(--brass); color: #0a1220; box-shadow: 0 6px 18px -8px var(--brass); }

.top-right { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--navy-line); color: var(--on-navy-muted); white-space: nowrap;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: #6b7487; }
.pill.ok i { background: #3fd6a1; box-shadow: 0 0 0 3px rgba(63, 214, 161, 0.18); }
.pill.off i { background: #e0675f; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--navy-line); background: transparent; color: var(--on-navy-muted); transition: .18s;
}
.icon-btn:hover { color: var(--brass); border-color: var(--brass); }

/* ------------------------------------------------------------ layout */
main { padding: clamp(16px, 2.4vw, 32px) clamp(16px, 3vw, 36px) 56px; max-width: 1760px; margin: 0 auto; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head h1 { margin: 0; font: 400 clamp(26px, 3vw, 36px)/1.05 var(--font-display); letter-spacing: -0.01em; }
.view-head h1 em { font-style: italic; color: var(--brass-ink); }
.view-head p { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
  padding: 16px 18px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 2px; background: var(--brass); border-radius: 2px; }
.kpi label { display: block; font: 600 10.5px/1 var(--font-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.kpi strong { display: block; margin: 10px 0 4px; font: 400 clamp(28px, 2.6vw, 36px)/1 var(--font-display); letter-spacing: -0.015em; font-variant-numeric: lining-nums tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }

.workspace { display: grid; grid-template-columns: minmax(300px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.panel {
  position: sticky; top: 92px; max-height: calc(100vh - 108px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
  scrollbar-width: thin;
}
.panel h2 { margin: 0 0 14px; font: 600 10.5px/1 var(--font-ui); letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.panel h2::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field > span b { font: 500 15px var(--font-display); color: var(--brass-ink); font-variant-numeric: tabular-nums; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
input[type='text'], input[type='search'], input[type='number'], select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input:focus, select:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
input[type='range'] { width: 100%; accent-color: var(--brass); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; transition: .16s; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--brass); color: var(--brass-ink); }
.btn.primary { background: var(--primary-bg); color: var(--primary-ink); border-color: var(--primary-bg); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.12); color: var(--primary-ink); }
.btn.gold { background: var(--brass); color: #0a1220; border-color: var(--brass); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.seg { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.seg button { flex: 1; padding: 7px 8px; border: 0; background: transparent; cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--muted); transition: .15s; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--surface); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--brass-soft); color: var(--brass-ink); border: 1px solid color-mix(in srgb, var(--brass) 35%, transparent); max-width: 100%;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: inherit; }
.chip button:hover { background: var(--brass-soft); }
.toggle-chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2); cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--muted); transition: .15s; }
.toggle-chip[aria-pressed='true'] { background: var(--brass-soft); color: var(--brass-ink); border-color: var(--brass); }

.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); max-height: 280px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: 0 18px 40px -16px rgba(10, 18, 32, 0.45);
}
.combo-list button { display: block; width: 100%; text-align: left; padding: 8px 12px; border: 0; background: transparent; cursor: pointer; font-size: 13px; }
.combo-list button:hover, .combo-list button:focus { background: var(--brass-soft); outline: none; }
.combo-list small { display: block; color: var(--muted); font-size: 11.5px; }
.combo-list .add-all { border-top: 1px solid var(--line); font-weight: 600; color: var(--brass-ink); }

.estimate { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--line-strong); font-size: 12.5px; color: var(--ink-2); margin-bottom: 14px; }
.estimate b { font: 500 17px var(--font-display); color: var(--ink); }
.progress { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 12px 0 6px; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brass), color-mix(in srgb, var(--brass) 60%, #fff)); transition: width .3s; }
.status { font-size: 12.5px; color: var(--muted); min-height: 18px; }
.status.err { color: var(--danger); }
.note { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin: 6px 0 0; }

/* ------------------------------------------------------------ palco / mapa / tabela */
.stage { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
#map { height: clamp(320px, 42vh, 500px); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; z-index: 1; }
.leaflet-container { font-family: var(--font-ui); background: var(--surface-2); }
.pin { width: 30px; height: 40px; filter: drop-shadow(0 6px 6px rgba(10, 18, 32, 0.4)); }
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.table-bar h3 { margin: 0; font: 400 20px var(--font-display); }
.table-bar h3 small { font: 500 12px var(--font-ui); color: var(--muted); margin-left: 8px; }
.bar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sel-bar { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: var(--brass-soft); border-bottom: 1px solid color-mix(in srgb, var(--brass) 30%, transparent); font-size: 13px; font-weight: 500; flex-wrap: wrap; }
.sel-bar .grow { flex: 1; }
.applied { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 18px 0; }
.scroll { overflow: auto; max-height: min(64vh, 720px); }
table { width: 100%; border-collapse: collapse; }
th {
  position: sticky; top: 0; z-index: 2; text-align: left; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line-strong);
  font: 600 10.5px/1.2 var(--font-ui); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--brass-ink); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--brass) 6%, transparent); }
tbody tr[aria-selected='true'] { background: var(--brass-soft); }
td.chk, th.chk { width: 40px; padding-right: 0; }
input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--brass); cursor: pointer; }
.name { font-weight: 600; color: var(--ink); }
.sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dim { color: var(--muted); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink-2); white-space: nowrap; }
.badge.gold { background: var(--brass-soft); border-color: color-mix(in srgb, var(--brass) 45%, transparent); color: var(--brass-ink); }
.badge.green { background: var(--emerald-soft); border-color: color-mix(in srgb, var(--emerald) 40%, transparent); color: var(--emerald); }
.star { color: var(--brass); }
.skel td > div { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--line), var(--surface-2), var(--line)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty h4 { margin: 14px 0 6px; font: 400 22px var(--font-display); color: var(--ink); }
.empty p { margin: 0 auto; max-width: 52ch; }
.empty code { display: inline-block; margin-top: 12px; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 8px; font: 12.5px ui-monospace, Consolas, monospace; color: var(--ink); user-select: all; }
.empty .ico { width: 36px; height: 36px; color: var(--brass); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.pager .row { flex: none; }

/* ------------------------------------------------------------ gaveta de detalhes */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(6, 10, 19, 0.45); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line-strong); box-shadow: -24px 0 60px -30px rgba(0, 0, 0, 0.55);
  transform: translateX(102%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
}
.drawer.open { transform: none; }
.drawer-head { padding: 22px 22px 18px; background: var(--navy); color: var(--on-navy); position: relative; }
.drawer-head::after { content: ''; position: absolute; left: 22px; right: 22px; bottom: 0; height: 1px; background: linear-gradient(90deg, var(--brass), transparent); }
.drawer-head h2 { margin: 0 36px 6px 0; font: 400 24px/1.15 var(--font-display); }
.drawer-head p { margin: 0; color: var(--on-navy-muted); font-size: 13px; }
.drawer-head .x { position: absolute; top: 16px; right: 16px; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 22px 28px; }
.sect { margin-bottom: 22px; }
.sect h4 { margin: 0 0 8px; font: 600 10.5px/1 var(--font-ui); letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.kv { display: grid; grid-template-columns: 22px 1fr auto; gap: 4px 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv .ico { color: var(--brass-ink); }
.kv .v { overflow-wrap: anywhere; }
.kv .v small { display: block; color: var(--muted); font-size: 11.5px; }
.kv .acts { display: flex; gap: 6px; }
.plain { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.plain span:first-child { color: var(--muted); }
.plain span:last-child { text-align: right; font-weight: 500; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; background: var(--surface-2); }

.toasts { position: fixed; z-index: 60; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 11px 18px; border-radius: 999px; background: var(--navy); color: var(--on-navy); border: 1px solid var(--brass); font-size: 13px; font-weight: 500;
  box-shadow: 0 16px 40px -14px rgba(0, 0, 0, 0.6); animation: rise .25s ease-out; max-width: min(90vw, 560px);
}
.toast.err { border-color: #e0675f; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* entrada orquestrada */
.reveal { animation: rise .55s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 70ms); }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; }
}
@media (max-width: 760px) {
  .top { grid-template-columns: 1fr auto; row-gap: 12px; }
  .tabs { grid-column: 1 / -1; order: 3; justify-content: stretch; }
  .tab { flex: 1; justify-content: center; }
  .tagline, .pill.hide-sm { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* mapa base (OSM) levemente dessaturado para combinar com a paleta */
.leaflet-tile-pane { filter: grayscale(0.4) sepia(0.14) contrast(0.96) brightness(1.02); }
:root[data-theme='dark'] .leaflet-tile-pane { filter: grayscale(0.5) invert(0.92) hue-rotate(180deg) contrast(0.9) brightness(0.95); }
