:root {
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #677083;
  --line: #d9e0e8;
  --brand: #ff7f23;
  --blue: #0b2c70;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  background: #07163a;
  color: #fff;
}

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

.brand img {
  width: 36px;
  height: 36px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.user-box {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.nav-actions {
  display: grid;
  gap: 8px;
}

.nav-link {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  text-align: left;
  padding: 0 14px;
}

.nav-link.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #151515;
  font-weight: 700;
}

.user-box {
  margin-top: auto;
  line-height: 1.45;
}

.main-content {
  min-width: 0;
}

.view {
  display: none;
  min-height: 100vh;
}

.view.active {
  display: block;
}

#view-map {
  position: relative;
}

#photoMap {
  height: 100vh;
  width: 100%;
}

.map-toolbar,
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
}

.map-toolbar {
  position: absolute;
  z-index: 500;
  top: 16px;
  left: 16px;
  right: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 22px;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
}

.secondary-button,
.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  padding: 0 16px;
  font-weight: 700;
}

.secondary-button {
  background: #eef3f8;
  color: var(--blue);
}

.primary-button {
  width: 100%;
  background: var(--brand);
  color: #1d1d1d;
}

#photoSearch {
  width: min(420px, 100%);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 20px;
}

.photo-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.photo-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #d9e0e8;
}

.photo-card-body {
  padding: 12px;
}

.photo-card-body strong {
  display: block;
  font-size: 14px;
  word-break: break-word;
}

.photo-card-body small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.upload-panel {
  width: min(680px, calc(100% - 32px));
  margin: 24px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.content-header.compact {
  border-radius: 8px 8px 0 0;
}

#uploadForm {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 170px;
  border: 1px dashed #9aa7b7;
  border-radius: 8px;
  background: #f7f9fb;
  cursor: pointer;
  text-align: center;
}

.drop-zone span {
  color: var(--blue);
  font-weight: 700;
}

.drop-zone small {
  color: var(--muted);
}

.drop-zone input {
  display: none;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.progress-bar {
  height: 8px;
  margin: 0 20px 20px;
  overflow: hidden;
  border-radius: 999px;
  background: #d8e0ea;
}

.progress-bar.hidden {
  display: none;
}

#progress {
  width: 0;
  height: 100%;
  background: var(--brand);
  transition: width 180ms ease;
}

.upload-results {
  display: grid;
  gap: 12px;
  padding: 0 20px 20px;
}

.upload-result {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.upload-result img {
  width: 96px;
  height: 96px;
  border-radius: 6px;
  object-fit: cover;
}

.photo-cluster {
  position: relative;
  width: 86px;
  height: 76px;
  transform: translate(-28px, -52px);
}

.photo-cluster img {
  width: 76px;
  height: 64px;
  border: 4px solid #fff;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}

.photo-cluster span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
}

.photo-cluster::after {
  content: "";
  position: absolute;
  left: 30px;
  bottom: -6px;
  width: 18px;
  height: 18px;
  background: #fff;
  transform: rotate(45deg);
}

.leaflet-div-icon {
  background: transparent;
  border: 0;
}

.photo-drawer {
  position: fixed;
  z-index: 1000;
  right: 18px;
  bottom: 18px;
  display: none;
  width: min(420px, calc(100% - 36px));
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.photo-drawer.open {
  display: block;
}

.photo-drawer img {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  display: block;
}

.drawer-close {
  position: absolute;
  right: 10px;
  top: 10px;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: rgba(7, 22, 58, 0.9);
  color: #fff;
  cursor: pointer;
}

.drawer-body {
  padding: 16px;
}

.drawer-body h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.drawer-body dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  margin: 0;
  color: var(--muted);
}

.drawer-body dt {
  color: var(--ink);
  font-weight: 700;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: fixed;
    z-index: 700;
    left: 12px;
    right: 12px;
    bottom: 12px;
    display: grid;
    grid-template-columns: 1fr;
    padding: 10px;
    border-radius: 14px;
  }

  .brand,
  .user-box {
    display: none;
  }

  .nav-actions {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-link {
    text-align: center;
  }

  .map-toolbar,
  .content-header {
    align-items: stretch;
    flex-direction: column;
  }

  .map-toolbar {
    top: 12px;
    left: 12px;
    right: 12px;
  }

  #photoMap {
    height: 100vh;
  }

  .view {
    padding-bottom: 88px;
  }
}
