* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary:        #1DB954;
  --primary-dark:   #158a3e;
  --primary-light:  #1ed760;
  --bg:             #121212;
  --surface:        #1e1e1e;
  --surface-2:      #282828;
  --surface-3:      #333333;
  --text:           #ffffff;
  --text-secondary: #b3b3b3;
  --muted:          #6a6a6a;
  --border:         #2a2a2a;
  --success:        #1DB954;
  --warning:        #f59b23;
  --error:          #e91429;
  --radius-sm:      500px;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow-xs:      0 1px 4px rgba(0,0,0,.4);
  --shadow-sm:      0 2px 16px rgba(0,0,0,.5);
  --shadow:         0 4px 28px rgba(0,0,0,.6);
  --shadow-lg:      0 12px 48px rgba(0,0,0,.7);
  --shadow-primary: 0 8px 28px rgba(29,185,84,.4);
  --grad-primary:   linear-gradient(135deg, #1DB954 0%, #158a3e 100%);
  --grad-accent:    linear-gradient(135deg, #1DB954 0%, #158a3e 100%);
  --grad-success:   linear-gradient(135deg, #1DB954 0%, #1ed760 100%);
  --glass:          rgba(30,30,30,.98);
  --glass-border:   rgba(60,60,60,.6);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Login ─────────────────────────────────────────────────────────────────── */

#telaLogin {
  min-height: 100vh;
  min-height: 100dvh;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  padding-top: calc(24px + env(safe-area-inset-top));
  position: relative;
  overflow: hidden;
}

#telaLogin::before {
  content: '';
  position: absolute;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(29,185,84,.18) 0%, transparent 70%);
  top: -120px; left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

#telaLogin::after {
  content: '';
  position: absolute;
  width: 280px; height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(29,185,84,.08) 0%, transparent 70%);
  bottom: -60px; right: -60px;
  pointer-events: none;
}

.login-wrap {
  width: 100%;
  max-width: 340px;
  position: relative;
  z-index: 1;
}

.login-logo  { text-align: center; margin-bottom: 20px; }

.login-title {
  color: var(--text);
  font-size: 1.8rem;
  font-weight: 900;
  text-align: center;
  letter-spacing: -.5px;
}

.login-sub {
  color: var(--text-secondary);
  text-align: center;
  font-size: .9rem;
  margin-top: 8px;
}

.login-wrap .card {
  margin-top: 32px;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

/* ── App shell ─────────────────────────────────────────────────────────────── */

#telaApp { min-height: 100vh; min-height: 100dvh; }

/* ── Conn bar ──────────────────────────────────────────────────────────────── */

.conn-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .8rem;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.conn-bar span { font-weight: 600; color: var(--text-secondary); }

/* ── Header (home) ─────────────────────────────────────────────────────────── */

header {
  background: var(--bg);
  color: var(--text);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: -.4px;
  color: var(--text);
}

/* ── Header back ───────────────────────────────────────────────────────────── */

.header-back {
  background: var(--bg);
  color: var(--text);
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.header-back h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Container ─────────────────────────────────────────────────────────────── */

.container {
  padding: 20px 16px;
  max-width: 480px;
  margin: 0 auto;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

.card::before { display: none; }

.card h2 {
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: -.1px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* ── Labels ────────────────────────────────────────────────────────────────── */

label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* ── Inputs ────────────────────────────────────────────────────────────────── */

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 16px 18px;
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 4px;
  font-size: .98rem;
  outline: none;
  color: var(--text);
  -webkit-appearance: none;
  font-family: inherit;
  transition: border-color .2s, background .2s;
}

input::placeholder { color: var(--muted); }

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  background: var(--surface-3);
  border-color: var(--primary);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 20px;
  border: none;
  border-radius: 500px;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: transform .1s, background .15s, box-shadow .15s;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--primary);
  color: #000000;
  font-weight: 900;
  box-shadow: var(--shadow-primary);
}

.btn-primary:active { background: var(--primary-light); }

.btn-accent {
  background: var(--primary);
  color: #000000;
  font-weight: 900;
  box-shadow: var(--shadow-primary);
}

.btn-accent:active { background: var(--primary-light); }

.btn-success {
  background: var(--primary);
  color: #000000;
  font-weight: 900;
  box-shadow: var(--shadow-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--surface-3);
  flex: 1;
}

.btn-ghost:active { border-color: var(--text); background: rgba(255,255,255,.05); }

/* ── Coords box ────────────────────────────────────────────────────────────── */

.coords-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px 16px;
  font-size: .85rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  margin: 12px 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  letter-spacing: .2px;
  line-height: 1.5;
}

