:root {
  --primary: #4A90D9;
  --primary-dark: #3A7BC8;
  --secondary: #FF6B6B;
  --bg: #F8F9FA;
  --bg-dark: #1A1D23;
  --success: #27AE60;
  --alert: #E74C3C;
  --text: #2C3E50;
  --text-light: #7F8C8D;
  --card: #FFFFFF;
  --shadow: 0 2px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --bottom-bar-h: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
  position: fixed;
  -webkit-font-smoothing: antialiased;
}

#map {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: calc(var(--bottom-bar-h) + var(--safe-bottom));
  z-index: 1;
}

/* ===== TOP BAR ===== */
.top-bar {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
.top-bar > * { pointer-events: auto; }

.app-version {
  position: fixed;
  bottom: calc(var(--bottom-bar-h) + var(--safe-bottom) + 2px);
  right: 8px;
  z-index: 1000;
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.35);
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 16px;
  font-family: sans-serif;
  pointer-events: none;
}
/* On setup screen, bottom bar is hidden so position lower */
#setup-screen:not(.hidden) ~ .app-version {
  bottom: 8px;
  color: rgba(255,255,255,0.5);
}

.group-badge {
  background: var(--card);
  border-radius: 24px;
  padding: 8px 16px 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.group-badge .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.group-badge .count { color: var(--text-light); font-weight: 400; }

.top-actions { display: flex; gap: 8px; }
.top-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--card);
  border: none;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
}

/* ===== FAB GO (Strava-like) ===== */
.fab-go {
  position: absolute;
  bottom: calc(var(--bottom-bar-h) + var(--safe-bottom) + 24px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #27AE60, #1E8449);
  border: 4px solid #fff;
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1px;
  box-shadow: 0 6px 24px rgba(39,174,96,0.45), 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(39,174,96,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  animation: fab-pulse 2.5s ease-in-out infinite;
}
.fab-go:active {
  transform: translateX(-50%) scale(0.92);
  box-shadow: 0 3px 12px rgba(39,174,96,0.3);
}
@keyframes fab-pulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(39,174,96,0.45), 0 2px 8px rgba(0,0,0,0.15); }
  50% { box-shadow: 0 6px 32px rgba(39,174,96,0.65), 0 2px 12px rgba(0,0,0,0.2); }
}

/* ===== FAB ===== */
.fab-share {
  position: absolute;
  bottom: calc(var(--bottom-bar-h) + var(--safe-bottom) + 20px);
  right: 16px;
  z-index: 1000;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--secondary);
  border: none;
  color: white;
  font-size: 26px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-recenter {
  position: absolute;
  bottom: calc(var(--bottom-bar-h) + var(--safe-bottom) + 20px);
  left: 16px;
  z-index: 1000;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--card);
  border: none;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== BOTTOM BAR ===== */
.bottom-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-bar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -2px 20px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 1000;
}
.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text-light);
  font-size: 11px;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
.tab-item.active { color: var(--primary); }
.tab-item .tab-icon { font-size: 24px; }

/* ===== TRACKING BAR ===== */
.tracking-bar {
  position: absolute;
  bottom: calc(var(--bottom-bar-h) + var(--safe-bottom) + 84px);
  left: 12px; right: 12px;
  z-index: 1000;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: none;
  align-items: center;
  gap: 10px;
}
.tracking-bar.active { display: flex; }
.tracking-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--alert);
  animation: blink 1.5s infinite;
  flex-shrink: 0;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.tracking-info { flex: 1; }
