:root {
  --bg: #05060a;
  --text: #e9eef5;
  --muted: #a2b0c2;
  --border: rgba(255,255,255,0.08);
  --blood: #c61a1a;
  --bone: #e7e2da;
  --glow: rgba(198,26,26,0.22);
  --sidebar-width: 460px;
}

* {
  box-sizing: border-box;
}

html, body { 
  height: 100%; 
  margin: 0; 
  background: var(--bg); 
  color: var(--text); 
}

body { 
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; 
  overflow: hidden; 
}

body::before {
  content: "";
  position: fixed; 
  inset: 0;
  background:
    radial-gradient(1200px 800px at 18% 12%, rgba(198,26,26,0.12), transparent 56%),
    radial-gradient(900px 700px at 90% 20%, rgba(231,226,218,0.05), transparent 60%),
    radial-gradient(1400px 900px at 50% 110%, rgba(0,0,0,0.8), transparent 60%),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.018) 0 2px, transparent 2px 6px);
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.55;
}

#app { 
  height: 100%; 
  display: grid; 
  grid-template-columns: var(--sidebar-width) 1fr; 
}

/* ===== SIDEBAR ===== */
#sidebar {
  position: relative;
  background: linear-gradient(180deg, rgba(8,10,16,0.88), rgba(7,9,21,0.92));
  border-right: 1px solid var(--border);
  box-shadow: 12px 0 60px rgba(0,0,0,0.35);
  overflow: auto;
  padding: 24px 20px 24px 20px;
  backdrop-filter: blur(10px);
}

#sidebar::before {
  content: "";
  position: absolute;
  left: 20px; 
  right: 20px; 
  top: 16px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--blood), transparent);
  box-shadow: 0 0 26px var(--glow);
  opacity: 0.8;
  border-radius: 999px;
}

/* ===== TYPOGRAPHY ===== */
.title {
  font-family: "UnifrakturCook", serif;
  font-size: 32px;
  margin: 16px 0 20px 0;
  letter-spacing: 0.6px;
  line-height: 1.05;
  text-shadow: 0 0 24px rgba(198,26,26,0.16);
  user-select: none;
}

/* ===== MAP ===== */
#mapWrap { 
  position: relative; 
  height: 100%; 
}

#map { 
  height: 100%; 
}

/* ===== SEARCH ===== */
.topbar { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  margin-bottom: 20px; 
}

.search { 
  flex: 1; 
  position: relative; 
}

input {
  width: 100%;
  padding: 13px 14px 13px 42px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(4,6,10,0.72);
  color: var(--text);
  outline: none;
  font-size: 14px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35) inset, 0 10px 30px rgba(0,0,0,0.18);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

input:focus {
  border-color: rgba(198,26,26,0.55);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35) inset, 0 0 0 3px rgba(198,26,26,0.10), 0 10px 30px rgba(0,0,0,0.22);
  transform: translateY(-1px);
}

input::placeholder { 
  color: rgba(162,176,194,0.68); 
}

.search::before {
  content: "⌕";
  position: absolute;
  left: 14px; 
  top: 50%;
  transform: translateY(-50%);
  color: rgba(231,226,218,0.75);
  font-size: 16px;
  opacity: 0.9;
  pointer-events: none;
}

/* ===== STATS CHIPS ===== */
.stats { 
  display: flex; 
  gap: 10px; 
  flex-wrap: wrap; 
  margin: 0 0 24px 0; 
}

.chip {
  display: inline-flex; 
  align-items: center; 
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(4,6,10,0.55);
  box-shadow: 0 10px 30px rgba(0,0,0,0.14);
  font-size: 13px;
  color: rgba(231,226,218,0.85);
  user-select: none;
}

.chip b { 
  color: var(--bone); 
  font-weight: 900; 
  letter-spacing: 0.2px; 
}

.dot { 
  width: 6px; 
  height: 6px; 
  border-radius: 50%; 
  background: var(--blood); 
  box-shadow: 0 0 16px var(--glow); 
}

/* ===== CONTROLS ===== */
.controls {
  background: rgba(4,6,10,0.35);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 20px;
}

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

.controls-title { 
  font-weight: 900; 
  font-size: 13px;
  letter-spacing: 0.3px; 
  color: rgba(231,226,218,0.92); 
  user-select: none; 
  text-transform: uppercase;
}

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

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(4,6,10,0.62);
  color: rgba(231,226,218,0.92);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
  white-space: nowrap;
}

.btn:hover { 
  transform: translateY(-1px); 
  border-color: rgba(198,26,26,0.40); 
  background: rgba(198,26,26,0.10); 
}

.btn:active { 
  transform: translateY(0px); 
}

