:root {
  --bg: #09090b;
  --panel: #18181b;
  --panel-soft: rgba(24, 24, 27, 0.68);
  --line: #27272a;
  --line-light: #3f3f46;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --primary: #13ef93;
  --primary-soft: rgba(19, 239, 147, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warning: #fbbf24;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

body.signed-in {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  min-height: 60px;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 9, 11, 0.92);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand:hover { text-decoration: none; }
.brand-logo { height: 26px; width: auto; object-fit: contain; }
.brand-divider { width: 1px; height: 20px; background: var(--line-light); }
.brand-name { color: var(--text); }

.user-account-menu { position: relative; }

.user-account-menu summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  max-width: min(280px, 55vw);
  padding: 0.3rem 0.55rem 0.3rem 0.3rem;
  border: 1px solid var(--line-light);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
  list-style: none;
}

.user-account-menu summary::-webkit-details-marker { display: none; }
.user-account-menu summary:hover { border-color: #71717a; }

.user-account-menu summary img,
.user-avatar-fallback {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #27272a;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
}

.user-summary-name {
  overflow: hidden;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chevron {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.user-account-menu[open] .user-chevron { transform: rotate(180deg); }

.user-account-panel {
  position: absolute;
  right: 0;
  z-index: 30;
  width: 240px;
  margin-top: 0.5rem;
  padding: 0.75rem 0 0.5rem;
  overflow: hidden;
  border: 1px solid var(--line-light);
  border-radius: 0.75rem;
  background: #111113;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.user-account-name,
.user-account-email,
.user-account-role {
  margin: 0;
  padding: 0 0.9rem;
}

.user-account-name {
  overflow: hidden;
  font-size: 0.85rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-account-email {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-account-role {
  margin-top: 0.25rem;
  color: var(--primary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-logout {
  display: block;
  width: calc(100% - 1rem);
  margin: 0.65rem 0.5rem 0.15rem;
  padding: 0.5rem 0.4rem;
  border: none;
  border-radius: 0.45rem;
  background: none;
  color: var(--danger);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.user-logout:hover { background: var(--danger-soft); }

.login-page {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
}

.login-logo {
  height: 64px;
  width: auto;
  object-fit: contain;
}

.login-page .banner {
  width: min(360px, 100%);
  margin-top: 1.25rem;
  text-align: left;
}

.google-signin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  width: min(320px, 100%);
  margin-top: 1.25rem;
  min-height: 44px;
  padding: 0.7rem 1rem;
  border-radius: 0.55rem;
  background: #fff;
  color: #1f1f1f;
  font-weight: 700;
}

.google-signin:hover {
  background: #f4f4f5;
  text-decoration: none;
}

.google-signin svg { width: 20px; height: 20px; }

body.signed-in main {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.warn-label { color: var(--warning); }

h1 {
  margin: 0 0 0.45rem;
  font-size: 1.45rem;
  line-height: 1.2;
}

h2 {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
}

.muted { color: var(--muted); }

.gate {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.gate-card {
  width: min(520px, 100%);
  padding: 1.4rem 1.3rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: var(--panel-soft);
}

.gate-card .btn { margin-top: 1rem; }

.blocked-summary {
  margin: 0 0 0.55rem;
}

.steps {
  margin: 0;
  padding-left: 1.2rem;
}

.steps li { margin: 0.4rem 0; }

.spinner {
  width: 28px;
  height: 28px;
  margin-bottom: 1rem;
  border: 3px solid var(--line-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--primary);
  border-radius: 0.4rem;
  background: var(--primary);
  color: #09090b;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover { background: #6ee7b7; }
.btn.btn-secondary {
  margin-top: 0.5rem;
  border-color: var(--line-light);
  background: transparent;
  color: var(--text);
}
.btn.btn-secondary:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--text);
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn:focus-visible,
.google-signin:focus-visible,
.user-logout:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.banner {
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--panel);
}

.banner.warn {
  border-color: rgba(251, 191, 36, 0.45);
  color: #fde68a;
}

.map-stage { height: 100%; }

#map {
  height: 100%;
  width: 100%;
  background: var(--bg);
}

.leaflet-container { font: inherit; }

.map-card {
  position: absolute;
  z-index: 500;
  top: 0.75rem;
  left: 0.75rem;
  width: min(340px, calc(100% - 4.5rem));
  max-height: calc(100% - 1.5rem);
  overflow: auto;
  padding: 1rem 1rem 0.9rem;
  border: 1px solid var(--line-light);
  border-radius: 0.85rem;
  background: rgba(17, 17, 19, 0.94);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.map-card h1 { font-size: 1.25rem; }

.docs-link {
  display: inline-block;
  margin: 0.15rem 0 0.85rem;
  font-weight: 600;
}

.card-rule {
  margin: 0.95rem 0 0.8rem;
  border: 0;
  border-top: 1px solid var(--line-light);
}

.site-choice {
  margin: 0;
  padding: 0;
  border: 0;
}

.site-choice legend {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.4rem 0;
  cursor: pointer;
}

.site-choice:disabled {
  opacity: 0.55;
}

.site-choice:disabled .choice { cursor: not-allowed; }

#existing-site-panel,
#new-site-panel { margin-top: 0.85rem; }

#send-layer-button,
#begin-demo-button { margin-top: 0.75rem; }

.legend {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.swatch {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid var(--primary);
  border-radius: 50%;
  background: var(--primary-soft);
}

#location-summary { margin: 0 0 0.85rem; }

.field-label {
  display: block;
  margin: 0.85rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.layer-select {
  width: 100%;
  min-height: 40px;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line-light);
  border-radius: 0.4rem;
  background: #09090b;
  color: var(--text);
  font: inherit;
}

.layer-select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

#existing-layer-status {
  margin: 0.35rem 0 0.75rem;
  font-size: 0.78rem;
}

.places-panel { margin: 0.9rem 0 0; }

.places-panel h2 {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.places-panel .muted { margin: 0; font-size: 0.78rem; }

.places-list {
  max-height: 180px;
  margin: 0.45rem 0 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.places-list li + li { border-top: 1px solid var(--line); }

.place-button {
  display: block;
  width: 100%;
  padding: 0.45rem 0.1rem;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.place-button:hover,
.place-button:focus-visible,
.place-button.selected { background: var(--primary-soft); }

#geofence-status {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
}

.place-name {
  display: block;
  font-weight: 600;
}

.place-meta {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.demo-status {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
}

.demo-status.error { color: #fecaca; }
.demo-status.info { color: var(--muted); }
.demo-status.success { color: var(--primary); }

.layer-note {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.hidden { display: none !important; }

@media (max-width: 600px) {
  .topbar { padding: 0 1rem; }
  .user-summary-name { display: none; }
  .brand-name { font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .user-chevron { transition: none; }
}
