:root {
  /* Pastel Denver Broncos palette */
  --orange: #f3923f;          /* Broncos orange (full) */
  --orange-soft: #f7b27e;     /* pastel orange */
  --orange-pale: #fdeadb;     /* wash */
  --navy: #1f3a6e;            /* Broncos navy */
  --navy-soft: #7b94c9;       /* pastel navy/periwinkle */
  --navy-pale: #e6ebf6;       /* wash */

  /* Per-person accent colors (pastel Broncos family) */
  --c-scott: #f3923f;
  --c-scott-soft: #f9c79c;
  --c-katie: #7b94c9;
  --c-katie-soft: #b9c6e6;
  --c-denver: #6fb6d6;
  --c-denver-soft: #b3dcec;
  --c-vail: #ef9aa0;
  --c-vail-soft: #f6c8cb;

  --bg: #fbf7f0;
  --surface: #ffffff;
  --surface-2: #fdfaf4;
  --ink: #2c2a27;
  --ink-soft: #6f6a62;
  --ink-faint: #9b958c;
  --line: #ece4d7;
  --line-soft: #f3ede2;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(60, 50, 35, 0.06), 0 1px 2px rgba(60, 50, 35, 0.04);
  --shadow-md: 0 8px 24px rgba(60, 50, 35, 0.10), 0 2px 6px rgba(60, 50, 35, 0.06);
  --shadow-lg: 0 20px 50px rgba(40, 35, 25, 0.18);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
  width: 100vw;
}

/* ---------------- Sidebar ---------------- */
#sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(135deg, var(--orange-pale) 0%, var(--navy-pale) 130%);
}
.brand-mark { flex-shrink: 0; line-height: 0; }
.brand-text h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.32rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--navy);
}
.brand-text p {
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--orange);
  font-weight: 600;
  margin-top: 2px;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 12px;
}
.sidebar-scroll::-webkit-scrollbar { width: 8px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

.panel {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 14px;
}

/* People filter */
.people-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.person-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface);
  transition: all 0.18s ease;
  user-select: none;
}
.person-chip:hover { background: var(--surface-2); }
.person-chip .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--chip-color, var(--line));
  flex-shrink: 0;
  transition: border-color 0.18s ease;
}
.person-chip .pc-name {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1;
}
.person-chip .pc-count {
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-top: 2px;
}
.person-chip[data-active="false"] { opacity: 0.42; filter: grayscale(0.6); }
.person-chip[data-active="true"] {
  border-color: var(--chip-color);
  background: var(--chip-pale);
  box-shadow: var(--shadow-sm);
}

/* Select fields */
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field select {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%239b958c' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.18s ease;
}
.field select:focus { outline: none; border-color: var(--orange-soft); }

.reset-btn {
  width: 100%;
  margin-top: 4px;
  padding: 9px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy);
  background: var(--navy-pale);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.18s ease;
}
.reset-btn:hover { background: #d8e1f1; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.stat-card .stat-num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--navy);
}
.stat-card .stat-label {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-top: 4px;
  font-weight: 500;
}
.stat-card.accent { background: var(--orange-pale); border-color: #f6dcc4; }
.stat-card.accent .stat-num { color: var(--orange); }

/* Person stats table */
.person-stats { display: flex; flex-direction: column; gap: 8px; }
.ps-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ps-row .avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.ps-row .ps-name { font-size: 0.84rem; font-weight: 600; width: 56px; flex-shrink: 0; }
.ps-bar-track {
  flex: 1;
  height: 8px;
  background: var(--line-soft);
  border-radius: 6px;
  overflow: hidden;
}
.ps-bar-fill { height: 100%; border-radius: 6px; transition: width 0.4s ease; }
.ps-row .ps-val { font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); width: 26px; text-align: right; flex-shrink: 0; }

.sidebar-foot {
  padding: 12px 24px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 500;
}

/* ---------------- Map ---------------- */
#map-wrap { position: relative; height: 100vh; }
#map { height: 100%; width: 100%; background: #dfeaf0; }

.leaflet-container { font-family: var(--font-body); }

/* Custom marker */
.fam-marker {
  background: none !important;
  border: none !important;
}
/* Neutralize default markercluster chrome — we use our own pin */
.marker-cluster, .marker-cluster div {
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
}
.marker-cluster { margin: 0 !important; }
.leaflet-cluster-anim .leaflet-marker-icon { transition: transform 0.3s ease, opacity 0.3s ease; }
.marker-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -100%);
  cursor: pointer;
}
.marker-pin {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 999px;
  padding: 3px 7px 3px 3px;
  box-shadow: var(--shadow-md);
  border: 1.5px solid #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.marker-inner:hover .marker-pin { transform: scale(1.07); box-shadow: var(--shadow-lg); }
.marker-avatars { display: flex; }
.marker-avatars img {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  margin-left: -8px;
}
.marker-avatars img:first-child { margin-left: 0; }
.marker-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--navy);
  padding: 0 5px 0 6px;
}
.marker-tail {
  position: absolute;
  bottom: -6px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #fff;
  filter: drop-shadow(0 2px 1px rgba(60,50,35,0.12));
}