.btn-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(4,6,10,0.62);
  color: rgba(231,226,218,0.92);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
  white-space: nowrap;
}

.btn-mini:hover { 
  transform: translateY(-1px); 
  border-color: rgba(198,26,26,0.40); 
  background: rgba(198,26,26,0.10); 
}

.btn .badge {
  display: inline-flex; 
  align-items: center; 
  justify-content: center;
  min-width: 20px; 
  height: 20px; 
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(198,26,26,0.22);
  border: 1px solid rgba(198,26,26,0.35);
  color: var(--bone);
  font-weight: 900;
  font-size: 11px;
}

/* ===== PANEL (LIST) ===== */
.panel {
  background: rgba(4,6,10,0.40);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 55px rgba(0,0,0,0.30);
}

.panel-header {
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(90deg, rgba(198,26,26,0.08), transparent 55%);
}

.panel-header .h { 
  font-weight: 900; 
  font-size: 14px;
  letter-spacing: 0.3px; 
  color: rgba(231,226,218,0.92); 
  user-select: none; 
  text-transform: uppercase;
}

.panel-header .sub { 
  font-size: 12px; 
  color: rgba(162,176,194,0.78); 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  max-width: 260px; 
}

.panel-body { 
  padding: 8px 10px; 
  max-height: calc(100vh - 480px); 
  overflow: auto; 
}

/* ===== BAND ITEMS ===== */
.band {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  border-radius: 12px;
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.band:last-child { 
  border-bottom: none; 
}

.band:hover { 
  background: rgba(198,26,26,0.06); 
  box-shadow: 0 0 0 1px rgba(198,26,26,0.10) inset; 
}

.band.active {
  background: rgba(198,26,26,0.14);
  box-shadow: 0 0 0 1px rgba(198,26,26,0.20) inset, 0 0 22px rgba(198,26,26,0.18);
}

.name { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  font-weight: 900; 
  font-size: 14px;
  letter-spacing: 0.15px; 
}

.sigil { 
  width: 8px; 
  height: 8px; 
  background: var(--blood); 
  box-shadow: 0 0 18px var(--glow); 
  transform: rotate(45deg); 
  flex: 0 0 auto; 
}

a { 
  color: var(--text); 
  text-decoration: none; 
}

a:hover { 
  color: var(--bone); 
  text-decoration: underline; 
}

.meta { 
  margin-top: 8px; 
  font-size: 12px; 
  color: rgba(162,176,194,0.88); 
  line-height: 1.5; 
}

.meta b { 
  color: rgba(231,226,218,0.92); 
  font-weight: 700; 
}

/* ===== FILTERS ===== */
.grid2 { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 12px; 
}

.filter-box {
  background: rgba(4,6,10,0.35);
  border-radius: 16px;
  padding: 14px;
}

.filter-title {
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.3px;
  color: rgba(231,226,218,0.92);
  margin-bottom: 12px;
  text-transform: uppercase;
}

/* ===== SELECT ===== */
.select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(4,6,10,0.72);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.select:hover {
  border-color: rgba(198,26,26,0.30);
}

/* ===== TOGGLES (STATUS) ===== */
.chips { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 8px; 
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(4,6,10,0.55);
  cursor: pointer;
  user-select: none;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
  font-size: 12px;
  color: rgba(231,226,218,0.92);
  font-weight: 700;
}

.toggle:hover { 
  transform: translateY(-1px); 
  border-color: rgba(198,26,26,0.35); 
  background: rgba(198,26,26,0.08); 
}

.toggle .box {
  width: 14px; 
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(231,226,218,0.35);
  background: rgba(0,0,0,0.25);
  position: relative;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.20) inset;
  flex: 0 0 auto;
}

.toggle.on .box {
  border-color: rgba(198,26,26,0.55);
  background: rgba(198,26,26,0.18);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.20) inset, 0 0 18px rgba(198,26,26,0.14);
}

.toggle.on .box::after {
  content: "";
  position: absolute; 
  inset: 3px;
  background: rgba(231,226,218,0.80);
  border-radius: 2px;
  opacity: 0.85;
}

.count-badge { 
  color: rgba(162,176,194,0.90); 
  font-weight: 800; 
  font-size: 11px;
}

/* ===== MULTISELECT ===== */
.multiselect {
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(4,6,10,0.50);
  border-radius: 14px;
  overflow: hidden;
}

.ms-head {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.ms-search {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.30);
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.ms-search::placeholder {
  color: rgba(162,176,194,0.60);
}

.ms-actions { 
  display: flex; 
  gap: 6px; 
}

.ms-list {
  max-height: 200px;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ms-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.15);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  transition: border-color 120ms ease, background 120ms ease;
}

