/* ── Splash Screen ── */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.4s ease;
}

.splash-screen.splash-fade {
  opacity: 0;
  pointer-events: none;
}

.splash-logo {
  max-width: min(320px, 70vw);
  max-height: 50vh;
  object-fit: contain;
}

/* ── Reset & Base ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --info: #3b82f6;
  --sidebar-width: 260px;
  --topbar-height: 52px;
  --toolbar-height: 44px;
  --radius: 8px;
  --radius-sm: 4px;
  --bar-bg-hover: rgba(30, 41, 59, 0.88);
  --bar-btn-bg: rgba(15, 23, 42, 0.65);
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── Auth Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px 32px;
  text-align: center;
  width: 360px;
  max-width: 90vw;
  position: relative;
}

.modal-card-small {
  width: 320px;
  padding: 32px 28px 24px;
}

.modal-close, .modal-cancel {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover, .modal-cancel:hover { color: var(--text-primary); }

.modal-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.modal-subtitle {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 14px;
}

.modal-card input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.modal-card input:focus {
  border-color: var(--accent);
}

.modal-card button[type="submit"] {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

.modal-card button[type="submit"]:hover {
  background: var(--accent-hover);
}

.auth-switch {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  margin-left: 4px;
}
.auth-switch a:hover { text-decoration: underline; }

.auth-error {
  background: rgba(239,68,68,0.15);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
  text-align: left;
}

.passcode-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.passcode-hint a {
  color: var(--primary);
  text-decoration: underline;
}

.unlock-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Main Layout ── */
#app {
  position: relative;
  height: 100vh;
  overflow: hidden;
}

#main-content {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  z-index: 1;
}

/* ── Top Bar (transparent overlay) ── */
#top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: transparent;
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
  transition: background 0.3s;
  pointer-events: none;
}

#top-bar:hover,
#main-content.sidebar-open ~ #top-bar,
#app:has(#main-content.sidebar-open) #top-bar {
  background: var(--bar-bg-hover);
}

#top-bar > * {
  pointer-events: auto;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}

.app-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.2s;
}
.app-brand-link:hover { opacity: 0.8; }

.app-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 10px rgba(0,0,0,0.5);
}

.top-bar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.cell-info-badge {
  background: var(--bar-btn-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-primary);
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-bar-left svg {
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.8));
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  background: var(--bar-btn-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.btn:hover { background: rgba(71, 85, 105, 0.8); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-secondary {
  background: var(--bar-btn-bg);
  border-color: rgba(255,255,255,0.12);
}

.btn-icon {
  padding: 6px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  position: relative;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}
.btn-icon:hover { background: rgba(51,65,85,0.7); color: var(--text-primary); }

.btn-small { padding: 4px 8px; font-size: 12px; }

.btn-full { width: 100%; justify-content: center; margin-top: 8px; }

/* ── User Badge ── */
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--bar-btn-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.user-badge-clickable {
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.user-badge-clickable:hover {
  background: var(--bg-tertiary);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: white;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Profile modal ── */
.profile-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 12px 0 4px 0;
}

.profile-label:first-of-type { margin-top: 0; }

#profile-form input[type="text"],
#profile-form textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  box-sizing: border-box;
}

#profile-form textarea { resize: vertical; min-height: 80px; }

.profile-char-count {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  text-align: right;
}

.profile-photo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.profile-photo-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.profile-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#profile-photo-input {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 200px;
}

.profile-separator {
  border-top: 1px solid var(--border);
  margin: 16px 0 4px 0;
}

.profile-pw-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.profile-pw-row input {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
}

.user-count-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

/* ── Dropdown ── */
.dropdown { position: relative; }

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  min-width: 220px;
  z-index: 200;
  overflow: hidden;
}

.dropdown-menu.show { display: block; }

.dropdown-menu a {
  display: block;
  padding: 10px 16px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s;
}

.dropdown-menu a:hover { background: rgba(51,65,85,0.6); }

.dropdown-menu a.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

.export-login-warn {
  padding: 8px 16px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* ── Language Dropdown ── */
#lang-dropdown .dropdown-menu {
  min-width: 150px;
  right: 0;
  left: auto;
}

.lang-option {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 8px 14px !important;
  font-size: 13px;
  white-space: nowrap;
}

.lang-option.active-lang {
  background: rgba(22,163,74,0.25);
  font-weight: 600;
}

.lang-flag {
  flex-shrink: 0;
}

