:root {
  --bg: #f6f8ff;
  --surface: #ffffff;
  --surface-soft: #edf3ff;
  --surface-high: #dfe9ff;
  --text: #14233a;
  --muted: #66708a;
  --line: #d9e0f0;
  --primary: #0d52d8;
  --primary-deep: #0a44b0;
  --green: #64efb8;
  --green-deep: #00754d;
  --amber: #ffd6a5;
  --amber-deep: #875100;
  --danger: #c91919;
  --danger-soft: #ffd9d4;
  --shadow: 0 10px 24px rgba(13, 38, 76, 0.08);
  --shadow-strong: 0 18px 28px rgba(13, 82, 216, 0.3);
  --radius: 24px;
  --radius-lg: 32px;
  --radius-sm: 16px;
  --phone-width: 390px;
  --safe-bottom: calc(30px + env(safe-area-inset-bottom));
  font-family: "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(173, 203, 255, 0.55), transparent 30%),
    linear-gradient(180deg, #f9fbff 0%, #edf3ff 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 12px;
}

.phone {
  width: min(100%, var(--phone-width));
  min-height: 844px;
  background: var(--bg);
  border-radius: 40px;
  box-shadow: 0 30px 60px rgba(10, 34, 76, 0.16);
  overflow: hidden;
  position: relative;
}

.screen {
  display: none;
  min-height: 844px;
  padding: 18px 20px 116px;
  position: relative;
}

.screen.active {
  display: block;
}

.map-screen {
  padding: 0 0 106px;
  background: linear-gradient(180deg, #e2edf7 0%, #f4f8ff 58%, #f4f8ff 100%);
}

.map-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 85%, rgba(74, 184, 215, 0.65), transparent 22%),
    radial-gradient(circle at 84% 36%, rgba(92, 195, 227, 0.35), transparent 22%),
    linear-gradient(180deg, rgba(7, 56, 91, 0.78), rgba(107, 194, 210, 0.84)),
    linear-gradient(90deg, rgba(255,255,255,0.16) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.16) 1px, transparent 1px);
  background-size: auto, auto, auto, 30px 30px, 30px 30px;
  z-index: 0;
}

.map-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(60deg, transparent 0 18%, rgba(255,255,255,0.35) 18.5%, transparent 19.5% 43%, rgba(255,255,255,0.28) 44%, transparent 45% 100%),
    linear-gradient(102deg, transparent 0 28%, rgba(255,255,255,0.25) 28.4%, transparent 29.1% 55%, rgba(255,255,255,0.3) 55.5%, transparent 56% 100%),
    linear-gradient(0deg, transparent 0 14%, rgba(255,255,255,0.2) 14.5%, transparent 15.1% 34%, rgba(255,255,255,0.16) 34.5%, transparent 35% 100%);
  opacity: 0.7;
  z-index: 0;
}

.live-map-shell {
  position: absolute;
  inset: 78px 0 0;
  z-index: 1;
}

.live-map {
  position: absolute;
  inset: 0;
}

.map-embed-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.tile-map {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #dfe8f4, #cde3ed);
}

.tile-layer,
.tile-overlay {
  position: absolute;
  inset: 0;
}

.map-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  display: block;
  background: #d5e0e9;
}

.zone-circle {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(13, 82, 216, 0.65);
  background: rgba(84, 188, 255, 0.15);
}

.zone-circle.inside {
  border-color: rgba(20, 184, 110, 0.75);
  background: rgba(100, 239, 184, 0.18);
}

.zone-circle.disabled {
  border-style: dashed;
  opacity: 0.45;
}

.track-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.track-overlay polyline {
  fill: none;
  stroke: rgba(13, 82, 216, 0.78);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.center-marker {
  position: absolute;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  margin-top: -11px;
  border-radius: 50%;
  background: rgba(13, 82, 216, 0.15);
  display: grid;
  place-items: center;
}

.center-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #0d52d8;
  border: 2px solid #fff;
  box-shadow: 0 4px 10px rgba(13, 82, 216, 0.28);
}

.live-map .leaflet-control-attribution {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.82);
}

.live-map .leaflet-bottom {
  bottom: 250px;
}

.live-map .leaflet-control-zoom {
  display: none;
}

.permission-banner {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 16px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 6px;
}

.map-hint {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  background: rgba(13, 82, 216, 0.92);
  color: #fff;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow);
}

.permission-banner strong {
  font-size: 15px;
}

