:root {
  --bg: #0b1020;
  --panel: #141b34;
  --panel-2: #1b2444;
  --panel-3: #24315f;
  --text: #eff3ff;
  --muted: #aab6da;
  --border: rgba(255,255,255,0.08);
  --accent: #7cb3ff;
  --accent-2: #c8dcff;
}

* { box-sizing: border-box; }

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

body {
  font-family: Inter, system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: #0e152a;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.view-switcher {
  display: flex;
  gap: 8px;
}

.view-section {
  display: none;
  min-height: calc(100vh - 95px);
}

.view-section.active {
  display: block;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

button {
  appearance: none;
  border: 1px solid transparent;
  background: var(--accent);
  color: #06101f;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

button.tab-btn.active {
  background: var(--accent);
  color: #06101f;
}

input[type="text"],
select {
  width: 100%;
  margin-top: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
}

input[type="range"] {
  width: 100%;
  margin-top: 6px;
}

label,
.checkbox-row {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
}

.button-row {
  display: flex;
  gap: 8px;
}

.cabinet-home,
.section-view,
.photo-viewer {
  height: 100%;
  padding: 20px;
  overflow: auto;
}

.cabinet-drawers {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.drawer-card {
  background: linear-gradient(180deg, #6a4b2f 0%, #5a3e25 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  padding: 18px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.07);
}

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

.drawer-title {
  font-size: 1.1rem;
  font-weight: 800;
}

.drawer-subtitle {
  color: #f6e6d4;
  opacity: 0.85;
}

.section-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.section-btn {
  min-width: 92px;
  background: rgba(255,255,255,0.12);
  color: #fff8f0;
  border: 1px solid rgba(255,255,255,0.15);
}

.section-btn:hover {
  background: rgba(255,255,255,0.18);
}

.section-btn .count {
  display: block;
  font-size: 0.8rem;
  color: #ebd6bf;
}

.section-toolbar,
.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.section-toolbar h2,
.viewer-meta h3 {
  margin: 0 0 4px;
}

.section-toolbar p,
.viewer-meta p {
  margin: 0;
  color: var(--muted);
}

.thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

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

.thumbnail-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #09101d;
}

.thumbnail-card .thumb-meta {
  padding: 10px;
  font-size: 0.9rem;
}

.thumb-title {
  font-weight: 700;
  margin-bottom: 4px;
  word-break: break-word;
}

.thumb-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.photo-stage {
  position: relative;
  min-height: 62vh;
  background: #070d18;
  border: 1px solid var(--border);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.photo-stage img {
  max-width: calc(100% - 140px);
  max-height: 58vh;
  object-fit: contain;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 54px;
  height: 54px;
  border-radius: 999px;
  padding: 0;
  font-size: 1.5rem;
  background: rgba(255,255,255,0.14);
  color: white;
  border: 1px solid rgba(255,255,255,0.18);
}

.nav-arrow.left { left: 18px; }
.nav-arrow.right { right: 18px; }

.viewer-counter {
  color: var(--muted);
  font-weight: 700;
}

.viewer-meta {
  margin-top: 16px;
}

.meta-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 12px;
}

.meta-pill {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--accent-2);
}

.viewer-meta-grid,
.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(200px, 1fr));
  gap: 12px 18px;
}

.viewer-meta-grid div,
.meta-grid div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-grid strong,
.viewer-meta-grid strong {
  color: var(--muted);
}

.meta-grid span,
.viewer-meta-grid span {
  white-space: pre-wrap;
  word-break: break-word;
}

/* MAP VIEW */

#mapView {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: calc(100vh - 95px);
}

.map-sidebar {
  overflow: auto;
  padding: 18px;
  background: #0e152a;
  border-right: 1px solid var(--border);
}

.map-main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 24px;
}

.map-photo-panel {
  border-radius: 0;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  margin: 0;
  overflow: visible;
}

.details-header,
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.details-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.details-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: visible;
}

.map-photo-section {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.map-photo-main {
  min-width: 0;
  overflow: visible;
}

.map-image-wrap {
  width: 100%;
  background: #070d18;
  border-radius: 16px;
  padding: 18px;
  min-height: 420px;
  height: 62vh;
  max-height: 62vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.map-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
}

.secondary-meta-grid {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  align-content: start;
  height: fit-content;
}

.map-panel-wrap {
  position: relative;
  margin-top: 8px;
  height: 340px;
  min-height: 340px;
  max-height: 340px;
  border-top: 1px solid var(--border);
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

.floating-btn {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 500;
  backdrop-filter: blur(4px);
}

.photo-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 36vh;
  overflow: auto;
}

.photo-item {
  text-align: left;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
}

.photo-item-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.photo-item-sub,
.photo-item-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: 0;
}

.empty-state {
  color: var(--muted);
  padding: 16px 0;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #111a32;
  color: var(--text);
}

@media (max-width: 1200px) {
  #mapView {
    grid-template-columns: 1fr;
  }

  .map-sidebar {
    max-height: 40vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .map-photo-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: start;
  }

  .details-content {
    grid-template-columns: 1fr;
  }

  .viewer-meta-grid,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .photo-stage img {
    max-width: calc(100% - 80px);
  }

  .nav-arrow {
    width: 42px;
    height: 42px;
  }

  .map-panel-wrap {
    height: 280px;
    min-height: 280px;
    max-height: 280px;
  }
}