#lang-btn {
  display: flex;
  align-items: center;
  gap: 5px;
}

#lang-btn-label {
  font-weight: 600;
  font-size: 12px;
}

/* ── Sidebar Toggle Button ── */
.sidebar-toggle {
  position: absolute;
  top: calc(var(--topbar-height) + (100% - var(--topbar-height) - var(--toolbar-height)) / 2);
  left: 4px;
  transform: translateY(-50%);
  z-index: 150;
  width: 28px;
  height: 56px;
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bar-btn-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 0 8px rgba(0,0,0,0.3);
  transition: background 0.15s, left 0.3s ease;
  padding: 0;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.toggle-arrow {
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
}

.sidebar-toggle:hover {
  background: rgba(51,65,85,0.8);
}

#main-content.sidebar-open .sidebar-toggle {
  left: var(--sidebar-width);
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  position: absolute;
  top: var(--topbar-height);
  left: calc(-1 * var(--sidebar-width));
  height: calc(100% - var(--topbar-height) - var(--toolbar-height));
  z-index: 140;
  transition: left 0.3s ease;
}

#main-content.sidebar-open #sidebar {
  left: 0;
}

/* ── Sidebar Overlay (disabled on desktop — map stays interactive) ── */
.sidebar-overlay {
  display: none;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.filter-group {
  margin-bottom: 14px;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 6px 0;
  letter-spacing: 0.3px;
}

.filter-subgroup {
  margin-left: 20px;
  padding-left: 4px;
  border-left: 2px solid var(--border);
}

.filter-subgroup .filter-item {
  padding: 2px 0;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.filter-item:hover { color: var(--text-primary); }

.filter-item-parent {
  font-weight: 500;
  color: var(--text-primary);
}

.filter-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.filter-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cell-id-label {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

/* ── Cell Detail Info ── */
.cell-detail {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  font-size: 13px;
}

.cell-detail-label {
  color: var(--text-muted);
  font-size: 12px;
}

.cell-detail-value {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

/* ── Users List ── */
#users-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  font-size: 13px;
}

.user-item .online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.user-item .user-cell-info {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: auto;
}

.user-item.user-item-zoomable {
  cursor: pointer;
}

.user-item.user-item-zoomable:hover {
  background: var(--bg-tertiary);
}

/* ── Point Insertion Banner ── */
.insertion-banner {
  position: absolute;
  top: calc(var(--topbar-height) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 210;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: rgba(220, 38, 38, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(239, 68, 68, 0.7);
  border-radius: 20px;
  color: #fca5a5;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  pointer-events: none;
  white-space: nowrap;
}

.insertion-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: pulse-red 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-red {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.insertion-mode-active {
  outline: 4px solid #eab308;
  outline-offset: -4px;
}

.toolbar-checkbox-warn {
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.toolbar-checkbox-warn input:checked + span {
  color: #fca5a5;
}

/* ── Edit Mode Badge ── */
.edit-mode-badge {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 210;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: rgba(234, 179, 8, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(234, 179, 8, 0.5);
  border-radius: 20px;
  color: #fde047;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  pointer-events: none;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 420px;
  text-align: center;
}

.edit-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #eab308;
  animation: pulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.6); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(234, 179, 8, 0); }
}

.tool-hint-text {
  display: block;
  width: 100%;
  font-size: 10px;
  font-weight: 400;
  color: rgba(253, 224, 71, 0.7);
  margin-top: -2px;
  letter-spacing: 0.2px;
}

/* ── Map ── */
#map-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

#map {
  flex: 1;
  min-height: 0;
}

/* ── Floating Edit Tools (bottom-left on map) ── */
.edit-tools-panel {
  position: absolute;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 160;
  display: flex;
  gap: 6px;
  padding: 6px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
}

.edit-tool-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bar-btn-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
}

.edit-tool-btn svg {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.edit-tool-btn:hover {
  background: rgba(71, 85, 105, 0.8);
  color: white;
}

.edit-tool-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.edit-tool-btn-special {
  background: rgba(245, 158, 11, 0.35);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

.edit-tool-btn-special:hover {
  background: rgba(245, 158, 11, 0.5);
  color: #fde68a;
}

.edit-tool-btn-special.active {
  background: #d97706;
  color: white;
  border-color: #d97706;
}

/* ── Map Controls Right (zoom + home group) ── */
.map-controls-right {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 160;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.map-ctrl-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bar-btn-bg);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
}

.map-ctrl-btn svg {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.map-ctrl-btn:hover:not(:disabled) {
  background: rgba(71, 85, 105, 0.8);
  color: white;
}

.map-ctrl-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Street View ── */
#streetview-container {
  height: 280px;
  border-top: 2px solid var(--accent);
  display: flex;
  flex-direction: column;
  position: relative;
}

#streetview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-secondary);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

#streetview-pano {
  flex: 1;
}

/* ── Toolbar (transparent overlay) ── */
#toolbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--toolbar-height);
  background: transparent;
  border-top: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
  transition: background 0.3s;
  pointer-events: none;
}

#toolbar:hover,
#app:has(#main-content.sidebar-open) #toolbar {
  background: var(--bar-bg-hover);
}

#toolbar > * {
  pointer-events: auto;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-right {
  margin-left: auto;
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.15);
  margin: 0 8px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bar-btn-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.tool-btn svg {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.tool-btn:hover:not(:disabled) {
  background: rgba(71, 85, 105, 0.8);
  color: white;
}

.tool-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.tool-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Toolbar checkbox ── */
.toolbar-checkbox {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bar-btn-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  margin-left: 4px;
}

.toolbar-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ── Coords display ── */
.coords-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: var(--bar-btn-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.1);
}

.coords {
  font-size: 12px;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
}

.coords-hint {
  font-size: 9px;
  color: rgba(255,255,255,0.5);
  font-family: inherit;
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  color: white;
  min-width: 250px;
  max-width: 400px;
  animation: slideIn 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.toast.info { background: var(--info); }
.toast.success { background: var(--success); }
.toast.warning { background: var(--warning); color: #000; }
.toast.error { background: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Map Legend (accordion) ── */
.map-legend {
  position: absolute;
  bottom: 56px;
  left: 12px;
  z-index: 150;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  min-width: 170px;
  pointer-events: auto;
  overflow: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.map-legend.legend-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.legend-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  font-family: inherit;
}

.legend-toggle:hover {
  color: var(--text-primary);
}

.legend-arrow {
  transition: transform 0.2s;
}

.map-legend.collapsed .legend-arrow {
  transform: rotate(180deg);
}

.legend-body {
  padding: 0 14px 10px;
  padding-right: 8px;
  transition: max-height 0.2s ease, opacity 0.2s;
  max-height: 200px;
  opacity: 1;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.legend-body::-webkit-scrollbar {
  width: 6px;
}

.legend-body::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
}

.legend-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
}

.legend-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.4);
}

.map-legend.collapsed .legend-body {
  max-height: 0;
  opacity: 0;
  padding-bottom: 0;
}

.legend-category {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 8px;
  margin-bottom: 2px;
}

.legend-category:first-child {
  margin-top: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 2px 0;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-color.legend-hollow {
  background: transparent !important;
  border: 3px solid;
}

.legend-color.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin: 0 2px;
  box-sizing: border-box;
}

.legend-color.legend-mask {
  border-radius: 3px;
}

/* ── Documentation Modal ── */
.modal-card-docs {
  width: 640px;
  max-width: 90vw;
  max-height: 85vh;
  padding: 32px 36px;
  text-align: left;
  overflow-y: auto;
}

.docs-content h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
  color: var(--accent);
}

