:root {
  --navy: #1e3a8a;
  --blue: #3b82f6;
  --sky: #0ea5e9;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --page: #f1f5f9;
  --card: #ffffff;
  --trail-green: #3d9b47;
  --trail-blue: #2f7fbd;
}

*, *::before, *::after { box-sizing: border-box; }

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

body.dash {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.dash-skip {
  position: absolute;
  left: 8px;
  top: -40px;
  z-index: 20;
  padding: 8px 10px;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
}

.dash-skip:focus { top: 8px; }

.dash-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.dash-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.dash-brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.dash-brand strong {
  display: block;
  font-size: 16px;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.dash-brand em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.dash-status {
  margin: 0;
  flex: 1;
  font-size: 13px;
  color: var(--muted);
}

.dash-nav {
  display: flex;
  gap: 18px;
}

.dash-nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.dash-nav a:hover { color: var(--blue); }

.dash-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dash-kpi {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.dash-kpi:first-child {
  grid-column: 1 / -1;
}

.dash-kpi-label,
.dash-kpi-meta {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.dash-kpi-label {
  font-weight: 600;
}

.dash-kpi-value {
  margin: 4px 0 2px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--navy);
}

.dash-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  padding: 12px 20px 12px;
  position: relative;
  z-index: 2;
}

.dash-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}

.dash-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.dash-panel-head .dash-section-label {
  margin: 0;
}

.dash-panel-head .dash-status {
  margin: 4px 0 0;
  font-size: 12px;
}

.dash-panel-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.dash-map-toggle {
  flex-shrink: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.dash-map-toggle:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.dash-body.is-map-max {
  grid-template-columns: 52px minmax(0, 1fr);
}

.dash-body.is-map-max .dash-panel {
  padding: 8px;
  align-items: stretch;
}

.dash-body.is-map-max .dash-panel-body,
.dash-body.is-map-max .dash-panel-head .dash-section-label {
  display: none;
}

.dash-body.is-map-max .dash-panel-head {
  flex: 1;
  justify-content: center;
}

.dash-body.is-map-max .dash-map-toggle {
  width: 100%;
  height: 100%;
  min-height: 120px;
  padding: 12px 8px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.04em;
}

.dash-section-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.dash-section-label output,
.dash-section-label span {
  color: var(--blue);
  font-weight: 600;
}

.dash-pass-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dash-pass-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.dash-pass-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
}

.dash-pass-card img {
  height: 13px;
  width: auto;
  filter: grayscale(1);
  opacity: 0.45;
}

.dash-pass-card strong {
  font-size: 22px;
  line-height: 1.15;
  color: var(--ink);
}

.dash-pass-card em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.dash-pass-card.is-active {
  border-color: var(--pass-color, var(--blue));
  background: #fff;
  color: var(--ink);
}

.dash-pass-card.is-active img {
  filter: none;
  opacity: 1;
}

.dash-pass-card:not(.is-active) strong,
.dash-pass-card:not(.is-active) em {
  opacity: 0.4;
}

.dash-discipline-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dash-discipline-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.dash-discipline-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.dash-discipline-hint {
  font-size: 11px;
  line-height: 1.3;
}

.dash-discipline-card.is-active {
  border-color: var(--navy);
  background: #fff;
  color: var(--ink);
}

.dash-discipline-card:not(.is-active) .dash-discipline-label,
.dash-discipline-card:not(.is-active) .dash-discipline-hint {
  opacity: 0.45;
}

.mtn-map-layer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pass-color, var(--sky));
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.dash-roster {
  position: relative;
  z-index: 1;
  flex: 0 1 30vh;
  min-height: 160px;
  margin: 0 20px 16px;
  padding: 16px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dash-roster-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.dash-roster-head .dash-section-label {
  margin: 0;
  font-size: 15px;
}

.map-search-wrap {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, 90vw);
  z-index: 10;
  pointer-events: none;
}

.map-search-wrap > * {
  pointer-events: auto;
}

