@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #F0F4F3;
  color: #323031;
  overflow: hidden;
}

#map-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
}

#map-container canvas { outline: none; }

/* Sidebar */
#sidebar {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 320px;
  max-height: calc(100vh - 32px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  border: 1px solid #D8DFE0;
  padding: 20px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

/* Sidebar header with logo */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.js-logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.js-logo-text {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
  color: #98C93C;
  text-transform: uppercase;
  flex-shrink: 0;
}

#sidebar h1 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 2px;
  color: #354379;
}

#sidebar .subtitle {
  font-size: 11px;
  color: #728BC6;
  margin-bottom: 0;
}

/* Search */
#search-input {
  width: 100%;
  padding: 10px 12px;
  background: #F0F4F3;
  border: 1px solid #D8DFE0;
  border-radius: 6px;
  color: #323031;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

#search-input::placeholder { color: #9CA3AF; }
#search-input:focus { border-color: #98C93C; box-shadow: 0 0 0 2px #98C93C25; }

/* Filter tabs */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-tab {
  flex: 1;
  padding: 8px 4px;
  background: #F0F4F3;
  border: 1px solid #D8DFE0;
  border-radius: 6px;
  color: #6B7280;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.filter-tab:hover { background: #E5EBE9; color: #354379; }
.filter-tab.active {
  background: #98C93C;
  border-color: #98C93C;
  color: #fff;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.stat-card {
  background: #F0F4F3;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid #D8DFE0;
}

.stat-card .label {
  font-size: 11px;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.stat-card .value {
  font-size: 20px;
  font-weight: 700;
  color: #354379;
}

/* System list */
#system-list-wrapper {
  margin-bottom: 4px;
}

#system-list-toggle {
  display: flex;
  align-items: center;
  padding: 8px 4px;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  transition: background 0.15s;
}

#system-list-toggle:hover {
  background: #F0F4F3;
}

#system-list-toggle span:first-child {
  font-size: 11px;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  flex: 1;
}

#system-list-count {
  font-size: 10px;
  color: #9CA3AF;
  margin-right: 6px;
}

#system-list-arrow {
  font-size: 10px;
  color: #9CA3AF;
  transition: transform 0.2s;
}

#system-list-arrow.collapsed {
  transform: rotate(-90deg);
}

#system-list {
  max-height: 240px;
  overflow-y: auto;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}

#system-list.collapsed {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
}

.system-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.system-item:hover { background: #F0F4F3; }
.system-item.selected {
  background: #98C93C18;
  border-left: 2px solid #98C93C;
}

.system-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 10px;
  flex-shrink: 0;
}

.system-item .name {
  font-size: 13px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #323031;
}

.system-item .meta {
  font-size: 11px;
  color: #6B7280;
  margin-left: 8px;
  white-space: nowrap;
  font-weight: 500;
}

/* Top stations */
#top-stations {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #D8DFE0;
}

#top-stations h3 {
  font-size: 11px;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  font-weight: 500;
}

.top-station-item {
  display: flex;
  align-items: center;
  padding: 5px 4px;
  gap: 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.top-station-item[onclick] { cursor: pointer; }
.top-station-item[onclick]:hover { background: #F0F4F3; }

.top-station-rank {
  font-size: 11px;
  font-weight: 600;
  color: #9CA3AF;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.top-station-info {
  flex: 1;
  min-width: 0;
}

.top-station-name {
  font-size: 12px;
  color: #323031;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-station-meta {
  font-size: 11px;
}

.top-station-total {
  font-size: 12px;
  font-weight: 600;
  color: #F7B32B;
  flex-shrink: 0;
}

.heatmap-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.heatmap-header h3 {
  font-size: 11px;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  margin: 0;
}

.heatmap-tz {
  font-size: 9px;
  color: #9CA3AF;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: 14px repeat(24, 1fr);
  gap: 1px;
}

.heatmap-day {
  font-size: 8px;
  color: #9CA3AF;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 2px;
  line-height: 1;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 1.5px;
  min-width: 0;
  transition: transform 0.1s;
}

.heatmap-cell:hover {
  transform: scale(1.3);
  z-index: 1;
}

.heatmap-hours {
  display: grid;
  grid-template-columns: 14px repeat(24, 1fr);
  margin-top: 1px;
}

.heatmap-hour {
  font-size: 7px;
  color: #9CA3AF;
  text-align: center;
}

/* Entity heatmap (station/hex level) */
#entity-heatmap {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #D8DFE0;
}

#entity-heatmap .heatmap-header {
  margin-bottom: 4px;
}

.entity-heatmap-name {
  font-size: 10px;
  color: #374151;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

#entity-heatmap .heatmap-grid {
  grid-template-columns: 24px repeat(24, 1fr);
  gap: 1.5px;
}

#entity-heatmap .heatmap-cell {
  aspect-ratio: 1 / 2;
  border-radius: 2px;
}

#entity-heatmap .heatmap-day {
  font-size: 9px;
}

#entity-heatmap .heatmap-hours {
  grid-template-columns: 24px repeat(24, 1fr);
}

#entity-heatmap .heatmap-hour {
  font-size: 8px;
}

.heatmap-legend-mini {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  margin-top: 4px;
}

.heatmap-loading {
  font-size: 10px;
  color: #9CA3AF;
  padding: 8px 0;
  text-align: center;
}

/* Legend */
.legend {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #D8DFE0;
}

.legend h3 {
  font-size: 11px;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  font-weight: 500;
}

.legend-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #E05252, #F7B32B, #98C93C);
  margin-bottom: 4px;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #6B7280;
}

/* Credits */
.data-credit {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #D8DFE0;
  font-size: 10px;
  color: #9CA3AF;
  text-align: center;
  line-height: 1.6;
}

.data-credit a {
  color: #728BC6;
  text-decoration: none;
  transition: color 0.15s;
}

.data-credit a:hover {
  color: #98C93C;
}

.built-by {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #D8DFE0;
  font-size: 10px;
  color: #9CA3AF;
  text-align: center;
  line-height: 1.6;
}

.built-by a {
  color: #728BC6;
  text-decoration: none;
  transition: color 0.15s;
}

.built-by a:hover {
  color: #98C93C;
}

/* Tooltip */
.deck-tooltip {
  background: rgba(255, 255, 255, 0.96) !important;
  backdrop-filter: blur(12px);
  border: 1px solid #D8DFE0 !important;
  border-radius: 8px !important;
  padding: 14px 16px !important;
  color: #323031 !important;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  font-size: 13px !important;
  max-width: 280px !important;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1) !important;
  pointer-events: none;
  line-height: 1.5 !important;
}

.tooltip-title {
  font-weight: 600;
  font-size: 14px;
  color: #354379;
  margin-bottom: 8px;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}

.tooltip-label { color: #6B7280; }
.tooltip-value { color: #323031; font-weight: 500; }

.tooltip-bar {
  height: 6px;
  background: #E5EBE9;
  border-radius: 3px;
  margin: 6px 0;
  overflow: hidden;
}

.tooltip-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.tooltip-divider {
  height: 1px;
  background: #D8DFE0;
  margin: 8px 0;
}

.delta-positive { color: #2D9B3A; }
.delta-negative { color: #D93636; }
.delta-zero { color: #9CA3AF; }

/* Refresh indicator */
#refresh-indicator {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  color: #6B7280;
  z-index: 10;
  border: 1px solid #D8DFE0;
}

#refresh-indicator .live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #98C93C;
  margin-right: 6px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D8DFE0; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }
