@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0c0d12;
  --bg2: #0f1117;
  --card: #15171f;
  --card2: #1b1e27;
  --border: #262a35;
  --border2: #313644;
  --text: #eceef3;
  --muted: #9aa1b0;
  --muted2: #646b7c;
  --green: #22c55e;
  --green-bg: rgba(34,197,94,.14);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,.14);
  --amber: #f59e0b;
  --amber-bg: rgba(245,158,11,.14);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,.14);
  --violet: #8b5cf6;
  --violet-bg: rgba(139,92,246,.14);
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --glow: 0 0 0 1px rgba(255,255,255,.02), 0 8px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html { background: radial-gradient(1400px 950px at 50% 42%, #0a1733, #04070f 72%); }
/* globo 3D interativo no canto */
#globe-box {
  position: fixed; right: 18px; bottom: 18px;
  width: 420px; height: 420px; z-index: 60;
  border-radius: 16px; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #0a1733, #05070d);
  border: 1px solid var(--border2); box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
#globe-box.collapsed { height: 38px; }
#globe-box.collapsed #globe-canvas { display: none; }
#globe-box .globe-label {
  position: absolute; top: 9px; left: 12px; z-index: 2;
  font-size: 12px; font-weight: 700; color: #cfe0ff;
  background: rgba(8,12,22,.55); padding: 4px 10px; border-radius: 8px; pointer-events: none;
}
#globe-box .globe-min {
  position: absolute; top: 9px; right: 10px; z-index: 3; cursor: pointer;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  color: #cfe0ff; background: rgba(8,12,22,.55); border-radius: 6px; font-weight: 700; line-height: 1;
}
#globe-canvas { width: 420px; height: 420px; }
/* modo ampliado (duplo-clique) */
#globe-box.expanded { inset: 0; right: auto; bottom: auto; width: 100vw; height: 100vh; border-radius: 0; z-index: 200; }
#globe-box.expanded #globe-canvas { width: 100vw; height: 100vh; }
#globe-box .globe-hint { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted2); pointer-events: none; }
#globe-fab { position: fixed; right: 18px; bottom: 448px; z-index: 201; width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; cursor: pointer; background: var(--card2); border: 1px solid var(--border2); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
#globe-fab:hover { background: #232732; }
@media (max-width: 880px) { #globe-box { display: none; } }
#view-banner { background: linear-gradient(90deg, #6a5cff, #2b6fff); color: #fff; text-align: center; padding: 8px; font-size: 13px; position: relative; z-index: 80; }
#view-banner a { color: #fff; text-decoration: underline; font-weight: 600; }

/* ===== menu lateral (sidebar) ===== */
#nx-sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 212px; background: linear-gradient(180deg, #11141d, #0b0d14); border-right: 1px solid var(--border); padding: 16px 12px; overflow-y: auto; z-index: 70; }
#nx-sidebar .brand { font-family: 'Space Grotesk', sans-serif; font-size: 23px; font-weight: 700; padding: 8px 10px 22px; letter-spacing: -.02em; background: linear-gradient(90deg, #cfe0ff, #8b5cf6); -webkit-background-clip: text; background-clip: text; color: transparent; }
#nx-sidebar a { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; margin-bottom: 3px; transition: all .15s; }
#nx-sidebar a i { font-style: normal; font-size: 17px; width: 20px; text-align: center; }
#nx-sidebar a:hover { background: var(--card2); color: var(--text); }
#nx-sidebar a.active { background: var(--violet-bg); color: #c7b8ff; }
#nx-sidebar a.sair { margin-top: 16px; color: #fca5a5; }
body.has-sidebar { padding-left: 212px; }
body.has-sidebar .topbar .actions a.btn { display: none !important; }
#nx-sidebar .brand::before { content: '◆'; margin-right: 8px; -webkit-text-fill-color: #8b5cf6; }

/* estados vazios */
.muted[colspan], td.muted, .empty { text-align: center; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted2); }
.empty-state .ico { font-size: 40px; opacity: .5; display: block; margin-bottom: 10px; }

/* toasts */
#nx-toasts { position: fixed; bottom: 20px; right: 20px; z-index: 400; display: flex; flex-direction: column; gap: 10px; }
.nx-toast { background: var(--card2); border: 1px solid var(--border2); border-left: 3px solid var(--green); color: var(--text); padding: 12px 18px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.45); font-size: 14px; font-weight: 500; animation: toastIn .25s ease; max-width: 320px; }
.nx-toast.err { border-left-color: var(--red); }
.nx-toast.out { opacity: 0; transform: translateX(20px); transition: all .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@media (max-width: 880px) {
  #nx-sidebar { width: 58px; padding: 14px 8px; }
  #nx-sidebar .brand { font-size: 0; padding: 8px 0 16px; }
  #nx-sidebar a span { display: none; }
  #nx-sidebar a { justify-content: center; gap: 0; }
  body.has-sidebar { padding-left: 58px; }
}
body {
  margin: 0;
  background: transparent;
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
}
a { color: inherit; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; gap: 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(15,17,23,.6);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-family: 'Space Grotesk', sans-serif; font-size: 25px; margin: 0; display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; }
.topbar .sub { color: var(--muted); margin: 3px 0 0; font-size: 13px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px;
  border: 1px solid var(--border2); background: var(--card2); border-radius: 10px;
  font-size: 13.5px; font-weight: 500; cursor: pointer; text-decoration: none; color: var(--text);
  transition: all .15s ease;
}
.btn:hover { background: #232732; border-color: #3a4150; }
.btn.active { background: var(--violet-bg); border-color: var(--violet); color: #c7b8ff; }
.btn.small { padding: 6px 11px; font-size: 12.5px; }
.btn.wa { background: #1f3d2e; color: #4ade80; border-color: #2c5a43; margin-top: 7px; }
.btn.wa:hover { background: #245038; }

.wrap { padding: 20px 28px 48px; max-width: 1320px; margin: 0 auto; }

.section-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted2); margin: 24px 0 12px; display: flex; align-items: center; gap: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; box-shadow: 0 0 8px var(--green); }
.dot.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* período / abas */
.tabs { display: flex; gap: 6px; }

.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.cards.four { grid-template-columns: repeat(4, 1fr); }
.metric {
  background: linear-gradient(160deg, rgba(139,92,246,.08), var(--card2) 45%, var(--card));
  border: 1px solid var(--border); border-radius: 16px;
  padding: 20px 22px; box-shadow: var(--glow);
}
.metric .label {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); display: flex; align-items: center; gap: 7px;
}
.metric { position: relative; overflow: hidden; transition: transform .15s, border-color .15s; }
.metric::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--violet), var(--blue)); opacity: .7; }
.metric.green::before { background: linear-gradient(90deg, #16a34a, #4ade80); }
.metric.red::before { background: linear-gradient(90deg, #dc2626, #f87171); }
.metric:hover { transform: translateY(-3px); border-color: var(--border2); }
.metric .value { font-family: 'Space Grotesk', sans-serif; font-size: 38px; font-weight: 700; margin-top: 10px; letter-spacing: -.03em; }
.metric.green .value { color: var(--green); }
.metric.red .value { color: var(--red); }
.metric.violet .value { color: #a78bfa; }

/* funil de conversão */
.funnel { display: flex; flex-direction: column; gap: 10px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--glow); }
.funnel .step { }
.funnel .step .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.funnel .step .top .n { font-weight: 600; }
.funnel .step .top .pct { color: var(--muted); }
.funnel .bar { height: 26px; background: var(--card2); border-radius: 8px; overflow: hidden; }
.funnel .bar > span { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--violet), var(--blue)); transition: width .5s ease; }

/* pessoas no funil */
.people { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.person {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--glow); cursor: pointer; transition: border-color .15s;
}
.person:hover { border-color: var(--border2); }
.person .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.badge { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 7px; }
.badge.nav { background: var(--blue-bg); color: #93c5fd; }
.badge.pago { background: var(--green-bg); color: #6ee7a0; }
.badge.pix { background: var(--amber-bg); color: #fcd34d; }
.person .ago { font-size: 12px; color: var(--muted2); }
.person .geo { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.person .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.person .item .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted2); display: flex; align-items: center; gap: 5px; }
.person .item .v { font-size: 14px; margin-top: 2px; min-height: 18px; color: var(--text); }
.person .item .v.empty { color: #3b414f; }
.person .prod { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border2); font-size: 13px; color: var(--muted); }
.person .addr { margin-top: 8px; font-size: 13px; color: var(--muted); }
.person .src { margin-top: 8px; font-size: 11.5px; color: var(--violet); }
.updated { font-size: 12px; color: var(--muted2); }

/* tabela */
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 14px; box-shadow: var(--glow); }
thead th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted2); padding: 13px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: rgba(255,255,255,.012); }
tbody tr:hover { background: rgba(139,92,246,.06); }
.cli-nome { font-weight: 600; }
.cli-email { font-size: 12px; color: var(--muted2); }
.tel { color: #6ee7a0; }
.status { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 7px; display: inline-flex; align-items: center; gap: 5px; }
.status.pago { background: var(--green-bg); color: #6ee7a0; }
.status.pendente { background: var(--amber-bg); color: #fcd34d; }
.status.cancelado { background: var(--red-bg); color: #fca5a5; }
.muted { color: var(--muted2); }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--glow); padding: 34px; width: 100%; max-width: 370px; }
.login-card h1 { font-size: 23px; margin: 0 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login-card input { width: 100%; padding: 13px 15px; border: 1px solid var(--border2); border-radius: 11px; font-size: 15px; margin-bottom: 12px; background: var(--bg2); color: var(--text); }
.login-card input::placeholder { color: var(--muted2); }
.login-card button { width: 100%; padding: 13px; background: linear-gradient(90deg, var(--violet), var(--blue)); color: #fff; border: none; border-radius: 11px; font-size: 15px; font-weight: 600; cursor: pointer; }
.login-card .err { color: var(--red); font-size: 13px; margin-bottom: 12px; min-height: 16px; }

/* modal jornada */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-bg.show { display: flex; }
.modal { background: var(--card); border: 1px solid var(--border2); border-radius: var(--radius); padding: 24px; max-width: 460px; width: 100%; box-shadow: var(--glow); max-height: 85vh; overflow:auto; }
.modal h3 { margin: 0 0 4px; }
.modal .close { float: right; cursor: pointer; color: var(--muted2); font-size: 20px; line-height: 1; }
.timeline { margin-top: 18px; border-left: 2px solid var(--border2); padding-left: 18px; }
.timeline .ev { position: relative; padding-bottom: 16px; }
.timeline .ev::before { content: ''; position: absolute; left: -25px; top: 3px; width: 11px; height: 11px; border-radius: 50%; background: var(--violet); box-shadow: 0 0 0 3px var(--card); }
.timeline .ev .s { font-weight: 600; font-size: 14px; }
.timeline .ev .t { font-size: 12px; color: var(--muted2); }

/* região ranking */
.rank { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--glow); }
.rank .r { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.rank .r:last-child { border-bottom: none; }
.rank .r .nm { flex: 1; font-size: 14px; }
.rank .r .ct { font-weight: 700; }
.rank .r .barwrap { flex: 2; height: 8px; background: var(--card2); border-radius: 6px; overflow: hidden; }
.rank .r .barwrap > span { display: block; height: 100%; background: linear-gradient(90deg, var(--violet), var(--blue)); }

@media (max-width: 880px) {
  .cards, .cards.four { grid-template-columns: repeat(2, 1fr); }
  .people { grid-template-columns: 1fr; }
  .wrap, .topbar { padding-left: 16px; padding-right: 16px; }
}
