:root {
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color: #0f2233;
  background: #eef3f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: #ffffff;
  border-bottom: 1px solid #dfe7ee;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
}

.brand p {
  margin: 0;
  color: #4d6373;
  font-size: 0.9rem;
}

.dot {
  width: 14px;
  height: 14px;
  background: #0e6d74;
  border-radius: 50%;
  display: inline-block;
}

.controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: #4d6373;
  gap: 6px;
}

.field input {
  padding: 8px 12px;
  border: 1px solid #cdd7df;
  border-radius: 8px;
  min-width: 180px;
  font-size: 0.95rem;
}

button {
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  background: #0e6d74;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #0b5b61;
}

button.ghost {
  background: #ffffff;
  border: 1px solid #d4dde5;
  color: #0f2233;
}

button.ghost:hover {
  background: #f3f6f8;
}

.status {
  font-size: 0.85rem;
  color: #4d6373;
}

main {
  position: relative;
}

#map {
  width: 100%;
  height: calc(100vh - 80px);
}

.panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e3ebf1;
  border-radius: 12px;
  padding: 14px 16px;
  width: min(320px, 92vw);
  box-shadow: 0 10px 25px rgba(15, 35, 51, 0.12);
  z-index: 1000;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.panel p {
  margin: 0 0 6px;
  color: #516474;
  font-size: 0.9rem;
  line-height: 1.4;
}

.panel .muted {
  color: #7a8996;
}

.panel code {
  background: #f1f4f7;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #324554;
}

.billboard {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafb 100%);
  border-radius: 10px;
  padding: 6px 10px;
  border: 1px solid #e0e8ed;
  box-shadow: 0 4px 12px rgba(15, 35, 51, 0.12);
  font-size: 0.75rem;
  color: #2a3f4d;
  min-width: 90px;
  max-width: 160px;
  line-height: 1.3;
}

.billboard strong {
  display: block;
  font-size: 0.78rem;
  color: #0e6d74;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.billboard span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-marker {
  background: linear-gradient(135deg, #ffffff 0%, #f0f7f7 100%);
  border-radius: 999px;
  border: 2px solid #0e6d74;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #0e6d74;
  box-shadow: 0 4px 10px rgba(14, 109, 116, 0.2);
}

@media (max-width: 720px) {
  .billboard {
    padding: 4px 8px;
    font-size: 0.7rem;
    min-width: 70px;
    max-width: 120px;
    border-radius: 8px;
  }

  .billboard strong {
    font-size: 0.72rem;
  }

  .avatar-marker {
    width: 32px;
    height: 32px;
    font-size: 0.7rem;
  }
}

.profile {
  position: absolute;
  left: 16px;
  bottom: 16px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #e3ebf1;
  border-radius: 14px;
  padding: 16px;
  width: min(340px, 92vw);
  box-shadow: 0 12px 28px rgba(15, 35, 51, 0.16);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 1000;
}

.profile.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.profile .close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: #f0f4f7;
  font-size: 18px;
  cursor: pointer;
  color: #3f5564;
}

.profile-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
}

.profile-card h2 {
  margin: 0;
  font-size: 1.1rem;
}

.profile .avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #0e6d74;
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.profile-details {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}

.profile-details p {
  margin: 0;
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  color: #445766;
}

.profile-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.profile .small {
  font-size: 0.8rem;
}

.muted {
  color: #7a8996;
}

.auth-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.auth-form input {
  padding: 8px 12px;
  border: 1px solid #cdd7df;
  border-radius: 8px;
  font-size: 0.9rem;
  width: 140px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #0e6d74;
}

.hidden {
  display: none !important;
}

.connection-status {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
}

.connection-status.pending {
  background: #fff3cd;
  color: #856404;
}

.connection-status.accepted {
  background: #d4edda;
  color: #155724;
}

.connection-status.declined {
  background: #f8d7da;
  color: #721c24;
}

.message-composer {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-composer textarea {
  padding: 10px;
  border: 1px solid #cdd7df;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
}

.inbox-panel {
  position: absolute;
  right: 16px;
  top: 100px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #e3ebf1;
  border-radius: 14px;
  padding: 16px;
  width: min(360px, 92vw);
  max-height: calc(100vh - 180px);
  box-shadow: 0 12px 28px rgba(15, 35, 51, 0.16);
  transform: translateX(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  z-index: 1000;
}

.inbox-panel.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.inbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.inbox-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
  max-height: 300px;
}

.conversation-item {
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 8px;
  transition: background 0.15s;
}

.conversation-item:hover {
  background: #f3f6f8;
  border-color: #e3ebf1;
}

.conversation-item h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.conversation-item p {
  margin: 0;
  font-size: 0.85rem;
  color: #5a6c7a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item .time {
  font-size: 0.75rem;
  color: #8a9aa8;
}

.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e3ebf1;
  margin-bottom: 12px;
}