.dash-search-label {
  display: block;
  margin: 0;
}

.dash-search {
  width: 100%;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 24px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.dash-search::placeholder {
  color: #94a3b8;
}

.dash-search:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1), 0 1px 3px rgba(15, 23, 42, 0.06);
}

.dash-search:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.18), 0 2px 6px rgba(15, 23, 42, 0.08);
}

.map-search-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: 6px 0;
  border: 1px solid rgba(226, 232, 240, 0.98);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06);
  max-height: min(320px, 50vh);
  overflow: auto;
  overscroll-behavior: contain;
}

.map-search-suggestions[hidden] {
  display: none;
}

.map-search-option {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.map-search-option:hover,
.map-search-option.is-active {
  background: #f1f5f9;
}

.map-search-option:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.map-search-option-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.map-search-option-loc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.map-search-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

@media (prefers-reduced-motion: reduce) {
  .dash-search {
    transition: none;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dash-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px;
  min-height: 0;
  overflow: auto;
}

.dash-list-empty,
.mtn-map-empty {
  grid-column: 1 / -1;
  padding: 16px 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.dash-list-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f8fafc;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.dash-list-item:hover,
.dash-list-item.is-selected {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.dash-list-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.dash-list-meta {
  grid-column: 1;
  font-size: 12px;
  color: var(--muted);
}

.dash-list-passes {
  grid-row: 1 / span 2;
  align-self: center;
  display: flex;
  gap: 4px;
}

.dash-list-passes i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pass-color);
}

.dash-map {
  position: relative;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #dbeafe;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.map-legend {
  position: absolute;
  left: 12px;
  bottom: 28px;
  z-index: 8;
  width: 168px;
  padding: 8px 10px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.map-legend.is-min {
  width: auto;
  padding: 4px;
}

.map-legend-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin: 0 0 6px;
  padding: 2px 2px 2px 4px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  cursor: pointer;
  text-align: left;
}

.map-legend.is-min .map-legend-toggle {
  margin: 0;
  padding: 6px 8px;
}

.map-legend-chevron {
  width: 6px;
  height: 6px;
  border-right: 1.5px solid #94a3b8;
  border-bottom: 1.5px solid #94a3b8;
  transform: rotate(45deg);
  margin-top: -3px;
}

.map-legend.is-min .map-legend-chevron {
  transform: rotate(-135deg);
  margin-top: 2px;
}

.map-legend.is-min .map-legend-passes,
.map-legend.is-min .map-legend-shapes,
.map-legend.is-min .map-legend-shape-label {
  display: none;
}

.map-vertical {
  position: absolute;
  left: 196px;
  right: 12px;
  bottom: 28px;
  z-index: 8;
  max-width: 360px;
  margin-left: auto;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.map-vertical-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.map-vertical-label output {
  color: var(--blue);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.map-vertical input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--blue);
}

.map-legend-passes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: #1e293b;
}

.map-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
}

.map-dot--epic {
  background: #F37021;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.map-dot--ikon {
  background: #F5C518;
  border: 2px solid #0A1628;
}

.map-dot--indy {
  background: #D70300;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.map-dot--mc {
  background: #0ea5e9;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.map-dot--snow {
  background: #0B1F3A;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.map-legend-shape-label {
  margin: 8px 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.map-legend-shapes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: #1e293b;
}

.map-dot--shape-circle {
  background: #64748b;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.map-dot--shape-diamond {
  background: #64748b;
  border: 2px solid #fff;
  border-radius: 2px;
  transform: rotate(45deg) scale(0.85);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.map-compass {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 8;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.94);
  color: #1e293b;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
  pointer-events: none;
}

.mtn-map-canvas {
  position: absolute;
  inset: 0;
  height: auto;
  min-height: 0;
  isolation: isolate;
}

.mtn-map-canvas .leaflet-skiBase-pane {
  filter: saturate(0.85) brightness(1.02);
}