.permission-banner span {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.permission-btn {
  margin-top: 4px;
  min-height: 42px;
  border-radius: 12px;
  color: #fff;
  background: var(--primary);
  font-weight: 700;
}

.layer {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.map-top {
  padding: 18px 20px 0;
}

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

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #bcd0ff;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(13, 82, 216, 0.12);
  flex: 0 0 auto;
}

.avatar svg,
.marker-face svg {
  display: block;
  width: 100%;
  height: 100%;
}

.title {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  margin: 0;
}

.headline {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
  margin: 4px 0 14px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: transparent;
}

.caption {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 18px;
}

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

.small-note {
  font-size: 14px;
  color: #9099ad;
  margin: 0;
}

.card,
.alert-card,
.timeline-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card {
  padding: 16px;
  margin-bottom: 18px;
}

.badge-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.zone-head,
.alert-head,
.timeline-card-head,
.tracker-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.zone-name,
.alert-title,
.timeline-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.chip.green {
  background: rgba(100, 239, 184, 0.35);
  color: var(--green-deep);
}

.chip.gray {
  background: #e7edf9;
  color: #56627c;
}

.switch {
  display: inline-block;
  flex: 0 0 auto;
  width: 46px;
  height: 26px;
  background: #cfd7ea;
  border-radius: 999px;
  position: relative;
  flex: 0 0 auto;
  transition: background-color 0.2s ease;
}

.switch::after {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 3px;
  left: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
  transition: left 0.2s ease;
}

.switch.on {
  background: var(--primary);
}

.switch.on::after {
  left: 23px;
}

.switch-button {
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.map-preview {
  position: relative;
  height: 128px;
  border-radius: 16px;
  overflow: hidden;
  margin: 16px 0 14px;
  background:
    linear-gradient(125deg, rgba(255,255,255,0.7), rgba(186, 217, 226, 0.4)),
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.95) 0 8px, transparent 9px),
    linear-gradient(90deg, rgba(255,255,255,0.35) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.35) 1px, transparent 1px),
    linear-gradient(145deg, #d6eadf, #cfe8e8 48%, #e7f0da);
  background-size: auto, auto, 22px 22px, 22px 22px, auto;
}

.map-preview::before,
.map-preview::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

.map-preview::before {
  width: 96px;
  height: 96px;
  background: rgba(80, 205, 255, 0.18);
  border: 3px solid rgba(58, 179, 245, 0.7);
}

.map-preview::after {
  width: 56px;
  height: 56px;
  border: 3px solid rgba(54, 106, 226, 0.65);
}

.pin-dot {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #5ec5ee;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: #49556c;
}

.meta .link,
.text-link {
  color: var(--primary);
  font-weight: 600;
  background: transparent;
}

.compact-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--primary);
}

.float-tools {
  position: absolute;
  right: 20px;
  top: 108px;
  display: grid;
  gap: 10px;
  z-index: 2;
}

.tool {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  color: var(--primary);
  border: 0;
}

.tool.active {
  background: var(--primary);
  color: #fff;
}

.live-marker-icon {
  background: transparent;
  border: 0;
}