.docs-content h3 {
  font-size: 15px;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 8px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.docs-content p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 8px;
}

.docs-content ul {
  margin: 8px 0 8px 20px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.docs-content a {
  color: var(--accent);
  text-decoration: underline;
}

.docs-content em {
  font-style: italic;
}

/* ── Guide "Comece por aqui" Button ── */
.guide-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid rgba(59, 130, 246, 0.5);
  border-radius: 20px;
  background: rgba(59, 130, 246, 0.2);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #93c5fd;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  animation: guide-glow 2.5s ease-in-out infinite;
}

.guide-start-btn:hover {
  background: rgba(59, 130, 246, 0.35);
  border-color: rgba(59, 130, 246, 0.8);
  color: white;
}

@keyframes guide-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  50% { box-shadow: 0 0 12px 3px rgba(59, 130, 246, 0.25); }
}

/* ── Guide Modal ── */
.modal-card-guide {
  width: 680px;
  max-width: 92vw;
  max-height: 88vh;
  padding: 32px 36px;
  text-align: left;
  overflow-y: auto;
}

.modal-card-guide h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
  color: var(--info);
}

.guide-page { }

.guide-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.guide-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  font-family: inherit;
  color: inherit;
}

.guide-card:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: var(--info);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.guide-card-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--info);
}