.chat-header span {
  font-weight: 600;
  font-size: 1rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  max-height: 250px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 80%;
  font-size: 0.9rem;
  line-height: 1.4;
}

.chat-bubble.sent {
  background: #0e6d74;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-bubble.received {
  background: #f0f4f7;
  color: #0f2233;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-bubble .time {
  display: block;
  font-size: 0.7rem;
  margin-top: 4px;
  opacity: 0.7;
}

.chat-input {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e3ebf1;
}

.chat-input textarea {
  padding: 10px;
  border: 1px solid #cdd7df;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
}

.upgrade-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: #ffffff;
  border: 1px solid #e3ebf1;
  border-radius: 16px;
  padding: 24px;
  width: min(380px, 90vw);
  box-shadow: 0 20px 50px rgba(15, 35, 51, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 2000;
}

.upgrade-panel.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.upgrade-panel .close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: #f0f4f7;
  font-size: 18px;
  cursor: pointer;
  color: #3f5564;
}

.upgrade-content {
  text-align: center;
}

.upgrade-content h2 {
  margin: 0 0 10px;
  font-size: 1.4rem;
  color: #0f2233;
}

.upgrade-content > p {
  margin: 0 0 16px;
  color: #5a6c7a;
  font-size: 0.95rem;
  line-height: 1.5;
}

.upgrade-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  text-align: left;
}

.upgrade-features li {
  padding: 8px 0;
  padding-left: 28px;
  position: relative;
  color: #3a4d5c;
  font-size: 0.9rem;
  border-bottom: 1px solid #f0f4f7;
}

.upgrade-features li:last-child {
  border-bottom: none;
}

.upgrade-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #0e6d74;
  font-weight: 700;
}

.upgrade-price {
  margin-bottom: 16px;
}

.upgrade-price .price {
  font-size: 2rem;
  font-weight: 700;
  color: #0e6d74;
}

.upgrade-price .period {
  font-size: 1rem;
  color: #7a8996;
}

.btn-upgrade {
  display: block;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #0e6d74 0%, #16939c 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(14, 109, 116, 0.3);
  transition: transform 0.2s ease;
}

.btn-upgrade:hover {
  transform: translateY(-1px);
}

.upgrade-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 35, 51, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 1999;
}

.upgrade-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.profile-blurred .profile-details,
.profile-blurred .profile-actions {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

.profile-upgrade-hint {
  background: linear-gradient(135deg, #e7f3f4 0%, #f0f8f8 100%);
  border: 1px solid #bdd6d8;
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
  text-align: center;
}

.profile-upgrade-hint p {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: #0a4f54;
}

.profile-upgrade-hint button {
  background: #0e6d74;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.auth-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: #ffffff;
  border: 1px solid #e3ebf1;
  border-radius: 16px;
  padding: 24px;
  width: min(440px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(15, 35, 51, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 2000;
}

.auth-panel.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.auth-panel .close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: #f0f4f7;
  font-size: 18px;
  cursor: pointer;
  color: #3f5564;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #e0e8ed;
  background: #f8fafb;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  color: #5a6c7a;
  transition: all 0.2s;
}

.auth-tab.active {
  background: #0e6d74;
  border-color: #0e6d74;
  color: #fff;
}

.auth-tab-content {
  display: none;
}

.auth-tab-content.active {
  display: block;
}

.auth-tab-content h2 {
  margin: 0 0 16px;
  font-size: 1.3rem;
  color: #0f2233;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.form-field span {
  font-size: 0.8rem;
  font-weight: 600;
  color: #4d6373;
}

.form-field input,
.form-field textarea {
  padding: 10px 12px;
  border: 1px solid #cdd7df;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: #0e6d74;
  box-shadow: 0 0 0 3px rgba(14, 109, 116, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-auth {
  width: 100%;
  padding: 12px 20px;
  background: linear-gradient(135deg, #0e6d74 0%, #16939c 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 8px;
}

.btn-auth:hover {
  opacity: 0.95;
}

.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 35, 51, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 1999;
}

.auth-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 500px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 20px 16px;
  }
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f2233;
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.9rem;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  background: #dc3545;
}

.toast.success {
  background: #28a745;
}

@media (max-width: 720px) {
  .controls {
    width: 100%;
  }

  #map {
    height: calc(100vh - 160px);
  }

  .auth-controls {
    width: 100%;
    justify-content: flex-end;
  }

  .auth-form input {
    width: 100px;
  }

  .inbox-panel {
    right: 8px;
    left: 8px;
    width: auto;
  }
}