.live-marker {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(180deg, #1c64f2, #0d52d8);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 18px rgba(13, 82, 216, 0.25);
  border: 2px solid #fff;
}

.child-marker {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.pulse {
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  background: rgba(20, 94, 255, 0.18);
  animation: pulse 2.4s infinite;
}

.marker-core {
  width: 64px;
  height: 64px;
  background: linear-gradient(180deg, #1b62f0, #0a49cb);
  border-radius: 50% 50% 50% 8px;
  transform: rotate(45deg);
  display: grid;
  place-items: center;
  box-shadow: 0 18px 24px rgba(7, 63, 173, 0.3);
}

.marker-face {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  transform: rotate(-45deg);
  border: 3px solid #fff;
  background: linear-gradient(180deg, #f7d7a8, #e4a567);
}

.bottom-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 28px 28px 0 0;
  padding: 16px 20px calc(24px + var(--safe-bottom));
  box-shadow: 0 -8px 30px rgba(19, 43, 92, 0.12);
  z-index: 2;
}

.handle {
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: #bfc7d8;
  margin: 0 auto 18px;
}

.battery-chip {
  background: rgba(100, 239, 184, 0.35);
  color: #037450;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.updated {
  color: #8a93a7;
  font-size: 12px;
  margin-top: 6px;
  text-align: right;
  font-style: italic;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.live-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.stat-box {
  background: #f2f6ff;
  border-radius: 14px;
  padding: 12px;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.map-attribution {
  margin: 14px 0 0;
  color: #8d96aa;
  font-size: 12px;
  line-height: 1.5;
}

.btn {
  border-radius: 16px;
  min-height: 60px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.secondary {
  border: 2px solid #c8cfdf;
  color: #4f596e;
  background: #fff;
}

.filter-row {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  overflow: auto;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-row.equal {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: visible;
}

.pill {
  min-width: 122px;
  padding: 14px 24px;
  border-radius: 999px;
  font-size: 17px;
  text-align: center;
  background: var(--surface-high);
  color: #4e5a73;
  white-space: nowrap;
}

.filter-row.equal .pill {
  min-width: 0;
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pill.icon-only {
  padding-inline: 12px;
}

.pill.active {
  background: var(--primary);
  color: #fff;
}

.alert-card {
  padding: 22px 22px 24px;
  margin-bottom: 20px;
}

.alert-card.danger {
  background: var(--danger-soft);
  border: 1px solid rgba(201, 25, 25, 0.28);
}

.circle-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.time {
  font-size: 16px;
  color: #8a90a3;
  white-space: nowrap;
}

.alert-body {
  margin-top: 8px;
  font-size: 17px;
  line-height: 1.55;
}

.danger-btn {
  width: 100%;
  min-height: 58px;
  border-radius: 12px;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #c0c6d8;
  margin: 28px 0 18px;
  font-size: 14px;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: #d5dced;
  flex: 1;
}

.timeline {
  position: relative;
  margin-top: 6px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 20px;
  top: 16px;
  bottom: 40px;
  width: 2px;
  background: repeating-linear-gradient(to bottom, #cad3e6, #cad3e6 5px, transparent 5px, transparent 10px);
}

.timeline-entry {
  position: relative;
  padding-left: 48px;
  margin-bottom: 24px;
}

.timeline-icon {
  position: absolute;
  left: 0;
  top: 2px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 4px solid #f6f8ff;
  box-shadow: 0 6px 14px rgba(22, 41, 77, 0.08);
}

.timeline-card {
  padding: 16px 16px 14px;
  border: 1px solid #d3dbef;
}

.timeline-card.highlight {
  border: 2px solid #d4e0ff;
}

.timeline-range {
  font-size: 15px;
  color: #4f586f;
  margin: 6px 0 0;
}

.history-meta {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  font-size: 13px;
  color: #60708b;
}

.timeline-duration {
  background: #e6edff;
  color: #5c6782;
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #038351;
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
}

.timeline-media {
  margin-top: 12px;
  height: 126px;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(106, 205, 245, 0.58), transparent 20%),
    linear-gradient(145deg, #0d1927 10%, #133d56 46%, #0a1623 100%);
  position: relative;
}

.timeline-media::before {
  content: "";
  position: absolute;
  width: 90px;
  height: 90px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(124, 200, 231, 0.65), rgba(84, 145, 177, 0.7));
  box-shadow: 0 10px 26px rgba(6, 19, 35, 0.32);
}

.timeline-media::after {
  content: "";
  position: absolute;
  width: 38px;
  height: 38px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 5px solid #244e71;
  box-shadow: 0 0 0 10px rgba(217, 239, 248, 0.45);
}

.media-label {
  position: absolute;
  left: 12px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.current-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d98793;
  display: inline-block;
  vertical-align: middle;
  margin: 0 4px;
}

.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 28px 28px 0 0;
  padding: 10px 12px var(--safe-bottom);
  box-shadow: 0 -6px 20px rgba(17, 43, 87, 0.08);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  z-index: 4;
}

.nav-item {
  min-height: 64px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #384255;
  font-size: 12px;
  font-weight: 700;
  background: transparent;
}

.nav-item.active {
  background: linear-gradient(180deg, #79f1c3, #62eab6);
  color: #0f5a48;
}

.floating-add {
  position: absolute;
  right: 24px;
  bottom: calc(88px + var(--safe-bottom));
  background: linear-gradient(180deg, #1662e4, #0a4ccc);
  color: #fff;
  border-radius: 999px;
  min-width: 160px;
  min-height: 58px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  box-shadow: var(--shadow-strong);
  z-index: 3;
}

.safezone-detail-row {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.safezone-actions {
  display: flex;
  justify-content: flex-end;
}

.safezone-radius {
  color: #627089;
  font-weight: 600;
  white-space: nowrap;
}

.empty-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.empty-card strong {
  display: block;
  margin-bottom: 6px;
}

.empty-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.7;
  }

  70% {
    transform: scale(1.6);
    opacity: 0;
  }

  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding: 0;
  }

  .phone {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
  }

  .screen {
    min-height: 100vh;
  }

  .filter-row.equal {
    gap: 10px;
  }

  .filter-row.equal .pill {
    font-size: 14px;
    padding: 11px 10px;
  }
}
