:root {
  --page: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --map-bg: #e5e7eb;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  /* soft slate gray */
}

.topbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px 0 12px;
}

.topbar label {
  font-weight: 500;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  height: calc(100% - 52px);
  padding: 12px;
  box-sizing: border-box;
}

.viz {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  height: 100%;
}

.panel {
  background: var(--panel);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, .05);
  flex: 1 1 0;
  min-height: 0;
}

#hotViz>.panel,
#odViz>.panel {
  flex: 0 0 auto;
}

.map-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: var(--map-bg);
  box-shadow: 0 16px 40px rgba(15, 23, 42, .05), 0 0 0 1px rgba(148, 163, 184, .25);
  flex: 1 1 auto;
  /* let it grow and shrink with the column */
  min-height: 0;
  /* no artificial floor; use all available space */
}

/* OD map uses the same flex behavior, no extra fixed min-height */
#odMap {
  min-height: 0;
}

.map-wrap svg {
  width: 100%;
  height: 100%;
}

/* BASE legend styles */
.legend-title {
  font-weight: 600;
  font-size: 12px;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: #475569;
}

.legend-bar {
  height: 8px;
  border-radius: 9999px;
}

.legend-bar.hot {
  background: linear-gradient(to right, #ffffcc, #fed976, #fd8d3c, #e31a1c);
}

.legend-bar.flow {
  background: linear-gradient(to right,
      #204080,
      /* deep blue (5% low)   */
      #3b83bd,
      /* bright blue          */
      #8a56b2,
      /* bright purple        */
      #cb352a,
      /* bright red           */
      #92140c
      /* deep red (5% high)   */
    );
}

/* HOT legend (left) — make it smaller */
#hotLegend {
  background: #f1f5f9;
  border: 1px solid rgba(148, 163, 184, .35);
  border-radius: 10px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 140px;
}

#hotLegend .legend-bar {
  width: 120px;
}

#hotLegend .legend-labels {
  width: 120px;
}

/* OD legend (right) — make it a bit longer & right-aligned */
#odLegend {
  background: #f1f5f9;
  border: 1px solid rgba(148, 163, 184, .35);
  border-radius: 10px;
  padding: 4px 6px;
  /* made smaller */
  display: flex;
  flex-direction: column;
  gap: 3px;
  /* tighter layout */
  max-width: 250px;
  /* slightly narrower */
  margin-top: -10px;
  /* move up so bottom aligns with text */
}

#odLegend .legend-bar {
  width: 100%;
}

#odLegend .legend-labels {
  width: 100%;
}

.od-controls {
  position: relative;
  /* for absolute positioning of captions */
  display: flex;
  align-items: flex-start;
  /* align top edges of search and legend */
  gap: 8px;
  justify-content: flex-start;
  /* let margin-left:auto on the legend handle the push */
  flex-wrap: wrap;
  margin-bottom: 0;
  /* remove bottom margin to pull things up */
  margin-top: -4px;
  /* pull up slightly closer to subtitle */
}

.corridor-search {
  display: flex;
  flex-direction: row;
  gap: 16px;
  /* a bit tighter so everything fits comfortably */
  align-items: flex-start;
  flex: 0 1 auto;
  /* let it shrink if panel width is tight */
}

.corridor-input {
  display: flex;
  flex-direction: column;
  /* this SHOULD stack label above input */
  gap: 3px;
  min-width: 150px;
  max-width: 200px;
}

/* Make dropdown text smaller + softer */
#boroughFilter {
  font-size: 12px;
  /* slightly smaller than default 14px */
  color: var(--muted);
  /* soft gray */
  padding: 2px 6px;
  /* optional: lighter visual footprint */
  border-color: #cbd5e1;
  /* subtle border */
}

/* Make the dropdown *options* gray as well */
#boroughFilter option {
  color: var(--muted);
  font-size: 12px;
}

#odSummary {
  margin-top: -6px;
  /* lift it up */
}

#odDbg {
  margin-top: -6px;
  /* lift debug text too */
}

select,
input[type=range] {
  font: inherit;
}

input[type="range"] {
  width: 150px;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: #ffffff;
  color: #0f172a;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .18);
  opacity: 0;
  border: 1px solid rgba(148, 163, 184, .25);
}

.od-node {
  stroke: #ffffff;
  stroke-width: 1;
  cursor: pointer;
}

.od-captions {
  margin-top: 4px;
}

.edge {
  fill: none;
  pointer-events: stroke;
}

/* OD / Cluster view toggle */
.od-toggle {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.od-view-btn {
  border: 1px solid rgba(148, 163, 184, .5);
  background: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.od-view-btn.is-active {
  background: #e2e8ff;
  border-color: #3b82f6;
  color: #0f172a;
}

/* cluster view container (replaces map area) */
.cluster-view {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .05), 0 0 0 1px rgba(148, 163, 184, .25);
  flex: 1 1 0;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  padding: 10px 12px 12px;
}

.cluster-title {
  font-weight: 600;
  font-size: 13.5px;
}

.cluster-subtitle {
  font-size: 12px;
  color: #64748b;
}

.cluster-chart {
  min-height: 250px;
  /* a bit taller for the chart SVG */
  margin-bottom: 12px;
  /* ⬅️ this is what pushes the table down */
}

.cluster-table-wrap {
  overflow-y: auto;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 10px;
}

.cluster-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.cluster-table thead {
  background: #f8fafc;
}

.cluster-table th,
.cluster-table td {
  padding: 6px 8px;
}

.cluster-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
}

.cluster-table tbody tr:hover {
  background: rgba(226, 232, 255, .4);
}

.cluster-table tbody tr.active {
  background: rgba(59, 130, 246, .10);
}

.cluster-tooltip {
  position: absolute;
  pointer-events: none;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, .5);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, .15);
  display: none;
  z-index: 10;
}

/* Completely hide the old corridor filter UI block */
#odCorridorControls {
  display: none !important;
}