.guide-card-icon-leaf {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.guide-card-icon-map {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.guide-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.guide-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.guide-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 16px;
  transition: all 0.15s;
}

.guide-back:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.guide-content h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
  color: var(--info);
}

.guide-content h3 {
  font-size: 14px;
  font-weight: 600;
  margin-top: 18px;
  margin-bottom: 6px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.guide-content p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 8px;
}

.guide-content ul {
  margin: 6px 0 10px 20px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.guide-content a {
  color: var(--accent);
  text-decoration: underline;
}

.guide-photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.guide-photos figure {
  margin: 0;
}

.guide-photos img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
}

.guide-photos figcaption {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
  line-height: 1.3;
}

.guide-tip {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.guide-tip strong {
  color: var(--info);
}

.guide-content-scroll {
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.guide-media-links {
  list-style: none;
  padding-left: 0;
  margin: 8px 0 16px;
}

.guide-media-links li {
  margin-bottom: 6px;
}

.guide-media-links a {
  color: var(--info);
  text-decoration: none;
}

.guide-media-links a:hover {
  text-decoration: underline;
}

.guide-refs-list {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 8px;
  padding: 8px;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius);
}

.guide-ref-item {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 4px;
}

.guide-ref-item a {
  color: var(--info);
  text-decoration: none;
}

.guide-ref-item a:hover {
  text-decoration: underline;
}

@media (max-width: 700px) {
  .guide-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .guide-photos {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .guide-cards {
    grid-template-columns: 1fr;
  }
}

/* ── View counter (admin) ── */
.view-counter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--bar-btn-bg);
  border-radius: var(--radius-sm);
}

