:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f1f5f9;
  color: #111827;
}

* {
  box-sizing: border-box;
}

body,
html {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
}

body {
  overflow: hidden;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.topbar__brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #0f172a;
}

.topbar__nav {
  display: flex;
  gap: 1rem;
}

.topbar__actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.notification-button {
  position: relative;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  background: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #334155;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.notification-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.notification-icon {
  font-size: 1.1rem;
}

.notification-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 5px;
}

.notification-panel {
  position: absolute;
  right: 0;
  top: 56px;
  width: 320px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
  padding: 0.85rem;
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.notification-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.notification-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.notification-panel__header span {
  font-weight: 700;
  color: #0f172a;
}

.notification-clear {
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-size: 0.85rem;
}

.notifications-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.8rem;
  max-height: 240px;
  overflow-y: auto;
}

.notification-item {
  border-radius: 18px;
  padding: 0.95rem 1rem;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.14);
  display: grid;
  gap: 0.35rem;
}

.notification-item span {
  display: block;
  color: #475569;
  font-size: 0.85rem;
}

.notification-item--empty {
  text-align: center;
  color: #64748b;
  padding: 1rem 0;
}

.topbar__nav a {
  color: #334155;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}

.topbar__nav a:hover {
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 320px) 1fr;
  gap: 1.25rem;
  padding: 1.25rem;
  flex: 1;
}

.sidebar {
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}

.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 24px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.06);
}

.panel__header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.panel__header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #0f172a;
}

.panel__header p {
  margin: 0.5rem 0 0;
  color: #475569;
  line-height: 1.6;
}

.layer-list {
  display: grid;
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.25rem;
}

.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.14);
  font-size: 0.95rem;
  color: #1e293b;
}

.layer-item__label {
  flex: 1;
}

.layer-item__switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.layer-item__switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.switch-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.14);
  transition: transform 0.2s ease;
}

.layer-item__switch input:checked + .switch-slider {
  background: #6366f1;
}

.layer-item__switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.panel__section {
  padding: 1.25rem 1.5rem 0;
}

.panel__header--categories {
  padding: 1.5rem 1.5rem 0;
}

.panel__header--categories h2 {
  margin: 0;
  font-size: 1.1rem;
  color: #0f172a;
}

.panel__header--categories p {
  margin: 0.5rem 0 0;
  color: #475569;
  line-height: 1.6;
}

.map-filter__label {
  display: block;
  margin-bottom: 0.75rem;
  color: #0f172a;
  font-weight: 600;
}

.map-style-select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  color: #0f172a;
  background: #ffffff;
}

.categories-container {
  display: grid;
  gap: 1rem;
  padding: 1rem 1.5rem 1.25rem;
}

.category-card {
  border-radius: 20px;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

.category-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #0f172a;
}

.category-header:hover {
  background: rgba(99, 102, 241, 0.06);
}

.category-title {
  font-weight: 700;
}

.category-meta {
  margin-top: 0.25rem;
  color: #475569;
  font-size: 0.85rem;
}

.category-pill {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 0.75rem;
}

.category-header > div {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.category-arrow {
  transition: transform 0.2s ease;
}

.category-card.expanded .category-arrow {
  transform: rotate(180deg);
}

.subcategory-list {
  display: grid;
  grid-gap: 0.75rem;
  padding: 0 1rem 1rem;
}

.category-card.expanded .subcategory-list {
  display: grid;
}

.subcategory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.85rem;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 0.95rem;
  color: #1e293b;
}

.subcategory-label {
  display: block;
  font-weight: 600;
}

.subcategory-note {
  display: block;
  color: #64748b;
  font-size: 0.82rem;
  margin-top: 0.2rem;
}

.layer-item__switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.layer-item__switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.switch-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.14);
  transition: transform 0.2s ease;
}

.layer-item__switch input:checked + .switch-slider {
  background: #6366f1;
}

.layer-item__switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.panel__note {
  padding: 0 1.5rem 1.5rem;
  color: #334155;
  line-height: 1.6;
}

.map-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 90px - 2.5rem);
  border-radius: 28px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.94) 0%, rgba(248,250,252,1) 100%);
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: 0 25px 55px rgba(15, 23, 42, 0.08);
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem 1.75rem 0;
}

.map-header h1 {
  margin: 0;
  font-size: 1.55rem;
  color: #0f172a;
}

.map-header p {
  margin: 0.5rem 0 0;
  color: #475569;
}

.map-header__status {
  align-self: center;
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
}

#map {
  flex: 1;
  min-height: 520px;
  position: relative;
  z-index: 0;
}

.map-panel {
  position: relative;
  z-index: 0;
}

.map-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.92);
}

.map-footer__info,
.map-footer__legend {
  color: #334155;
  font-size: 0.95rem;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin: 0 0.35rem 0 0.75rem;
  vertical-align: middle;
}

.leaflet-legend {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  font-size: 0.9rem;
  color: #0f172a;
}

.leaflet-legend .legend-title {
  font-weight: 700;
  margin-bottom: 0.55rem;
}

.leaflet-legend .legend-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}

.leaflet-legend .legend-row:last-child {
  margin-bottom: 0;
}

.leaflet-legend .legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
}

.cctv-popup {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.75rem;
}

.cctv-view-btn {
  appearance: none;
  border: none;
  background: #4338ca;
  color: #ffffff;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cctv-view-btn:hover {
  background: #3730a3;
}

.cctv-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cctv-preview img {
  width: 80px;
  height: 56px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.cctv-preview span {
  color: #475569;
  font-size: 0.85rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 760px;
  border-radius: 28px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.24);
}

.modal-close {
  position: absolute;
  right: 1rem;
  top: 1rem;
  border: none;
  background: transparent;
  font-size: 1.6rem;
  cursor: pointer;
  color: #0f172a;
}

.modal-body {
  padding: 1.75rem 1.75rem 1.5rem;
}

.modal-body h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  color: #0f172a;
}

.modal-media {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.modal-media img,
.modal-media video {
  width: 100%;
  border-radius: 18px;
  background: #f8fafc;
}

@media (max-width: 720px) {
  .modal-media {
    grid-template-columns: 1fr;
  }

  .map-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .topbar__nav {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .map-header {
    padding: 1.25rem 1.25rem 0;
  }

  .map-footer {
    padding: 1rem 1.25rem;
  }
}