.mtn-map-canvas .leaflet-control-zoom a {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.mtn-map-canvas .leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.9) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}

.mtn-map-canvas .leaflet-container,
.mtn-map-canvas .leaflet-pane { z-index: 1 !important; }
.mtn-map-canvas .leaflet-marker-pane { z-index: 3 !important; }
.mtn-map-canvas .leaflet-popup-pane { z-index: 5 !important; }
.mtn-map-canvas .leaflet-control-container { z-index: 6; position: relative; }

.mtn-map-marker { background: transparent; border: 0; }
.mtn-map-pin { display: block; border-radius: 50%; box-sizing: border-box; }
.mtn-map-pin--diamond {
  border-radius: 2px;
  transform: rotate(45deg);
}

.mtn-map-leaflet-popup .leaflet-popup-content-wrapper {
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.mtn-map-leaflet-popup .leaflet-popup-tip { background: #fff; }
.mtn-map-leaflet-popup .leaflet-popup-content { margin: 12px 14px; }

.mtn-map-popup-title { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.mtn-map-popup-link { color: inherit; text-decoration: none; }
.mtn-map-popup-link:hover { color: var(--blue); text-decoration: underline; }
.mtn-map-popup-loc { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.mtn-map-popup-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #eff6ff;
}
.mtn-map-popup-stat { font-size: 13px; font-weight: 600; }
.mtn-map-popup-passes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mtn-map-popup-logo { height: 16px; width: auto; }
.mtn-map-pass-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--pass-color);
  color: var(--pass-color);
}

.welcome {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
}

body:not(.welcome-open) .welcome {
  display: none;
}

body.welcome-open {
  overflow: hidden;
}

.welcome-card {
  width: min(480px, 100%);
  padding: 28px 28px 24px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.welcome-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blue);
}

.welcome-card h2 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: -0.03em;
  color: var(--navy);
}

.welcome-lead {
  margin: 0 0 22px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

.welcome-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.welcome-label output {
  color: var(--blue);
  font-weight: 600;
}

.welcome-passes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 22px;
}

.welcome-pass {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.welcome-pass img {
  height: 16px;
  width: auto;
  filter: grayscale(1);
  opacity: 0.45;
}

.welcome-pass strong {
  font-size: 14px;
  color: var(--ink);
}

.welcome-pass.is-active {
  border-color: var(--pass-color, var(--blue));
  background: #fff;
  color: var(--ink);
}

.welcome-pass.is-active img {
  filter: none;
  opacity: 1;
}

.welcome #welcome-vertical {
  width: 100%;
  margin-bottom: 22px;
  accent-color: var(--blue);
}

.welcome-go {
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.welcome-go:hover:not(:disabled) {
  background: #1d4ed8;
}

.welcome-go:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.welcome-hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 720px) {
  body.dash { height: auto; overflow: visible; }
  .dash-body {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(52vh, 64vh);
  }
  .dash-body.is-map-max {
    grid-template-columns: 1fr;
    grid-template-rows: 48px minmax(52vh, 70vh);
  }
  .dash-body.is-map-max .dash-map-toggle {
    writing-mode: horizontal-tb;
    transform: none;
    min-height: 0;
    height: auto;
    width: 100%;
    padding: 8px 10px;
  }
  .dash-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-kpi:first-child { grid-column: auto; }
  .dash-map { min-height: 0; }
  .dash-roster { margin: 0 16px 20px; }
  .dash-roster-head { flex-direction: column; align-items: stretch; }
  .map-search-wrap { top: 10px; width: min(440px, calc(100vw - 24px)); }
}

@media (max-width: 560px) {
  .dash-status { display: none; }
  .dash-nav a:not(:first-child) { display: none; }
  .map-legend { width: 148px; left: 8px; bottom: 96px; padding: 10px; }
  .map-vertical { left: 8px; right: 8px; bottom: 24px; max-width: none; }
  .map-compass { display: none; }
}
