* { box-sizing: border-box; margin: 0; }
body { font-family: system-ui, sans-serif; display: flex; height: 100vh; height: 100dvh; }
#map { flex: 1; }
#sidebar {
  width: 320px; display: flex; flex-direction: column;
  border-left: 1px solid #ddd; background: #fafafa;
}
#sidebar-header { padding: 16px 16px 12px; }
#sidebar-header h2 { font-size: 18px; margin-bottom: 4px; }
#sidebar-header .count { color: #2563eb; font-size: 14px; display: flex; align-items: center; justify-content: space-between; }
.csv-link {
  font-size: 11px; color: #374151; text-decoration: none;
  background: #f3f4f6; border: 1px solid #d1d5db; border-radius: 4px;
  padding: 2px 8px; white-space: nowrap;
}
.csv-link:hover { background: #e5e7eb; }
#street-table-wrap { flex: 1; overflow-y: auto; padding: 0 16px 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 6px 4px; border-bottom: 2px solid #ccc; font-size: 12px; color: #666; position: sticky; top: 0; background: #fafafa; }
td { padding: 6px 4px; border-bottom: 1px solid #eee; }
td.range { color: #555; font-variant-numeric: tabular-nums; }
tr.street-row { cursor: pointer; }
tr.street-row:hover { background: #f0f0f0; }
tr.street-row.selected { background: #fff7ed; }
tr.street-row.selected td { color: #ea580c; font-weight: 600; }
#selected-info {
  padding: 12px 16px; border-top: 1px solid #ddd; background: #fff;
  font-size: 13px; color: #666; min-height: 44px;
}
#selected-info.active { color: #ea580c; font-weight: 500; }
#reset-btn {
  background: #f3f4f6; border: 1px solid #d1d5db; border-radius: 4px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; color: #374151;
}
#reset-btn:hover { background: #e5e7eb; }
.header-row { display: flex; justify-content: space-between; align-items: center; }
#search-wrap { padding: 0 16px 8px; }
#street-search {
  width: 100%; padding: 6px 10px; font-size: 13px;
  border: 1px solid #d1d5db; border-radius: 4px;
  outline: none; font-family: inherit;
}
#street-search:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
tr.street-row.hidden { display: none; }

/* Drag handle - hidden on desktop */
#sidebar-handle { display: none; }

/* Mobile: sidebar becomes a bottom sheet */
@media (max-width: 640px) {
  body { flex-direction: column; }
  #map { flex: 1; min-height: 0; }
  #sidebar {
    width: 100%; border-left: none; border-top: 1px solid #ddd;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 40dvh;
    max-height: 85dvh;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    transition: height 0.3s ease;
    z-index: 10;
  }
  #sidebar.collapsed { height: 56px; }
  #sidebar.expanded { height: 85dvh; }
  #sidebar-handle {
    display: flex; justify-content: center; align-items: center;
    padding: 8px 0 4px; cursor: grab; touch-action: none;
  }
  #sidebar-handle .handle-bar {
    width: 36px; height: 4px; border-radius: 2px; background: #cbd5e1;
  }
  #sidebar-header { padding: 8px 16px 8px; }
  #sidebar-header h2 { font-size: 16px; }
  /* Reserve space at the bottom so the fixed sidebar doesn't cover the map */
  #map { padding-bottom: 56px; }
  /* Info bar: render inside the header on mobile to stay visible when collapsed */
  #selected-info { border-top: none; padding: 4px 16px 8px; font-size: 12px; min-height: unset; }
}