/* ── Admin users modal ── */
.admin-passcode-box {
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.admin-passcode-box strong {
  color: var(--text-primary);
}

.admin-users-list {
  max-height: 400px;
  overflow-y: auto;
}

.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.admin-user-row:last-child {
  border-bottom: none;
}

.admin-user-info {
  flex: 1;
  min-width: 0;
}

.admin-user-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.admin-user-date {
  font-size: 11px;
  color: var(--text-muted);
}

.admin-user-stats {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.admin-user-stats span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}

.admin-export-row {
  display: flex;
  justify-content: flex-end;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.admin-export-btn {
  padding: 6px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-export-btn:hover {
  opacity: 0.85;
}

.admin-user-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  margin-left: 6px;
}

.admin-user-actions {
  display: flex;
  gap: 6px;
}

.admin-user-actions button {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-user-actions button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.admin-user-actions button.btn-danger-sm {
  border-color: var(--danger);
  color: var(--danger);
}

.admin-user-actions button.btn-danger-sm:hover {
  background: var(--danger);
  color: white;
}

/* ── Quem Somos cards ── */
.about-section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 24px 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}

.about-section-title:first-child {
  margin-top: 8px;
}

.about-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.about-card {
  display: flex;
  gap: 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
}

.about-card-thumb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.about-card-thumb img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.about-card-info {
  flex: 1;
  min-width: 0;
}

.about-card-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.about-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
    --topbar-height: 46px;
    --toolbar-height: 40px;
  }

  #top-bar {
    padding: 0 8px;
  }

  .app-logo {
    width: 24px;
    height: 24px;
  }

  .app-title {
    font-size: 13px;
  }

  .guide-start-btn {
    font-size: 10px;
    padding: 4px 10px;
    gap: 4px;
  }

  .guide-start-btn svg {
    width: 14px;
    height: 14px;
  }

  .top-bar-right {
    gap: 6px;
  }

  .top-bar-right .btn {
    padding: 5px 8px;
    font-size: 11px;
    gap: 4px;
  }

  .top-bar-right .btn svg {
    width: 14px;
    height: 14px;
  }

  .top-bar-right .btn span {
    display: none;
  }

  .user-badge {
    padding: 3px 8px 3px 3px;
    font-size: 12px;
  }

  .user-avatar {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  #user-display-name {
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .cell-info-badge {
    font-size: 11px;
    padding: 3px 10px;
  }

  .edit-mode-badge {
    font-size: 11px;
    padding: 5px 12px;
    gap: 6px;
  }

  .tool-hint-text {
    font-size: 9px;
  }

  .insertion-banner {
    font-size: 10px;
    padding: 5px 12px;
    gap: 5px;
    max-width: 90vw;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 139;
  }

  #main-content.sidebar-open .sidebar-overlay {
    display: block;
  }

  #sidebar {
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
  }

  .sidebar-toggle {
    width: 24px;
    height: 48px;
    font-size: 16px;
  }

  #toolbar {
    padding: 0 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #toolbar::-webkit-scrollbar {
    display: none;
  }

  .toolbar-group {
    flex-shrink: 0;
  }

  .tool-btn {
    padding: 8px;
    font-size: 11px;
    gap: 3px;
    min-width: 36px;
    min-height: 36px;
    justify-content: center;
  }

  .tool-btn span {
    display: none;
  }

  .tool-btn svg {
    width: 18px;
    height: 18px;
  }

  .toolbar-separator {
    margin: 0 4px;
    height: 20px;
  }

  .toolbar-checkbox {
    padding: 4px 6px;
    font-size: 10px;
    gap: 3px;
  }

  .coords-container {
    padding: 3px 8px;
  }

  .coords {
    font-size: 10px;
  }

  .coords-hint {
    display: none;
  }

  .map-legend {
    bottom: 48px;
    left: 8px;
    min-width: 150px;
  }

  .legend-body {
    max-height: 150px;
  }

  .edit-tools-panel {
    bottom: 48px;
    gap: 4px;
    padding: 4px;
  }

  .edit-tool-btn {
    width: 44px;
    height: 44px;
  }

  .map-controls-right {
    right: 8px;
    gap: 3px;
    padding: 3px;
  }

  .map-ctrl-btn {
    width: 40px;
    height: 40px;
  }

  .map-ctrl-btn svg {
    width: 18px;
    height: 18px;
  }

  #streetview-container {
    height: 200px;
  }

  .modal-card {
    padding: 28px 20px 20px;
    width: 95vw;
    max-width: 95vw;
  }

  .modal-card-small {
    width: 95vw;
    padding: 24px 16px 18px;
  }

  .modal-card-docs,
  .modal-card-guide {
    width: 98vw;
    max-width: 98vw;
    padding: 20px 16px;
    max-height: 92vh;
  }

  .guide-content-scroll {
    max-height: 55vh;
  }

  .toast-container {
    right: 8px;
    left: 8px;
  }

  .toast {
    min-width: auto;
    max-width: 100%;
    font-size: 12px;
    padding: 8px 12px;
  }

  .dropdown-menu {
    min-width: 180px;
  }

  .admin-user-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .admin-user-actions {
    flex-wrap: wrap;
  }

  .admin-user-stats {
    gap: 8px;
    flex-wrap: wrap;
  }

  .about-cards {
    grid-template-columns: 1fr;
  }

  .about-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .view-counter {
    font-size: 10px;
    padding: 2px 6px;
  }

  .dropdown-menu {
    max-width: calc(100vw - 16px);
  }

  .profile-photo-row {
    flex-direction: column;
    align-items: flex-start;
  }

  #profile-photo-input {
    max-width: 100%;
  }

  .guide-photos {
    grid-template-columns: 1fr;
  }

  .guide-refs-list {
    max-height: 200px;
  }
}

@media (max-width: 480px) {
  :root {
    --sidebar-width: 100vw;
  }

  .app-logo {
    width: 22px;
    height: 22px;
  }

  .app-title {
    font-size: 12px;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .guide-start-btn span {
    display: none;
  }

  .top-bar-center {
    display: none;
  }

  .top-bar-left svg:first-child {
    width: 20px;
    height: 20px;
  }

  .guide-cards {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .guide-card {
    padding: 16px 12px;
  }

  .guide-card-icon {
    width: 44px;
    height: 44px;
  }

  .toolbar-checkbox span {
    display: none;
  }

  .toolbar-checkbox {
    min-width: 32px;
    min-height: 32px;
    justify-content: center;
  }

  .coords-container {
    display: none;
  }

  #user-display-name {
    display: none;
  }

  .user-badge {
    padding: 3px;
  }

  .map-legend {
    min-width: 130px;
    max-width: 160px;
  }

  .legend-body {
    max-height: 120px;
  }

  .legend-item {
    font-size: 11px;
    gap: 6px;
  }

  .legend-color {
    width: 12px;
    height: 12px;
  }
}