/* ── Status messages ───────────────────────────────────────────────────────── */

.status-msg {
  text-align: center;
  font-size: .85rem;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 4px;
  margin-top: 12px;
  animation: slideUp .2s ease;
}

.status-msg.ok      { background: rgba(29,185,84,.15); color: var(--primary-light); border: 1px solid rgba(29,185,84,.3); }
.status-msg.erro    { background: rgba(233,20,41,.15);  color: #ff4d63;              border: 1px solid rgba(233,20,41,.3); }
.status-msg.offline { background: rgba(245,155,35,.15); color: #f59b23;              border: 1px solid rgba(245,155,35,.3); }
.status-msg.info    { background: rgba(255,255,255,.06); color: var(--text-secondary); border: 1px solid var(--border); }

/* ── Badges ────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 500px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.badge-offline { background: rgba(233,20,41,.2);  color: #ff4d63;         border: 1px solid rgba(233,20,41,.3); }
.badge-online  { background: rgba(29,185,84,.2);   color: var(--primary);  border: 1px solid rgba(29,185,84,.3); }

/* ── Logout button ─────────────────────────────────────────────────────────── */

.btn-logout {
  background: transparent;
  border: 2px solid var(--surface-3);
  color: var(--text-secondary);
  border-radius: 500px;
  padding: 6px 14px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  font-family: inherit;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.btn-logout:hover  { border-color: var(--text); color: var(--text); }
.btn-logout:active { transform: scale(.95); }

/* ── Back button ───────────────────────────────────────────────────────────── */

.btn-back {
  background: transparent;
  border: 2px solid var(--surface-3);
  color: var(--text);
  border-radius: 500px;
  padding: 7px 14px;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  transition: border-color .15s;
  font-family: inherit;
  white-space: nowrap;
}

.btn-back:active { border-color: var(--text); transform: scale(.96); }

/* ── FAB ───────────────────────────────────────────────────────────────────── */

.fab {
  position: fixed;
  bottom: calc(28px + env(safe-area-inset-bottom));
  right: 22px;
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--primary);
  color: #000;
  font-size: 1.7rem;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: transform .15s, background .15s;
  font-family: inherit;
  font-weight: 900;
}

.fab::before { display: none; }

.fab:active {
  transform: scale(.9);
  background: var(--primary-light);
}

/* ── Pages ─────────────────────────────────────────────────────────────────── */

.pagina { display: none; }

.pagina.ativa {
  display: block;
  animation: pageIn .2s ease;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Mapa geral e individual ───────────────────────────────────────────────── */

#paginaMapaGeral.ativa,
#paginaMapa.ativa {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

#mapaGeralContainer,
#mapaContainer {
  flex: 1;
  min-height: 0;
  width: 100%;
}

.mapa-rodape {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.mapa-coords {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .76rem;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Histórico ─────────────────────────────────────────────────────────────── */

.historico-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  animation: slideUp .18s ease;
}

.historico-item:last-child { border-bottom: none; }
.historico-login  { font-weight: 700; color: var(--text);          font-size: .95rem; }
.historico-coords { color: var(--muted); font-family: 'SF Mono','Fira Code',monospace; font-size: .75rem; margin-top: 3px; }
.historico-hora   { color: var(--muted); white-space: nowrap; font-size: .75rem; }

/* ── Busca resultados ──────────────────────────────────────────────────────── */

#buscaResultados { margin-top: 14px; }

.busca-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  animation: slideUp .18s ease;
}

.busca-item:last-child { border-bottom: none; }
.busca-info { flex: 1; min-width: 0; }
.busca-data { font-size: .74rem; color: var(--muted); margin-top: 4px; }

/* ── Ação buttons ──────────────────────────────────────────────────────────── */

.btn-acao {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: none;
  border-radius: 500px;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .1s, opacity .15s;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.btn-acao:active { transform: scale(.94); opacity: .8; }

.btn-acao-editar  { background: var(--surface-3); color: var(--text); border: 1px solid var(--surface-3); }
.btn-acao-editar:active { background: #444; }
.btn-acao-remover { background: rgba(233,20,41,.15); color: #ff4d63; border: 1px solid rgba(233,20,41,.25); }

/* ── Maps button ───────────────────────────────────────────────────────────── */

.btn-maps {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 20px;
  background: var(--primary);
  color: #000;
  border-radius: 500px;
  font-size: .82rem;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: var(--shadow-primary);
  text-transform: uppercase;
  letter-spacing: .05em;
  transition: background .15s, transform .1s;
}

.btn-maps:active { background: var(--primary-light); transform: scale(.97); }

/* ── Login clicável na busca ───────────────────────────────────────────────── */

.busca-login-btn {
  background: none;
  border: none;
  padding: 0;
  font-weight: 700;
  font-size: .95rem;
  color: var(--primary);
  cursor: pointer;
  text-align: left;
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .15s;
  font-family: inherit;
}

.busca-login-btn::after { content: ' 📍'; font-size: .78rem; opacity: .55; }
.busca-login-btn:active { color: var(--primary-light); }

/* ── Ver mapa btn ──────────────────────────────────────────────────────────── */

#btnVerMapa {
  background: var(--primary);
  color: #000;
  font-weight: 900;
  border-radius: 500px;
  box-shadow: var(--shadow-primary);
  font-size: .9rem;
}

#btnVerMapa:active { background: var(--primary-light); }

/* ── Marcador no mapa ──────────────────────────────────────────────────────── */

.ml-dot {
  display: inline-block;
  width: 12px; height: 12px;
  background: var(--primary);
  border-radius: 50%;
  border: 2px solid #121212;
  box-shadow: 0 2px 6px rgba(29,185,84,.5);
  vertical-align: middle;
  flex-shrink: 0;
}

.ml-text {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  vertical-align: middle;
  text-shadow:
    -1px -1px 0 #000,  1px -1px 0 #000,
    -1px  1px 0 #000,  1px  1px 0 #000;
}

/* ── Leaflet tooltip ───────────────────────────────────────────────────────── */

.leaflet-tooltip {
  padding: 3px 8px !important;
  font-size: .72rem !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
  background: #1e1e1e !important;
  border: 1px solid rgba(29,185,84,.4) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.4) !important;
  border-radius: 4px !important;
  color: var(--primary) !important;
}

.leaflet-tooltip::before { display: none !important; }

/* ── Spin ──────────────────────────────────────────────────────────────────── */

.spin { animation: spin .8s linear infinite; display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Wrapper do mapa ───────────────────────────────────────────────────────── */

.mapa-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.mapa-wrapper #mapaGeralContainer { height: 100%; width: 100%; }

/* ── Crosshair ─────────────────────────────────────────────────────────────── */

.mapa-crosshair {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 48px; height: 48px;
  pointer-events: none;
  z-index: 500;
}

.ch-v {
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 2px;
  background: var(--primary);
  transform: translateX(-50%);
}

.ch-h {
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 2px;
  background: var(--primary);
  transform: translateY(-50%);
}

.ch-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 10px; height: 10px;
  background: var(--primary);
  border-radius: 50%;
  border: 2px solid #000;
  box-shadow: 0 0 0 1.5px var(--primary), 0 2px 6px rgba(0,0,0,.5);
}

/* ── FAB mapa ──────────────────────────────────────────────────────────────── */

.fab-mapa {
  position: absolute;
  bottom: 20px; right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #000;
  font-size: 1.5rem;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  transition: transform .15s, background .15s;
  font-family: inherit;
  font-weight: 900;
}

.fab-mapa:active { transform: scale(.9); background: var(--primary-light); }

/* ── Barra de ações ────────────────────────────────────────────────────────── */

.mapa-acoes-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 500;
}

.mapa-acoes-hint { font-size: .78rem; color: var(--muted); text-align: center; flex: 1; }

/* ── Bottom sheet ──────────────────────────────────────────────────────────── */

.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 600;
  display: flex;
  align-items: flex-end;
}

.bottom-sheet {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 8px 20px calc(24px + env(safe-area-inset-bottom));
  width: 100%;
  animation: slideUpSheet .25s cubic-bezier(.32,1,.5,1);
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  margin: 0 auto 20px;
}

.sheet-title  { font-size: 1rem; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ── Utilities ─────────────────────────────────────────────────────────────── */

.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }

/* ── Stats cards ───────────────────────────────────────────────────────────── */

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: background .15s, transform .12s;
  -webkit-user-select: none;
  user-select: none;
}

.stat-card:active {
  transform: scale(.97);
  background: var(--surface-3);
}

.stat-card-meus {
  background: rgba(29,185,84,.1);
  border-color: rgba(29,185,84,.25);
}

.stat-card-meus:active { background: rgba(29,185,84,.18); }

.stat-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.stat-num {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1.1;
  letter-spacing: -1px;
}

.stat-label {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .08em;
  text-align: center;
}

/* Ponto "meu" no mapa geral — cor diferente (branco para destacar no verde) */
.ml-dot-meu {
  background: #ffffff !important;
  box-shadow: 0 0 0 3px rgba(29,185,84,.6) !important;
  border-color: var(--primary) !important;
}