.ms-item:hover {
  border-color: rgba(198,26,26,0.30);
  background: rgba(198,26,26,0.08);
}

.ms-item.on {
  border-color: rgba(198,26,26,0.40);
  background: rgba(198,26,26,0.14);
}

/* ===== TIMELINE ===== */
.timeline { 
  padding: 8px 0 0 0; 
}

.timeline-meta { 
  margin-top: 14px; 
  display: flex; 
  gap: 10px; 
  flex-wrap: wrap; 
}

.noUi-target { 
  border: 1px solid rgba(255,255,255,0.10); 
  background: rgba(0,0,0,0.25); 
  box-shadow: none;
}

.noUi-connect { 
  background: rgba(198,26,26,0.35); 
}

.noUi-handle { 
  border-radius: 12px; 
  border: 1px solid rgba(255,255,255,0.12); 
  background: rgba(4,6,10,0.90); 
  box-shadow: 0 0 18px rgba(198,26,26,0.14); 
}

/* ===== LEAFLET CUSTOMIZATION ===== */
.leaflet-popup-content-wrapper, 
.leaflet-popup-tip {
  background: rgba(4,6,10,0.92);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  backdrop-filter: blur(10px);
}

.leaflet-popup-content a {
  color: #e9eef5;
  text-decoration: none;
  transition: color 0.2s ease;
}

.leaflet-popup-content a:hover {
  color: #c61a1a;
  text-decoration: underline;
}

.leaflet-control-attribution {
  background: rgba(4,6,10,0.70) !important;
  color: rgba(162,176,194,0.85) !important;
  border: 1px solid rgba(255,255,255,0.08);
}

.leaflet-control-attribution a { 
  color: rgba(162,176,194,0.85) !important; 
}

.marker-cluster-small, 
.marker-cluster-medium, 
.marker-cluster-large { 
  background-color: rgba(198,26,26,0.16) !important; 
}

.marker-cluster-small div, 
.marker-cluster-medium div, 
.marker-cluster-large div {
  background-color: rgba(198,26,26,0.30) !important;
  color: var(--text) !important;
  border: 1px solid rgba(198,26,26,0.42);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25) inset, 0 0 18px rgba(198,26,26,0.16);
  font-weight: 900;
}

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; 
  inset: 0;
  background: rgba(0,0,0,0.60);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}

.modal-backdrop.on { 
  display: flex; 
}

.modal {
  width: min(960px, 96vw);
  max-height: min(88vh, 900px);
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(4,6,10,0.92);
  box-shadow: 0 30px 90px rgba(0,0,0,0.70);
  backdrop-filter: blur(12px);
}

.modal-head {
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(90deg, rgba(198,26,26,0.08), transparent 55%);
}

.modal-head .h { 
  font-weight: 900; 
  font-size: 14px;
  color: rgba(231,226,218,0.92); 
  letter-spacing: 0.3px; 
  text-transform: uppercase;
}

.modal-head .x {
  width: 36px; 
  height: 36px;
  display: grid; 
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(4,6,10,0.55);
  cursor: pointer; 
  user-select: none;
  font-weight: 900; 
  font-size: 16px;
  color: rgba(231,226,218,0.90);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.modal-head .x:hover {
  transform: scale(1.05);
  border-color: rgba(198,26,26,0.40); 
  background: rgba(198,26,26,0.10); 
}

.modal-body { 
  padding: 12px 14px; 
  overflow: auto; 
  max-height: calc(88vh - 66px); 
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.20);
}

::-webkit-scrollbar-thumb {
  background: rgba(198,26,26,0.30);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(198,26,26,0.45);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  :root {
    --sidebar-width: 400px;
  }
  
  .title {
    font-size: 28px;
  }
}

@media (max-width: 992px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  
  :root {
    --sidebar-width: 100%;
  }
  
  #sidebar {
    max-height: 40vh;
    overflow-y: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  #sidebar::before {
    left: 16px;
    right: 16px;
  }
  
  .panel-body {
    max-height: 30vh;
  }
  
  .grid2 {
    grid-template-columns: 1fr;
  }
  
  .details {
    width: min(calc(100vw - 28px), 440px);
    max-height: 60vh;
  }
}

@media (max-width: 640px) {
  #sidebar {
    padding: 16px 14px;
  }
  
  .title {
    font-size: 24px;
    margin: 12px 0 16px 0;
  }
  
  .stats {
    gap: 8px;
  }
  
  .chip {
    padding: 7px 10px;
    font-size: 12px;
  }
  
  .controls {
    padding: 12px;
  }
  
  .btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .details {
    right: 8px;
    top: 8px;
    width: calc(100vw - 16px);
  }
}