.tracking-info .ti-title { font-size: 13px; font-weight: 600; }
.tracking-info .ti-detail { font-size: 11px; color: var(--text-light); }
.tracking-stop {
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 24px;
  border: 2px solid var(--alert);
  background: rgba(231,76,60,0.08);
  color: var(--alert);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(231,76,60,0.2);
  flex-shrink: 0;
}
.tracking-stop:active {
  background: rgba(231,76,60,0.2);
  transform: scale(0.95);
}
.tracking-pause {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: rgba(74,144,217,0.08);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(74,144,217,0.2);
  flex-shrink: 0;
}
.tracking-pause:active {
  background: rgba(74,144,217,0.2);
  transform: scale(0.95);
}
/* Start trip button */
.btn-start-trip {
  width: 100%;
  min-height: 52px;
  padding: 14px 20px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--primary), #357ABD);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(74,144,217,0.3);
  box-shadow: 0 4px 12px rgba(74,144,217,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-start-trip:active {
  transform: scale(0.97);
  box-shadow: 0 2px 6px rgba(74,144,217,0.2);
}
.tracking-bar.paused .tracking-dot {
  background: #F39C12;
  animation: none;
}
.tracking-bar.paused .ti-title { color: #F39C12; }

/* ===== MAP MARKERS ===== */
.member-marker { position: relative; width: 48px; height: 48px; }
.member-marker .avatar-ring {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.member-marker .avatar-ring img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.member-marker .avatar-ring.moving { border-color: var(--success); }
.member-marker .avatar-ring.stopped { border-color: var(--text-light); }
.member-marker .avatar-ring.driving { border-color: #E91E63; }
.member-marker .avatar-ring.cycling { border-color: #FF9800; }
.member-marker .avatar-ring.offline { border-color: #999; filter: grayscale(60%); }
.member-marker .activity-badge {
  position: absolute;
  bottom: -4px; right: -6px;
  font-size: 14px;
  line-height: 1;
  background: var(--card);
  border-radius: 50%;
  padding: 1px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.member-marker .speed-badge {
  position: absolute;
  top: -6px; right: -8px;
  background: var(--success);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 8px;
}
.member-marker .battery-bar {
  position: absolute;
  bottom: -10px; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 4px;
  background: #ddd;
  border-radius: 2px;
  overflow: hidden;
}
.member-marker .battery-bar .fill {
  height: 100%;
  border-radius: 2px;
}
.member-marker .marker-battery {
  position: absolute;
  bottom: -14px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}
.member-marker .marker-batt-bar {
  width: 18px; height: 6px;
  background: #ddd;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.15);
}
.member-marker .marker-batt-bar .fill {
  height: 100%;
  border-radius: 1px;
}
.member-marker .marker-batt-pct {
  font-size: 8px;
  font-weight: 700;
  color: var(--text-light);
}
.member-marker .name-tag {
  position: absolute;
  bottom: -22px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  background: rgba(255,255,255,0.9);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ===== PANELS ===== */
.panel-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.panel-overlay.active { opacity: 1; pointer-events: auto; }

.panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  z-index: 2001;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85dvh;
  overflow-y: auto;
}
.panel.active { transform: translateY(0); }
.panel-handle {
  width: 36px; height: 4px;
  background: #DDD;
  border-radius: 2px;
  margin: 0 auto 16px;
}
.panel h2 { font-size: 20px; margin-bottom: 16px; }

/* ===== MEMBER LIST ===== */
.member-list { list-style: none; }

/* ===== GROUP LIST ===== */
.group-list { list-style: none; padding: 0; margin: 0; }
.group-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 8px; margin-bottom: 4px;
  background: var(--bg); transition: background .15s;
}
.group-item.active { background: #e3f2fd; }
.gi-info { flex: 1; min-width: 0; }
.gi-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gi-meta { font-size: 11px; color: var(--text-light); }
.gi-actions { display: flex; gap: 4px; flex-shrink: 0; }
.gi-switch, .gi-leave {
  width: 28px; height: 28px; border-radius: 50%; border: none;
  font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.gi-switch { background: var(--primary); color: #fff; }
.gi-leave { background: transparent; color: var(--alert); }
.group-actions-bar { display: flex; gap: 8px; margin-top: 8px; }
.btn-sm {
  flex: 1; padding: 8px 6px; border-radius: 8px;
  border: 1px solid #ddd; background: #fff; font-size: 13px;
  cursor: pointer; text-align: center;
}
.btn-sm:active { background: #f0f0f0; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 16px; margin-left: 4px; vertical-align: middle; }
.btn-danger {
  width: 100%; padding: 10px; border-radius: 10px;
  border: 1px solid var(--alert); background: #fff; color: var(--alert);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-danger:active { background: #fff0f0; }
.group-count-badge {
  display: inline-block; min-width: 16px; height: 16px; line-height: 16px;
  border-radius: 8px; background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 700; text-align: center; padding: 0 4px;
  vertical-align: middle; margin-left: 4px;
}
.member-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: rgba(74,144,217,0.15);
  touch-action: manipulation;
}
.member-list li:last-child { border-bottom: none; }
.member-list li:hover {
  background: rgba(74,144,217,0.08);
}
.member-list li:active {
  background: rgba(74,144,217,0.15);
}
.member-list .ml-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  overflow: hidden;
}
.member-list .ml-avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.member-list .ml-info { flex: 1; }
.member-list .ml-name { font-weight: 600; font-size: 15px; }
.member-list .ml-status { font-size: 12px; color: var(--text-light); }
.member-list .ml-status .online { color: var(--success); }
.member-list .ml-status .recent { color: #F39C12; }
.member-list .ml-battery {
  font-size: 11px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.ml-batt-bar {
  width: 28px; height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}
.ml-batt-fill {
  height: 100%;
  border-radius: 3px;
}
.member-list .ml-locate {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg);
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: rgba(74,144,217,0.2);
  touch-action: manipulation;
  flex-shrink: 0;
}
.member-list .ml-locate:hover,
.member-list .ml-locate:active {
  background: var(--primary);
  transform: scale(1.15);
}

/* ===== SHARE ===== */
.share-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
}
.share-btn .share-icon { font-size: 32px; }
.share-btn.whatsapp { background: #e7f5e9; }
.share-btn.sms { background: #e3f2fd; }
.share-btn.messenger { background: #e8eaf6; }
.share-btn.copy { background: #f3e5f5; }
.share-btn.native { background: #fff3e0; }

.share-link-box {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--primary);
  word-break: break-all;
  margin-bottom: 12px;
}

/* ===== QUICK MESSAGES ===== */
.quick-msg-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0;
  scrollbar-width: none;
}
.quick-msg-bar::-webkit-scrollbar { display: none; }
.quick-msg {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid #e0e0e0;
  background: white;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

/* ===== CHAT ===== */
.panel-chat { display: flex; flex-direction: column; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  max-height: 45dvh;
  min-height: 120px;
  padding: 8px 0;
  scroll-behavior: smooth;
}
.chat-empty { color: var(--text-light); font-size: 13px; text-align: center; padding: 32px 0; }
.chat-bubble {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: flex-start;
}
.chat-bubble.mine { flex-direction: row-reverse; }
.chat-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-locatable {
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: rgba(74,144,217,0.15);
  touch-action: manipulation;
}
.chat-locatable:hover,
.chat-locatable:active {
  opacity: 0.7;
  transform: scale(1.1);
}
.chat-body {
  max-width: 75%;
}
.chat-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 2px;
}
.chat-bubble.mine .chat-name { text-align: right; }
.chat-text {
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 14px 14px 14px 4px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}
.chat-bubble.mine .chat-text {
  background: var(--primary);
  color: white;
  border-radius: 14px 14px 4px 14px;
}
.chat-text.system {
  background: #fff3e0;
  color: #e65100;
  font-size: 12px;
  font-style: italic;
  border-radius: 10px;
}
.chat-time {
  font-size: 9px;
  color: var(--text-light);
  margin-top: 2px;
}
.chat-bubble.mine .chat-time { text-align: right; }
.chat-quick {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 0;
  scrollbar-width: none;
}
.chat-quick::-webkit-scrollbar { display: none; }
.chat-quick .quick-msg {
  font-size: 11px;
  padding: 5px 10px;
}
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding-top: 8px;
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 24px;
  font-size: 15px;
  outline: none;
}
.chat-input:focus { border-color: var(--primary); }
.chat-send {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.chat-badge {
  display: none;
  position: absolute;
  top: 4px; right: 12px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--secondary);
}
.tab-item { position: relative; }
.chat-badge.visible { display: block; }

/* ===== FORM ELEMENTS ===== */
.pseudo-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 16px;
  outline: none;
  margin-bottom: 12px;
}
.pseudo-input:focus { border-color: var(--primary); }

.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.avatar-option {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--bg);
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}
.avatar-option img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-option.selected { border-color: var(--primary); background: #e3edf7; }
.avatar-option.avatar-gen { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; font-size: 20px; }

.privacy-note {
  margin-top: 16px;
  padding: 12px;
  background: #f0f7ff;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.5;
}
.privacy-note strong { color: var(--text); }

/* ===== BATTERY / GPS INDICATORS ===== */
.battery-gauge, .gps-quality {
  position: absolute;
  top: 62px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border-radius: 12px;
  padding: 4px 10px;
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 600;
}
.battery-gauge { right: 12px; }
.gps-quality { left: 12px; }
.bg-bar {
  width: 22px; height: 10px;
  border: 1.5px solid var(--text);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.bg-fill { height: 100%; }
.gps-bars { display: flex; gap: 1px; align-items: flex-end; height: 12px; }
.gps-bars span { width: 3px; border-radius: 1px; background: #ccc; }
.gps-bars span.active { background: var(--success); }
.gps-bars span:nth-child(1) { height: 4px; }
.gps-bars span:nth-child(2) { height: 6px; }
.gps-bars span:nth-child(3) { height: 9px; }
.gps-bars span:nth-child(4) { height: 12px; }

/* ===== TOAST ===== */
.toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  z-index: 3000;
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  white-space: nowrap;
}
.toast.visible { transform: translateX(-50%) translateY(0); }

/* ===== SOS ===== */
.sos-btn {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--alert);
  color: white;
  border: none;
  border-radius: 24px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: none;
  align-items: center;
  gap: 6px;
}
.sos-btn.visible { display: flex; }

/* ===== LEAFLET ===== */
.leaflet-control-zoom { display: none; }
.leaflet-control-attribution { font-size: 9px !important; opacity: 0.6; }

/* ===== SETUP SCREEN ===== */
#setup-screen {
  position: absolute;
  inset: 0;
  z-index: 5000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}
#setup-screen.hidden { display: none; }
#setup-screen h1 { font-size: 28px; margin-bottom: 4px; }
#setup-screen .subtitle { color: var(--text-light); font-size: 14px; margin-bottom: 24px; }
#setup-screen .setup-form { width: 100%; max-width: 360px; text-align: left; }

/* ===== TRIP LIST ===== */
.trip-actions-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.trip-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.trip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}
.trip-item:hover {
  background: rgba(74,144,217,0.06);
}
.trip-color {
  width: 6px;
  height: 36px;
  border-radius: 3px;
  flex-shrink: 0;
}
.trip-info {
  flex: 1;
  min-width: 0;
}
.trip-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.trip-stats {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}
.trip-group {
  font-size: 10px;
  color: var(--primary);
  margin-top: 1px;
}
.trip-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.trip-show, .trip-delete {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
.trip-show:hover, .trip-show:active { background: var(--primary); transform: scale(1.1); }
.trip-delete:hover, .trip-delete:active { background: var(--alert); color: white; transform: scale(1.1); }

/* ===== TECH DASHBOARD ===== */
.panel-tech {
  background: #1a1a2e;
  color: #e0e0e0;
}
.panel-tech .panel-handle { background: #444; }
.panel-tech h2 { color: #fff; font-size: 18px; margin-bottom: 12px; }
.panel-tech h3 { font-size: 13px; color: #aaa; text-transform: uppercase; letter-spacing: 1px; margin: 0 0 8px; }

.tech-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  margin-bottom: 16px;
}
.tech-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
}
.tech-pill-ok { background: rgba(39,174,96,0.2); color: #27ae60; }
.tech-pill-warn { background: rgba(243,156,18,0.2); color: #f39c12; }
.tech-pill-err { background: rgba(231,76,60,0.2); color: #e74c3c; }
.tech-uptime { font-size: 12px; color: #888; font-family: 'SF Mono', monospace; }

.tech-section { margin-bottom: 16px; }

.tech-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tech-card {
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px;
  min-height: 56px;
}
.tech-label {
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.tech-value {
  font-size: 20px;
  font-weight: 700;
  font-family: 'SF Mono', 'Menlo', monospace;
  color: #fff;
  line-height: 1.2;
}
.tech-sub {
  font-size: 10px;
  color: #666;
  margin-top: 2px;
  font-family: 'SF Mono', monospace;
}
.tech-bar {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.tech-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.5s;
}
.tech-spark {
  display: block;
  width: 100%;
  height: 24px;
  margin-top: 4px;
}
.tech-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.tech-actions .btn-sm {
  flex: 1;
  padding: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: #ccc;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.tech-actions .btn-sm:active {
  background: rgba(255,255,255,0.12);
}
.btn-demo {
  background: rgba(78, 205, 196, 0.15) !important;
  border-color: rgba(78, 205, 196, 0.4) !important;
  color: #4ecdc4 !important;
}
.btn-demo:disabled {
  opacity: 0.4;
  cursor: default;
}
.demo-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(78, 205, 196, 0.1);
  border: 1px solid rgba(78, 205, 196, 0.3);
  border-radius: 8px;
  color: #4ecdc4;
  font-size: 12px;
}

/* ===== NETWORK SUPERVISION DASHBOARD ===== */
.net-dashboard-container {
  margin-top: 8px;
}
.net-dashboard {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.net-canvas {
  width: 100%;
  border-radius: 10px;
  background: rgba(0,0,0,0.2);
}
.net-stats { overflow-x: auto; }
.net-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  color: #ccc;
}
.net-table th {
  text-align: left;
  font-weight: 600;
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  font-size: 10px;
  color: #999;
}
.net-table td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.net-type-p2p { color: #27AE60; font-weight: 600; }
.net-type-turn { color: #FF9800; font-weight: 600; }
.net-type-ws { color: #4A90D9; font-weight: 600; }
.net-empty {
  text-align: center;
  color: #777;
  padding: 12px;
  font-size: 12px;
}
.net-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  font-size: 11px;
  color: #999;
}
.net-leg-item { display: flex; align-items: center; gap: 4px; }
.net-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.net-dot-direct { background: #27AE60; }
.net-dot-relay { background: #FF9800; }
.net-dot-ws { background: #4A90D9; }

/* ===== BATTERY CRITICAL ALERT ===== */
.battery-alert {
  position: absolute;
  bottom: calc(var(--bottom-bar-h) + var(--safe-bottom));
  left: 0; right: 0;
  z-index: 1500;
  background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  animation: batt-pulse 1.5s ease-in-out infinite;
}
@keyframes batt-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}
.battery-alert-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  flex: 1;
  min-width: 0;
}
.battery-alert-text strong { font-size: 14px; }
.battery-alert-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.batt-btn {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: none;
  color: white;
  touch-action: manipulation;
}
.batt-btn-wa { background: #25D366; }
.batt-btn-sms { background: #3498db; }
.batt-btn-dismiss {
  background: rgba(0,0,0,0.25);
  padding: 8px 10px;
  font-size: 14px;
}