/* Map legend (bottom-left) */
.map-legend {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  box-shadow: var(--shadow-sm);
  font-size: 0.76rem;
}
.map-legend .ml-title {
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  font-size: 0.66rem; color: var(--ink-faint); margin-bottom: 7px;
}
.map-legend .ml-row { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.map-legend .ml-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.map-legend .ml-name { font-weight: 500; }

.mobile-toggle {
  display: none;
  position: absolute;
  top: 14px; left: 14px;
  z-index: 1100;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  color: var(--navy);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ---------------- Detail panel ---------------- */
.detail-panel {
  position: absolute;
  top: 0; right: 0;
  width: 380px;
  max-width: 90vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(110%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 1200;
  overflow-y: auto;
}
.detail-panel.open { transform: translateX(0); }
.detail-close {
  position: absolute;
  top: 14px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 1.3rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  z-index: 2;
}
.detail-close:hover { background: var(--line-soft); }

.detail-hero {
  padding: 28px 24px 20px;
  background: linear-gradient(135deg, var(--orange-pale), var(--navy-pale));
  border-bottom: 1px solid var(--line);
}
.detail-hero .dh-country {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--orange);
}
.detail-hero .dh-city {
  font-family: var(--font-display);
  font-weight: 600; font-size: 1.55rem; line-height: 1.12;
  color: var(--navy); margin: 6px 0 4px;
}
.detail-hero .dh-region { font-size: 0.86rem; color: var(--ink-soft); font-weight: 500; }
.detail-hero .dh-count { margin-top: 12px; font-size: 0.82rem; color: var(--ink-soft); }
.detail-hero .dh-count b { color: var(--navy); }
.detail-hero .dh-count .t-av {
  width: 26px; height: 26px; border-radius: 50%; object-fit: cover;
  border: 2px solid #fff; box-shadow: var(--shadow-sm);
}

.detail-body { padding: 8px 24px 32px; }
.trip-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  background: var(--surface-2);
}
.trip-card .tc-top {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; margin-bottom: 4px;
}
.trip-card .tc-dates { font-weight: 700; font-size: 0.94rem; color: var(--ink); }
.trip-card .tc-year {
  font-size: 0.74rem; font-weight: 700; color: var(--orange);
  background: var(--orange-pale); padding: 2px 9px; border-radius: 999px;
}
.trip-card .tc-acc { font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 8px; }
.trip-card .tc-acc.empty { display: none; }
.trip-card .tc-notes { font-size: 0.84rem; color: var(--ink); line-height: 1.5; }
.trip-card .tc-travelers { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.trip-card .tc-travelers .t-av {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
  border: 2px solid #fff; box-shadow: var(--shadow-sm);
}
.tc-conf {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 999px; margin-top: 10px;
  text-transform: uppercase;
}
.tc-conf::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.tc-conf.confirmed { background: #e6f3ea; color: #2f7d4f; }
.tc-conf.confirmed::before { background: #2f7d4f; }
.tc-conf.inferred { background: var(--navy-pale); color: #44588c; }
.tc-conf.inferred::before { background: #44588c; }
.tc-conf.unknown { background: #f4efe6; color: #8a7a5c; }
.tc-conf.unknown::before { background: #8a7a5c; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 12px; color: var(--ink-faint); text-align: center; padding: 40px;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 880px) {
  #app { grid-template-columns: 1fr; }
  #sidebar {
    position: absolute;
    top: 0; left: 0;
    width: 86vw; max-width: 360px;
    transform: translateX(-105%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
  }
  #sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: flex; }
  .detail-panel { width: 100vw; }
}

/* Basemap tints (keyless providers) */
.basemap-esri { filter: saturate(0.75) brightness(1.04); }
.basemap-osm  { filter: grayscale(0.85) brightness(1.08) sepia(0.12); }

/* Trends chart */
.trends svg { display: block; overflow: visible; }
.trends .tr-axis { stroke: var(--line); stroke-width: 1; }
.trends .tr-year { font-size: 9px; fill: var(--ink-faint); text-anchor: middle; font-weight: 600; }
.trends .tr-val { font-size: 8.5px; fill: var(--ink-soft); text-anchor: middle; font-weight: 700; }
.trends .tr-ymax { font-size: 8.5px; fill: var(--ink-faint); text-anchor: end; }
.trends .tr-mark { stroke: var(--navy); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.55; }
.trends .tr-mark-lbl { font-size: 8.5px; fill: var(--navy); font-weight: 700; letter-spacing: 0.02em; }
.trends rect { transition: opacity .15s ease; }
.trends rect:hover { opacity: 0.75; }
.tr-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; }
.tr-lg { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--ink-soft); font-weight: 500; }
.tr-lg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.trends-empty { font-size: 0.8rem; color: var(--ink-faint); }
